I am trying to delete a node from chef server using PyChef but i am getting a error given below
<p>I am trying to delete a node on chef server using PyChef but getting an error given below. And here is my script:</p>

<pre><code>import json
import requests
import chef
import base64
from chef import Node
from chef import auth
from chef.rsa import Key
from chef.api import ChefAPI
from chef import api
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()

key = open('/root/chef-repo/.chef/gs-validator.pem', "r").read()
key =Key(key)

hashed_body = auth.sha1_base64('')
#print hashed_body

from datetime import datetime
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
#print timestamp

headers={}
req=auth.canonical_request('GET','here-is-my url-of server',hashed_body,timestamp,'here-is-client-name')
sig =auth. _ruby_b64encode(key.private_encrypt(req))
#print sig
for i, line in enumerate(sig):
headers['x-ops-authorization-%s'%(i+1)] = line
#print headers
#print "--------------",headers.get('x-ops-authorization-%s'%(4),False)

X1= headers.get('x-ops-authorization-%s'%(1),False)
X2 = headers.get('x-ops-authorization-%s'%(2),False)
X3 = headers.get('x-ops-authorization-%s'%(3),False)
X4 = headers.get('x-ops-authorization-%s'%(4),False)
X5 = headers.get('x-ops-authorization-%s'%(5),False)

headers = {'Method':'GET','X-Ops-Content-Hash':hashed_body,'content-    type':'application/json','accept':'application/json','X-Ops-Timestamp':timestamp,'X-Ops-UserId':'gs-validator','X-Ops-Authorization-1':X1,'X-Ops-Authorization-2':X2,'X-Ops-Authorization-3':X3,'X-Ops-Authorization-4':X4,'X-Ops-Authorization-5':X5}

with chef.ChefAPI(url, '/root/chef-repo/.chef/gs-validator.pem', 'gs-    validator',headers = headers,ssl_verify = False):
   node = Node('node-name')
   print node.delete()  
</code></pre>

<p>Error:</p>

<pre><code>Traceback (most recent call last):
File "delchef.py", line 55, in &lt;module&gt;
print node.delete()
File "/usr/local/lib/python2.7/dist-packages/chef/base.py", line 117, in   delete
api.api_request('DELETE', self.url)
File "/usr/local/lib/python2.7/dist-packages/chef/api.py", line 217, in  api_request
response = self.request(method, path, headers, data)
File "/usr/local/lib/python2.7/dist-packages/chef/api.py", line 207, in request
raise ChefServerError.from_error(response.reason, code=response.status_code)
chef.exceptions.ChefServerNotFoundError: Object Not Found
</code></pre>

<p>And when i print instead of node.delete():<br>
    node.attributes</p>

<pre><code>it gives me this output:
chef.node.NodeAttributes object at 0x7fb2c11e7390
</code></pre>

<p>Thank you in advance.. Please suggest me the possible solution for this  error. </p>

<p>PyChef already does all the authentication headers for you, why are you duplicating things? For the specific question, a 404 means the node you are trying to delete doesn't exist. You can see what nodes exist on the server with <code>Node.list()</code>.</p>

python chef pychef