def create_resource(): body_serializers = {'application/xml': FlavorXMLSerializer()} serializer = wsgi.ResponseSerializer(body_serializers) return wsgi.Resource(Controller(), serializer=serializer)
def create_resource(version='1.0'): controller = { '1.0': ControllerV10, '1.1': ControllerV11, }[version]() metadata = { "attributes": { "server": [ "id", "imageId", "name", "flavorId", "hostId", "status", "progress", "adminPass", "flavorRef", "imageRef", "userId", "tenantId" ], "link": ["rel", "type", "href"], }, "dict_collections": { "metadata": { "item_name": "meta", "item_key": "key" }, }, "list_collections": { "public": { "item_name": "ip", "item_key": "addr" }, "private": { "item_name": "ip", "item_key": "addr" }, }, } xmlns = { '1.0': wsgi.XMLNS_V10, '1.1': wsgi.XMLNS_V11, }[version] headers_serializer = HeadersSerializer() xml_serializer = { '1.0': wsgi.XMLDictSerializer(metadata, wsgi.XMLNS_V10), '1.1': ServerXMLSerializer(), }[version] body_serializers = { 'application/xml': xml_serializer, } xml_deserializer = { '1.0': helper.ServerXMLDeserializer(), '1.1': helper.ServerXMLDeserializerV11(), }[version] body_deserializers = { 'application/xml': xml_deserializer, } serializer = wsgi.ResponseSerializer(body_serializers, headers_serializer) deserializer = wsgi.RequestDeserializer(body_deserializers) return wsgi.Resource(controller, deserializer, serializer)
def __init__(self, application): controller = RequestExtensionController(application) wsgi.Resource.__init__(self, controller, serializer=wsgi.ResponseSerializer(), deserializer=wsgi.RequestDeserializer())
def get_resources(self): resources = [] body_serializers = { 'application/xml': VsaSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) res = extensions.ResourceExtension( 'zadr-vsa', VsaController(), serializer=serializer, collection_actions={'detail': 'GET'}, member_actions={ 'add_capacity': 'POST', 'remove_capacity': 'POST', 'associate_address': 'POST', 'disassociate_address': 'POST' }) resources.append(res) body_serializers = { 'application/xml': VsaVolumeSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) res = extensions.ResourceExtension( 'volumes', VsaVolumeController(), serializer=serializer, collection_actions={'detail': 'GET'}, parent=dict(member_name='vsa', collection_name='zadr-vsa')) resources.append(res) body_serializers = { 'application/xml': VsaDriveSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) res = extensions.ResourceExtension( 'drives', VsaDriveController(), serializer=serializer, collection_actions={'detail': 'GET'}, parent=dict(member_name='vsa', collection_name='zadr-vsa')) resources.append(res) body_serializers = { 'application/xml': VsaVPoolSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) res = extensions.ResourceExtension('vpools', VsaVPoolController(), serializer=serializer, parent=dict( member_name='vsa', collection_name='zadr-vsa')) resources.append(res) headers_serializer = servers.HeadersSerializer() body_serializers = { 'application/xml': servers.ServerXMLSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers, headers_serializer) body_deserializers = { 'application/xml': servers.ServerXMLDeserializer(), } deserializer = wsgi.RequestDeserializer(body_deserializers) res = extensions.ResourceExtension('instances', VsaVCController(), serializer=serializer, deserializer=deserializer, parent=dict( member_name='vsa', collection_name='zadr-vsa')) resources.append(res) return resources
def get_resources(self): resources = [] body_serializers = { 'application/xml': VolumeSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) # NOTE(justinsb): No way to provide singular name ('volume') # Does this matter? res = extensions.ResourceExtension( 'os-volumes', VolumeController(), serializer=serializer, collection_actions={'detail': 'GET'}) resources.append(res) body_serializers = { 'application/xml': VolumeAttachmentSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers) res = extensions.ResourceExtension('os-volume_attachments', VolumeAttachmentController(), serializer=serializer, parent=dict( member_name='server', collection_name='servers')) resources.append(res) headers_serializer = servers.HeadersSerializer() body_serializers = { 'application/xml': servers.ServerXMLSerializer(), } serializer = wsgi.ResponseSerializer(body_serializers, headers_serializer) body_deserializers = { 'application/xml': servers.ServerXMLDeserializer(), } deserializer = wsgi.RequestDeserializer(body_deserializers) res = extensions.ResourceExtension('os-volumes_boot', BootFromVolumeController(), serializer=serializer, deserializer=deserializer) resources.append(res) snapshot_serializers = { 'application/xml': SnapshotSerializer(), } snap_serializer = wsgi.ResponseSerializer(snapshot_serializers) res = extensions.ResourceExtension( 'os-snapshots', SnapshotController(), serializer=snap_serializer, collection_actions={'detail': 'GET'}) resources.append(res) return resources