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" ], "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, } body_deserializers = { 'application/xml': helper.ServerXMLDeserializer(), } serializer = wsgi.ResponseSerializer(body_serializers, headers_serializer) deserializer = wsgi.RequestDeserializer(body_deserializers) return wsgi.Resource(controller, deserializer, serializer)
def create_resource(version): controller = { '1.0': Controller, '1.1': ControllerV11, }[version]() metadata = { "attributes": { "zone": ["id", "api_url", "name", "capabilities"], }, } body_serializers = { 'application/xml': wsgi.XMLDictSerializer(xmlns=wsgi.XMLNS_V10, metadata=metadata), } serializer = wsgi.ResponseSerializer(body_serializers) body_deserializers = { 'application/xml': helper.ServerXMLDeserializer(), } deserializer = wsgi.RequestDeserializer(body_deserializers) return wsgi.Resource(controller, deserializer, serializer)