diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-09-12 20:10:57 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-09-12 20:10:57 +0000 |
| commit | 050be203cb43a12ca430eadfd30c87690b33b9cf (patch) | |
| tree | 08aab8307fd2152dc546b62320fdc7ded3196665 /nova/api | |
| parent | e03f6a245d5be18e3918090cdd951f17b59d3585 (diff) | |
| download | nova-050be203cb43a12ca430eadfd30c87690b33b9cf.tar.gz nova-050be203cb43a12ca430eadfd30c87690b33b9cf.tar.xz nova-050be203cb43a12ca430eadfd30c87690b33b9cf.zip | |
Add support for vendor content types
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/versions.py | 7 | ||||
| -rw-r--r-- | nova/api/openstack/wsgi.py | 20 |
2 files changed, 24 insertions, 3 deletions
diff --git a/nova/api/openstack/versions.py b/nova/api/openstack/versions.py index e2f892fb6..04d9915ca 100644 --- a/nova/api/openstack/versions.py +++ b/nova/api/openstack/versions.py @@ -100,13 +100,17 @@ class Versions(wsgi.Resource): body_serializers = { 'application/atom+xml': VersionsAtomSerializer(metadata=metadata), 'application/xml': VersionsXMLSerializer(metadata=metadata), + 'application/vnd.openstack.compute+xml': + VersionsXMLSerializer(metadata=metadata), } serializer = wsgi.ResponseSerializer( body_serializers=body_serializers, headers_serializer=headers_serializer) supported_content_types = ('application/json', + 'application/vnd.openstack.compute+json', 'application/xml', + 'application/vnd.openstack.compute+xml', 'application/atom+xml') deserializer = VersionsRequestDeserializer( supported_content_types=supported_content_types) @@ -383,12 +387,15 @@ def create_resource(version='1.0'): body_serializers = { 'application/xml': VersionsXMLSerializer(), + 'application/vnd.openstack.compute+xml': VersionsXMLSerializer(), 'application/atom+xml': VersionsAtomSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) supported_content_types = ('application/json', + 'application/vnd.openstack.compute+json', 'application/xml', + 'application/vnd.openstack.compute+xml', 'application/atom+xml') deserializer = wsgi.RequestDeserializer( supported_content_types=supported_content_types) diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 8641e960a..ee6b87403 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -28,8 +28,12 @@ class Request(webob.Request): Based on the query extension then the Accept header. """ + LOG.info('supported = %s' % repr(supported_content_types)) supported_content_types = supported_content_types or \ - ('application/json', 'application/xml') + ('application/json', + 'application/vnd.openstack.compute+json', + 'application/xml', + 'application/vnd.openstack.compute+xml') parts = self.path.rsplit('.', 1) if len(parts) > 1: @@ -51,7 +55,10 @@ class Request(webob.Request): if not "Content-Type" in self.headers: return None - allowed_types = ("application/xml", "application/json") + allowed_types = ('application/json', + 'application/vnd.openstack.compute+json', + 'application/xml', + 'application/vnd.openstack.compute+xml') content_type = self.content_type if content_type not in allowed_types: @@ -191,11 +198,16 @@ class RequestDeserializer(object): supported_content_types=None): self.supported_content_types = supported_content_types or \ - ('application/json', 'application/xml') + ('application/json', + 'application/vnd.openstack.compute+json', + 'application/xml', + 'application/vnd.openstack.compute+xml') self.body_deserializers = { 'application/xml': XMLDeserializer(), + 'application/vnd.openstack.compute+xml': XMLDeserializer(), 'application/json': JSONDeserializer(), + 'application/vnd.openstack.compute+json': JSONDeserializer(), } self.body_deserializers.update(body_deserializers or {}) @@ -409,7 +421,9 @@ class ResponseSerializer(object): def __init__(self, body_serializers=None, headers_serializer=None): self.body_serializers = { 'application/xml': XMLDictSerializer(), + 'application/vnd.openstack.compute+xml': XMLDictSerializer(), 'application/json': JSONDictSerializer(), + 'application/vnd.openstack.compute+json': JSONDictSerializer(), } self.body_serializers.update(body_serializers or {}) |
