diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-05-15 12:54:16 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-05-15 15:44:14 -0400 |
| commit | ba76b954e69de56f76f9db5cade1780bc351be67 (patch) | |
| tree | 981706789636899cb13739a9f8942d882232b72c /nova/api | |
| parent | c8cafc6e9df3a389330da08cbcbf60fb6ca1b238 (diff) | |
| download | nova-ba76b954e69de56f76f9db5cade1780bc351be67.tar.gz nova-ba76b954e69de56f76f9db5cade1780bc351be67.tar.xz nova-ba76b954e69de56f76f9db5cade1780bc351be67.zip | |
Make use of openstack.common.jsonutils.
This patch imports jsonutils from openstack-common. It removes the
equivalent code from nova.utils and then converts the code base to use
jsonutils. The primary motivator for this change was to remove the rest
of the dependencies from nova.rpc on nova.utils.
Change-Id: If43658b9b098ed56cba018c81be268b8c3e2916a
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/__init__.py | 11 | ||||
| -rw-r--r-- | nova/api/openstack/wsgi.py | 8 |
2 files changed, 10 insertions, 9 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index ebcdc6aed..33a5c4af4 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -38,6 +38,7 @@ from nova import flags from nova import log as logging from nova.openstack.common import cfg from nova.openstack.common import importutils +from nova.openstack.common import jsonutils from nova import utils from nova import wsgi @@ -226,7 +227,7 @@ class EC2Token(wsgi.Middleware): 'path': req.path, 'params': auth_params, }}} - creds_json = utils.dumps(creds) + creds_json = jsonutils.dumps(creds) headers = {'Content-Type': 'application/json'} # Disable "has no x member" pylint error @@ -245,7 +246,7 @@ class EC2Token(wsgi.Middleware): # having keystone return token, tenant, # user, and roles from this call. - result = utils.loads(response) + result = jsonutils.loads(response) try: token_id = result['access']['token']['id'] except (AttributeError, KeyError), e: @@ -289,7 +290,7 @@ class EC2KeystoneAuth(wsgi.Middleware): creds = {'ec2Credentials': cred_dict} else: creds = {'auth': {'OS-KSEC2:ec2Credentials': cred_dict}} - creds_json = utils.dumps(creds) + creds_json = jsonutils.dumps(creds) headers = {'Content-Type': 'application/json'} o = urlparse.urlparse(FLAGS.keystone_ec2_url) @@ -306,7 +307,7 @@ class EC2KeystoneAuth(wsgi.Middleware): else: msg = _("Failure communicating with keystone") return ec2_error(req, request_id, "Unauthorized", msg) - result = utils.loads(data) + result = jsonutils.loads(data) conn.close() try: @@ -645,7 +646,7 @@ class Executor(wsgi.Application): env.pop(k) LOG.exception(_('Unexpected error raised: %s'), unicode(ex)) - LOG.error(_('Environment: %s') % utils.dumps(env)) + LOG.error(_('Environment: %s') % jsonutils.dumps(env)) return ec2_error(req, request_id, 'UnknownError', _('An unknown error has occurred. ' 'Please try your request again.')) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index f65425246..04c87c21a 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -26,7 +26,7 @@ import webob from nova import exception from nova import log as logging -from nova import utils +from nova.openstack.common import jsonutils from nova import wsgi @@ -130,7 +130,7 @@ class JSONDeserializer(TextDeserializer): def _from_json(self, datastring): try: - return utils.loads(datastring) + return jsonutils.loads(datastring) except ValueError: msg = _("cannot understand JSON") raise exception.MalformedRequestBody(reason=msg) @@ -242,7 +242,7 @@ class JSONDictSerializer(DictSerializer): """Default JSON request body serialization""" def default(self, data): - return utils.dumps(data) + return jsonutils.dumps(data) class XMLDictSerializer(DictSerializer): @@ -533,7 +533,7 @@ def action_peek_json(body): """Determine action to invoke.""" try: - decoded = utils.loads(body) + decoded = jsonutils.loads(body) except ValueError: msg = _("cannot understand JSON") raise exception.MalformedRequestBody(reason=msg) |
