Created
September 30, 2016 22:04
-
-
Save ahsan518/c3c0565d31439d518ea5ecc3b998ad48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CellById(base.Resource): | |
def get(self, id): | |
context = request.environ.get('context') | |
try: | |
cell_obj = dbapi.cells_get_by_id(context, id) | |
except exceptions.NotFound: | |
return self.error_response(404, 'Not Found') | |
except Exception as err: | |
LOG.error("Error during Cell get by id: %s" % err) | |
return self.error_response(500, 'Unknown Error') | |
cell_obj.data = cell_obj.variables | |
cell = jsonutils.to_primitive(cell_obj) | |
return cell, 200, None | |
def put(self, id): | |
"""Update existing cell.""" | |
# ipdb.set_trace() | |
id_keys = request.form.keys() | |
values = dict((key, request.form.getlist(key)[0]) for key in id_keys) | |
print values | |
context = request.environ.get('context') | |
try: | |
dbapi.cells_update(context, id, values) | |
except exceptions.NotFound: | |
return self.error_response(404, 'Not Found') | |
except Exception as err: | |
LOG.error('Error during cell update: %s' % err) | |
return self.error_response(500, 'Unknown Error') | |
return None, 401, None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@vagrant-ubuntu-trusty-64:~/craton$ curl -i "http://${MY_IP}:8084/v1/cells/{4}" -XPUT -d '{"name": "DTW_3", "region_id": 7,"project_id": 1}' -H "Content-Type: application/json" -H "X-Auth-Token: demo" -H "X-Auth-User: demo" -H "X-Auth-Project: 1" | |
HTTP/1.0 500 INTERNAL SERVER ERROR | |
Date: Fri, 30 Sep 2016 18:53:54 GMT | |
Server: WSGIServer/0.1 Python/2.7.6 | |
Content-Type: application/json | |
Content-Length: 51 | |
x-openstack-request-id: req-9b84eee6-30bf-45f3-8a51-a433ffab9360 | |
{"message": "`401` is not a defined status code."} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment