We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`deis destroy` did not destroy runtime layer in Opscode management console
On Friday, I performed a `deis destroy` on the NodeJS example application. I didn't check the Opscode Management Console to see if everything had closed down. On Monday, I opened up the Opscode console and the runtime layer was still there (screenshot below).

![screen shot 2013-08-26 at 4 05 29 pm](https://f.cloud.github.com/assets/2786310/1029626/3907f580-0e9c-11e3-9077-d6b740269619.png)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `celerytasks/chef.py`
Content:
```
1 """
2 Much of this has been copied from pyChef.
3 https://github.com/coderanger/pychef
4 
5 We want a simpler version for making API calls
6 """
7 
8 import base64
9 import datetime
10 import hashlib
11 import httplib
12 import json
13 import re
14 import urlparse
15 
16 from chef_rsa import Key
17 
18 
19 def ruby_b64encode(value):
20     """The Ruby function Base64.encode64 automatically breaks things up
21     into 60-character chunks.
22     """
23     b64 = base64.b64encode(value)
24     for i in xrange(0, len(b64), 60):
25         yield b64[i:i+60]
26 
27 
28 class UTC(datetime.tzinfo):
29     """UTC timezone stub."""
30 
31     ZERO = datetime.timedelta(0)
32 
33     def utcoffset(self, dt):
34         return self.ZERO
35 
36     def tzname(self, dt):
37         return 'UTC'
38 
39     def dst(self, dt):
40         return self.ZERO
41 
42 
43 utc = UTC()
44 
45 
46 def canonical_time(timestamp):
47     if timestamp.tzinfo is not None:
48         timestamp = timestamp.astimezone(utc).replace(tzinfo=None)
49     return timestamp.replace(microsecond=0).isoformat() + 'Z'
50 
51 
52 canonical_path_regex = re.compile(r'/+')
53 
54 
55 def canonical_path(path):
56     path = canonical_path_regex.sub('/', path)
57     if len(path) > 1:
58         path = path.rstrip('/')
59     return path
60 
61 
62 def canonical_request(http_method, path, hashed_body, timestamp, user_id):
63     # Canonicalize request parameters
64     http_method = http_method.upper()
65     path = canonical_path(path)
66     if isinstance(timestamp, datetime.datetime):
67         timestamp = canonical_time(timestamp)
68     hashed_path = sha1_base64(path)
69     return """\
70 Method:{}
71 Hashed Path:{}
72 X-Ops-Content-Hash:{}
73 X-Ops-Timestamp:{}
74 X-Ops-UserId:{}""".format(http_method, hashed_path, hashed_body, timestamp,
75                           user_id)
76 
77 
78 def sha1_base64(value):
79     return '\n'.join(ruby_b64encode(hashlib.sha1(value).digest()))
80 
81 
82 def create_authorization(blank_headers, verb, url, priv_key, user, body=''):
83     headers = blank_headers.copy()
84     rsa_key = Key(fp=priv_key)
85     timestamp = canonical_time(datetime.datetime.utcnow())
86     hashed_body = sha1_base64(body)
87 
88     canon = canonical_request(verb, url, hashed_body, timestamp, user)
89     b64_priv = ruby_b64encode(rsa_key.private_encrypt(canon))
90 
91     for i, line in enumerate(b64_priv):
92         headers['X-Ops-Authorization-' + str(i + 1)] = line
93 
94     headers['X-Ops-Timestamp'] = timestamp
95     headers['X-Ops-Content-Hash'] = hashed_body
96     headers['X-Ops-UserId'] = user
97     return headers
98 
99 
100 class ChefAPI(object):
101 
102     headers = {
103         'Accept': 'application/json',
104         'X-Chef-Version': '11.0.4.x',
105         'X-Ops-Sign': 'version=1.0',
106         'Content-Type': 'application/json'
107     }
108 
109     def __init__(self, server_url, client_name, client_key):
110         self.server_url = server_url
111         self.client_name = client_name
112         self.client_key = client_key
113         self.hostname = urlparse.urlsplit(self.server_url).netloc
114         self.path = urlparse.urlsplit(self.server_url).path
115         self.headers.update({'Host': self.hostname})
116         self.conn = httplib.HTTPSConnection(self.hostname)
117         self.conn.connect()
118 
119     def request(self, verb, path, body=''):
120         url = self.path + path
121         headers = create_authorization(
122             self.headers, verb, url, self.client_key, self.client_name, body)
123         self.conn.request(verb, url, body=body, headers=headers)
124         resp = self.conn.getresponse()
125         return resp.read(), resp.status
126 
127     def create_databag(self, name):
128         body = json.dumps({'name': name, 'id': name})
129         resp = self.request('POST', '/data', body)
130         return resp
131 
132     def create_databag_item(self, name, item_name, item_value):
133         item_dict = {'id': item_name}
134         item_dict.update(item_value)
135         body = json.dumps(item_dict)
136         resp = self.request('POST', '/data/%s' % name, body)
137         return resp
138 
139     def get_databag(self, bag_name):
140         return self.request('GET', '/data/%s' % bag_name)
141 
142     def delete_databag(self, bag_name):
143         return self.request('DELETE', '/data/%s' % bag_name)
144 
145     def delete_databag_item(self, bag_name, item_name):
146         return self.request('DELETE', '/data/%s/%s' % (bag_name, item_name))
147 
148     def update_databag_item(self, bag_name, item_name, item_value):
149         body = json.dumps(item_value)
150         return self.request('PUT', '/data/%s/%s' % (bag_name, item_name), body)
151 
152     def get_databag_item(self, bag_name, item_name):
153         return self.request('GET', '/data/%s/%s' % (bag_name, item_name))
154 
155     def get_all_cookbooks(self):
156         return self.request('GET', '/cookbooks')
157 
158     def get_node(self, node_id):
159         return self.request('GET', '/nodes/%s' % node_id)
160 
161     def delete_node(self, node_id):
162         return self.request('DELETE', '/nodes/%s' % node_id)
163 
164     def delete_client(self, client_id):
165         return self.request('DELETE', '/clients/%s' % client_id)
166 
167 #     def create_cookbook(self, cookbook_name, cookbooks, priv_key, user, org):
168 #         checksums = {}
169 #         by_cb = {}
170 #         first = None
171 #         for c in cookbooks:
172 #             json_cb = json.dumps(c)
173 #             first = json_cb
174 #             hasher = hashlib.md5()
175 #             hasher.update(json_cb)
176 #             check = hasher.hexdigest()
177 #             checksums[check] = None
178 #             by_cb[c['name']] = check
179 #         body = json.dumps({'checksums': checksums})
180 #         sandbox = json.loads(self.request('POST', '/sandboxes'))
181 #         print 'Sandbox is ', sandbox
182 #         for k, v in sandbox['checksums'].items():
183 #             print 'URL ', v
184 #             if 'url' in v:
185 #                print 'Trigger it ', self.request(
186 #                    'PUT', v['url'][25:], json_cb, priv_key, user)
187 #
188 #        print 'Mark as uploaded ', self.request(
189 #            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,
190 #            user)
191 #        print 'Mark as uploaded ', self.request(
192 #            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,
193 #            user)
194 #        print 'Mark as uploaded ', self.request(
195 #            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,
196 #            user)
197 #        print 'Mark as uploaded ', self.request(
198 #            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,
199 #            user)
200 #
201 #         for c in cookbooks:
202 #             c['definitions'] = [{
203 #                 'name': 'unicorn_config.rb',
204 #                 'checksum': by_cb[c['name']],
205 #                 'path': 'definitions/unicorn_config.rb',
206 #                 'specificity': 'default'
207 #             }],
208 #             return self.request('PUT', '/organizations/%s/cookbooks/%s/1' %
209 #                                 (org, cookbook_name), body, priv_key, user)
210 #
211 # @task(name='chef.update_data_bag_item')
212 # def update_data_bag_item(conn_info, bag_name, item_name, item_value):
213 #     client = ChefAPI(conn_info['server_url'],
214 #                      conn_info['client_name'],
215 #                      conn_info['client_key'],
216 #                      conn_info['organization'])
217 #     client.update_databag_item(bag_name, item_name, item_value)
218
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/celerytasks/chef.py b/celerytasks/chef.py
--- a/celerytasks/chef.py
+++ b/celerytasks/chef.py
@@ -11,6 +11,7 @@
 import httplib
 import json
 import re
+import time
 import urlparse
 
 from chef_rsa import Key
@@ -22,7 +23,7 @@
     """
     b64 = base64.b64encode(value)
     for i in xrange(0, len(b64), 60):
-        yield b64[i:i+60]
+        yield b64[i:i + 60]
 
 
 class UTC(datetime.tzinfo):
@@ -116,12 +117,20 @@
         self.conn = httplib.HTTPSConnection(self.hostname)
         self.conn.connect()
 
-    def request(self, verb, path, body=''):
+    def request(self, verb, path, body='', attempts=5, interval=5):
         url = self.path + path
         headers = create_authorization(
             self.headers, verb, url, self.client_key, self.client_name, body)
-        self.conn.request(verb, url, body=body, headers=headers)
-        resp = self.conn.getresponse()
+        # retry all chef api requests
+        for _ in range(attempts):
+            self.conn.request(verb, url, body=body, headers=headers)
+            resp = self.conn.getresponse()
+            if resp.status != 500:
+                break
+            time.sleep(interval)
+        else:
+            errmsg = 'Chef API requests failed: {}'.format(path)
+            raise RuntimeError(errmsg)
         return resp.read(), resp.status
 
     def create_databag(self, name):

{"golden_diff": "diff --git a/celerytasks/chef.py b/celerytasks/chef.py\n--- a/celerytasks/chef.py\n+++ b/celerytasks/chef.py\n@@ -11,6 +11,7 @@\n import httplib\n import json\n import re\n+import time\n import urlparse\n \n from chef_rsa import Key\n@@ -22,7 +23,7 @@\n     \"\"\"\n     b64 = base64.b64encode(value)\n     for i in xrange(0, len(b64), 60):\n-        yield b64[i:i+60]\n+        yield b64[i:i + 60]\n \n \n class UTC(datetime.tzinfo):\n@@ -116,12 +117,20 @@\n         self.conn = httplib.HTTPSConnection(self.hostname)\n         self.conn.connect()\n \n-    def request(self, verb, path, body=''):\n+    def request(self, verb, path, body='', attempts=5, interval=5):\n         url = self.path + path\n         headers = create_authorization(\n             self.headers, verb, url, self.client_key, self.client_name, body)\n-        self.conn.request(verb, url, body=body, headers=headers)\n-        resp = self.conn.getresponse()\n+        # retry all chef api requests\n+        for _ in range(attempts):\n+            self.conn.request(verb, url, body=body, headers=headers)\n+            resp = self.conn.getresponse()\n+            if resp.status != 500:\n+                break\n+            time.sleep(interval)\n+        else:\n+            errmsg = 'Chef API requests failed: {}'.format(path)\n+            raise RuntimeError(errmsg)\n         return resp.read(), resp.status\n \n     def create_databag(self, name):\n", "issue": "`deis destroy` did not destroy runtime layer in Opscode management console\nOn Friday, I performed a `deis destroy` on the NodeJS example application. I didn't check the Opscode Management Console to see if everything had closed down. On Monday, I opened up the Opscode console and the runtime layer was still there (screenshot below).\n\n![screen shot 2013-08-26 at 4 05 29 pm](https://f.cloud.github.com/assets/2786310/1029626/3907f580-0e9c-11e3-9077-d6b740269619.png)\n\n", "before_files": [{"content": "\"\"\"\nMuch of this has been copied from pyChef.\nhttps://github.com/coderanger/pychef\n\nWe want a simpler version for making API calls\n\"\"\"\n\nimport base64\nimport datetime\nimport hashlib\nimport httplib\nimport json\nimport re\nimport urlparse\n\nfrom chef_rsa import Key\n\n\ndef ruby_b64encode(value):\n    \"\"\"The Ruby function Base64.encode64 automatically breaks things up\n    into 60-character chunks.\n    \"\"\"\n    b64 = base64.b64encode(value)\n    for i in xrange(0, len(b64), 60):\n        yield b64[i:i+60]\n\n\nclass UTC(datetime.tzinfo):\n    \"\"\"UTC timezone stub.\"\"\"\n\n    ZERO = datetime.timedelta(0)\n\n    def utcoffset(self, dt):\n        return self.ZERO\n\n    def tzname(self, dt):\n        return 'UTC'\n\n    def dst(self, dt):\n        return self.ZERO\n\n\nutc = UTC()\n\n\ndef canonical_time(timestamp):\n    if timestamp.tzinfo is not None:\n        timestamp = timestamp.astimezone(utc).replace(tzinfo=None)\n    return timestamp.replace(microsecond=0).isoformat() + 'Z'\n\n\ncanonical_path_regex = re.compile(r'/+')\n\n\ndef canonical_path(path):\n    path = canonical_path_regex.sub('/', path)\n    if len(path) > 1:\n        path = path.rstrip('/')\n    return path\n\n\ndef canonical_request(http_method, path, hashed_body, timestamp, user_id):\n    # Canonicalize request parameters\n    http_method = http_method.upper()\n    path = canonical_path(path)\n    if isinstance(timestamp, datetime.datetime):\n        timestamp = canonical_time(timestamp)\n    hashed_path = sha1_base64(path)\n    return \"\"\"\\\nMethod:{}\nHashed Path:{}\nX-Ops-Content-Hash:{}\nX-Ops-Timestamp:{}\nX-Ops-UserId:{}\"\"\".format(http_method, hashed_path, hashed_body, timestamp,\n                          user_id)\n\n\ndef sha1_base64(value):\n    return '\\n'.join(ruby_b64encode(hashlib.sha1(value).digest()))\n\n\ndef create_authorization(blank_headers, verb, url, priv_key, user, body=''):\n    headers = blank_headers.copy()\n    rsa_key = Key(fp=priv_key)\n    timestamp = canonical_time(datetime.datetime.utcnow())\n    hashed_body = sha1_base64(body)\n\n    canon = canonical_request(verb, url, hashed_body, timestamp, user)\n    b64_priv = ruby_b64encode(rsa_key.private_encrypt(canon))\n\n    for i, line in enumerate(b64_priv):\n        headers['X-Ops-Authorization-' + str(i + 1)] = line\n\n    headers['X-Ops-Timestamp'] = timestamp\n    headers['X-Ops-Content-Hash'] = hashed_body\n    headers['X-Ops-UserId'] = user\n    return headers\n\n\nclass ChefAPI(object):\n\n    headers = {\n        'Accept': 'application/json',\n        'X-Chef-Version': '11.0.4.x',\n        'X-Ops-Sign': 'version=1.0',\n        'Content-Type': 'application/json'\n    }\n\n    def __init__(self, server_url, client_name, client_key):\n        self.server_url = server_url\n        self.client_name = client_name\n        self.client_key = client_key\n        self.hostname = urlparse.urlsplit(self.server_url).netloc\n        self.path = urlparse.urlsplit(self.server_url).path\n        self.headers.update({'Host': self.hostname})\n        self.conn = httplib.HTTPSConnection(self.hostname)\n        self.conn.connect()\n\n    def request(self, verb, path, body=''):\n        url = self.path + path\n        headers = create_authorization(\n            self.headers, verb, url, self.client_key, self.client_name, body)\n        self.conn.request(verb, url, body=body, headers=headers)\n        resp = self.conn.getresponse()\n        return resp.read(), resp.status\n\n    def create_databag(self, name):\n        body = json.dumps({'name': name, 'id': name})\n        resp = self.request('POST', '/data', body)\n        return resp\n\n    def create_databag_item(self, name, item_name, item_value):\n        item_dict = {'id': item_name}\n        item_dict.update(item_value)\n        body = json.dumps(item_dict)\n        resp = self.request('POST', '/data/%s' % name, body)\n        return resp\n\n    def get_databag(self, bag_name):\n        return self.request('GET', '/data/%s' % bag_name)\n\n    def delete_databag(self, bag_name):\n        return self.request('DELETE', '/data/%s' % bag_name)\n\n    def delete_databag_item(self, bag_name, item_name):\n        return self.request('DELETE', '/data/%s/%s' % (bag_name, item_name))\n\n    def update_databag_item(self, bag_name, item_name, item_value):\n        body = json.dumps(item_value)\n        return self.request('PUT', '/data/%s/%s' % (bag_name, item_name), body)\n\n    def get_databag_item(self, bag_name, item_name):\n        return self.request('GET', '/data/%s/%s' % (bag_name, item_name))\n\n    def get_all_cookbooks(self):\n        return self.request('GET', '/cookbooks')\n\n    def get_node(self, node_id):\n        return self.request('GET', '/nodes/%s' % node_id)\n\n    def delete_node(self, node_id):\n        return self.request('DELETE', '/nodes/%s' % node_id)\n\n    def delete_client(self, client_id):\n        return self.request('DELETE', '/clients/%s' % client_id)\n\n#     def create_cookbook(self, cookbook_name, cookbooks, priv_key, user, org):\n#         checksums = {}\n#         by_cb = {}\n#         first = None\n#         for c in cookbooks:\n#             json_cb = json.dumps(c)\n#             first = json_cb\n#             hasher = hashlib.md5()\n#             hasher.update(json_cb)\n#             check = hasher.hexdigest()\n#             checksums[check] = None\n#             by_cb[c['name']] = check\n#         body = json.dumps({'checksums': checksums})\n#         sandbox = json.loads(self.request('POST', '/sandboxes'))\n#         print 'Sandbox is ', sandbox\n#         for k, v in sandbox['checksums'].items():\n#             print 'URL ', v\n#             if 'url' in v:\n#                print 'Trigger it ', self.request(\n#                    'PUT', v['url'][25:], json_cb, priv_key, user)\n#\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#\n#         for c in cookbooks:\n#             c['definitions'] = [{\n#                 'name': 'unicorn_config.rb',\n#                 'checksum': by_cb[c['name']],\n#                 'path': 'definitions/unicorn_config.rb',\n#                 'specificity': 'default'\n#             }],\n#             return self.request('PUT', '/organizations/%s/cookbooks/%s/1' %\n#                                 (org, cookbook_name), body, priv_key, user)\n#\n# @task(name='chef.update_data_bag_item')\n# def update_data_bag_item(conn_info, bag_name, item_name, item_value):\n#     client = ChefAPI(conn_info['server_url'],\n#                      conn_info['client_name'],\n#                      conn_info['client_key'],\n#                      conn_info['organization'])\n#     client.update_databag_item(bag_name, item_name, item_value)\n", "path": "celerytasks/chef.py"}], "after_files": [{"content": "\"\"\"\nMuch of this has been copied from pyChef.\nhttps://github.com/coderanger/pychef\n\nWe want a simpler version for making API calls\n\"\"\"\n\nimport base64\nimport datetime\nimport hashlib\nimport httplib\nimport json\nimport re\nimport time\nimport urlparse\n\nfrom chef_rsa import Key\n\n\ndef ruby_b64encode(value):\n    \"\"\"The Ruby function Base64.encode64 automatically breaks things up\n    into 60-character chunks.\n    \"\"\"\n    b64 = base64.b64encode(value)\n    for i in xrange(0, len(b64), 60):\n        yield b64[i:i + 60]\n\n\nclass UTC(datetime.tzinfo):\n    \"\"\"UTC timezone stub.\"\"\"\n\n    ZERO = datetime.timedelta(0)\n\n    def utcoffset(self, dt):\n        return self.ZERO\n\n    def tzname(self, dt):\n        return 'UTC'\n\n    def dst(self, dt):\n        return self.ZERO\n\n\nutc = UTC()\n\n\ndef canonical_time(timestamp):\n    if timestamp.tzinfo is not None:\n        timestamp = timestamp.astimezone(utc).replace(tzinfo=None)\n    return timestamp.replace(microsecond=0).isoformat() + 'Z'\n\n\ncanonical_path_regex = re.compile(r'/+')\n\n\ndef canonical_path(path):\n    path = canonical_path_regex.sub('/', path)\n    if len(path) > 1:\n        path = path.rstrip('/')\n    return path\n\n\ndef canonical_request(http_method, path, hashed_body, timestamp, user_id):\n    # Canonicalize request parameters\n    http_method = http_method.upper()\n    path = canonical_path(path)\n    if isinstance(timestamp, datetime.datetime):\n        timestamp = canonical_time(timestamp)\n    hashed_path = sha1_base64(path)\n    return \"\"\"\\\nMethod:{}\nHashed Path:{}\nX-Ops-Content-Hash:{}\nX-Ops-Timestamp:{}\nX-Ops-UserId:{}\"\"\".format(http_method, hashed_path, hashed_body, timestamp,\n                          user_id)\n\n\ndef sha1_base64(value):\n    return '\\n'.join(ruby_b64encode(hashlib.sha1(value).digest()))\n\n\ndef create_authorization(blank_headers, verb, url, priv_key, user, body=''):\n    headers = blank_headers.copy()\n    rsa_key = Key(fp=priv_key)\n    timestamp = canonical_time(datetime.datetime.utcnow())\n    hashed_body = sha1_base64(body)\n\n    canon = canonical_request(verb, url, hashed_body, timestamp, user)\n    b64_priv = ruby_b64encode(rsa_key.private_encrypt(canon))\n\n    for i, line in enumerate(b64_priv):\n        headers['X-Ops-Authorization-' + str(i + 1)] = line\n\n    headers['X-Ops-Timestamp'] = timestamp\n    headers['X-Ops-Content-Hash'] = hashed_body\n    headers['X-Ops-UserId'] = user\n    return headers\n\n\nclass ChefAPI(object):\n\n    headers = {\n        'Accept': 'application/json',\n        'X-Chef-Version': '11.0.4.x',\n        'X-Ops-Sign': 'version=1.0',\n        'Content-Type': 'application/json'\n    }\n\n    def __init__(self, server_url, client_name, client_key):\n        self.server_url = server_url\n        self.client_name = client_name\n        self.client_key = client_key\n        self.hostname = urlparse.urlsplit(self.server_url).netloc\n        self.path = urlparse.urlsplit(self.server_url).path\n        self.headers.update({'Host': self.hostname})\n        self.conn = httplib.HTTPSConnection(self.hostname)\n        self.conn.connect()\n\n    def request(self, verb, path, body='', attempts=5, interval=5):\n        url = self.path + path\n        headers = create_authorization(\n            self.headers, verb, url, self.client_key, self.client_name, body)\n        # retry all chef api requests\n        for _ in range(attempts):\n            self.conn.request(verb, url, body=body, headers=headers)\n            resp = self.conn.getresponse()\n            if resp.status != 500:\n                break\n            time.sleep(interval)\n        else:\n            errmsg = 'Chef API requests failed: {}'.format(path)\n            raise RuntimeError(errmsg)\n        return resp.read(), resp.status\n\n    def create_databag(self, name):\n        body = json.dumps({'name': name, 'id': name})\n        resp = self.request('POST', '/data', body)\n        return resp\n\n    def create_databag_item(self, name, item_name, item_value):\n        item_dict = {'id': item_name}\n        item_dict.update(item_value)\n        body = json.dumps(item_dict)\n        resp = self.request('POST', '/data/%s' % name, body)\n        return resp\n\n    def get_databag(self, bag_name):\n        return self.request('GET', '/data/%s' % bag_name)\n\n    def delete_databag(self, bag_name):\n        return self.request('DELETE', '/data/%s' % bag_name)\n\n    def delete_databag_item(self, bag_name, item_name):\n        return self.request('DELETE', '/data/%s/%s' % (bag_name, item_name))\n\n    def update_databag_item(self, bag_name, item_name, item_value):\n        body = json.dumps(item_value)\n        return self.request('PUT', '/data/%s/%s' % (bag_name, item_name), body)\n\n    def get_databag_item(self, bag_name, item_name):\n        return self.request('GET', '/data/%s/%s' % (bag_name, item_name))\n\n    def get_all_cookbooks(self):\n        return self.request('GET', '/cookbooks')\n\n    def get_node(self, node_id):\n        return self.request('GET', '/nodes/%s' % node_id)\n\n    def delete_node(self, node_id):\n        return self.request('DELETE', '/nodes/%s' % node_id)\n\n    def delete_client(self, client_id):\n        return self.request('DELETE', '/clients/%s' % client_id)\n\n#     def create_cookbook(self, cookbook_name, cookbooks, priv_key, user, org):\n#         checksums = {}\n#         by_cb = {}\n#         first = None\n#         for c in cookbooks:\n#             json_cb = json.dumps(c)\n#             first = json_cb\n#             hasher = hashlib.md5()\n#             hasher.update(json_cb)\n#             check = hasher.hexdigest()\n#             checksums[check] = None\n#             by_cb[c['name']] = check\n#         body = json.dumps({'checksums': checksums})\n#         sandbox = json.loads(self.request('POST', '/sandboxes'))\n#         print 'Sandbox is ', sandbox\n#         for k, v in sandbox['checksums'].items():\n#             print 'URL ', v\n#             if 'url' in v:\n#                print 'Trigger it ', self.request(\n#                    'PUT', v['url'][25:], json_cb, priv_key, user)\n#\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#        print 'Mark as uploaded ', self.request(\n#            'PUT', sandbox['uri'][25:], '''{'is_completed':true}''', priv_key,\n#            user)\n#\n#         for c in cookbooks:\n#             c['definitions'] = [{\n#                 'name': 'unicorn_config.rb',\n#                 'checksum': by_cb[c['name']],\n#                 'path': 'definitions/unicorn_config.rb',\n#                 'specificity': 'default'\n#             }],\n#             return self.request('PUT', '/organizations/%s/cookbooks/%s/1' %\n#                                 (org, cookbook_name), body, priv_key, user)\n#\n# @task(name='chef.update_data_bag_item')\n# def update_data_bag_item(conn_info, bag_name, item_name, item_value):\n#     client = ChefAPI(conn_info['server_url'],\n#                      conn_info['client_name'],\n#                      conn_info['client_key'],\n#                      conn_info['organization'])\n#     client.update_databag_item(bag_name, item_name, item_value)\n", "path": "celerytasks/chef.py"}]}