Convert v2.1 extension_info to show V2 API extension list

The V2.1 API implementation does not have a 1-1 mapping of extensions
compared to the V2 API. For example because many of the dummy
extensions were only originally added in order to be able to signal to
the API clients that new functionality was available these were not
ported and functionally hard coded into the original plugin.
However in order to retain complete backwards compatibility we need
to have an /extensions output which is identical to the original
V2 API. This patch implements that backwards compatibility including
fields such as XML namespaces, links and updated which are no
longer supported.

Some minor testcase changes to reflect no real xml support in v2.1
now

Part of blueprint v2-on-v3-api

Change-Id: I8e63a684093dfe3a643c07b20e8080c1e950ed5a
This commit is contained in:
Chris Yeoh 2014-12-03 11:45:02 +10:30
parent 45e4d3a574
commit 30ed3064ab
8 changed files with 608 additions and 230 deletions

View File

@ -1,31 +1,31 @@
{
"extensions": [
{
"alias": "extensions",
"description": "Extension information.",
"alias": "NMN",
"description": "Multiple network support.",
"links": [],
"name": "Extensions",
"name": "Multinic",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "flavors",
"description": "Flavors Extension.",
"alias": "OS-DCF",
"description": "Disk Management Extension.",
"links": [],
"name": "Flavors",
"name": "DiskConfig",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "image-metadata",
"description": "Image Metadata API.",
"alias": "OS-EXT-AZ",
"description": "Extended Availability Zone support.",
"links": [],
"name": "ImageMetadata",
"name": "ExtendedAvailabilityZone",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "image-size",
"alias": "OS-EXT-IMG-SIZE",
"description": "Adds image size to image listings.",
"links": [],
"name": "ImageSize",
@ -33,26 +33,74 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "images",
"description": "Proxying API for Images.",
"alias": "OS-EXT-IPS",
"description": "",
"links": [],
"name": "Images",
"name": "ExtendedIps",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "ips",
"description": "Server addresses.",
"alias": "OS-EXT-IPS-MAC",
"description": "",
"links": [],
"name": "Ips",
"name": "ExtendedIpsMac",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "limits",
"description": "Limits support.",
"alias": "OS-EXT-SRV-ATTR",
"description": "Extended Server Attributes support.",
"links": [],
"name": "Limits",
"name": "ExtendedServerAttributes",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-EXT-STS",
"description": "",
"links": [],
"name": "ExtendedStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-EXT-VIF-NET",
"description": "",
"links": [],
"name": "ExtendedVIFNet",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-FLV-DISABLED",
"description": "",
"links": [],
"name": "FlavorDisabled",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-FLV-EXT-DATA",
"description": "",
"links": [],
"name": "FlavorExtraData",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-SCH-HNT",
"description": "Pass arbitrary key/value pairs to the scheduler.",
"links": [],
"name": "SchedulerHints",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-SRV-USG",
"description": "Adds launched_at and terminated_at on Servers.",
"links": [],
"name": "ServerUsage",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -120,6 +168,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-baremetal-ext-status",
"description": "",
"links": [],
"name": "BareMetalExtStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-baremetal-nodes",
"description": "Admin-only bare-metal node administration.",
@ -136,6 +192,22 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-block-device-mapping-v2-boot",
"description": "",
"links": [],
"name": "BlockDeviceMappingV2Boot",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cell-capacities",
"description": "",
"links": [],
"name": "CellCapacities",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cells",
"description": "Enables cells-related functionality such as adding neighbor cells,\n listing neighbor cells, and getting the capabilities of the local cell.\n ",
@ -160,6 +232,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cloudpipe-update",
"description": "",
"links": [],
"name": "CloudpipeUpdate",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-config-drive",
"description": "Config Drive Extension.",
@ -186,9 +266,9 @@
},
{
"alias": "os-consoles",
"description": "Consoles.",
"description": "Interactive Console support.",
"links": [],
"name": "Consoles",
"name": "RemoteConsoles",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -201,18 +281,18 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-deferred-delete",
"description": "Instance deferred delete.",
"alias": "os-create-server-ext",
"description": "",
"links": [],
"name": "DeferredDelete",
"name": "Createserverext",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-disk-config",
"description": "Disk Management Extension.",
"alias": "os-deferred-delete",
"description": "Instance deferred delete.",
"links": [],
"name": "DiskConfig",
"name": "DeferredDelete",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -225,18 +305,66 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-availability-zone",
"description": "Extended Availability Zone support.",
"alias": "os-extended-evacuate-find-host",
"description": "",
"links": [],
"name": "ExtendedAvailabilityZone",
"name": "ExtendedEvacuateFindHost",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-server-attributes",
"description": "Extended Server Attributes support.",
"alias": "os-extended-floating-ips",
"description": "",
"links": [],
"name": "ExtendedServerAttributes",
"name": "ExtendedFloatingIps",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-hypervisors",
"description": "",
"links": [],
"name": "ExtendedHypervisors",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-networks",
"description": "",
"links": [],
"name": "ExtendedNetworks",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-quotas",
"description": "",
"links": [],
"name": "ExtendedQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-rescue-with-image",
"description": "",
"links": [],
"name": "ExtendedRescueWithImage",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-services",
"description": "",
"links": [],
"name": "ExtendedServices",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-services-delete",
"description": "",
"links": [],
"name": "ExtendedServicesDelete",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -296,6 +424,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-flavor-swap",
"description": "",
"links": [],
"name": "FlavorSwap",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-floating-ip-dns",
"description": "Floating IP DNS support.",
@ -352,6 +488,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-hypervisor-status",
"description": "",
"links": [],
"name": "HypervisorStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-hypervisors",
"description": "Admin-only hypervisor administration.",
@ -369,7 +513,7 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-instance-usage-audit-log",
"alias": "os-instance_usage_audit_log",
"description": "Admin-only Task Log Monitoring.",
"links": [],
"name": "InstanceUsageAuditLog",
@ -408,14 +552,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-multinic",
"description": "Multiple network support.",
"links": [],
"name": "Multinic",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-multiple-create",
"description": "Allow multiple create in the Create Server v3 API.",
@ -480,14 +616,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-remote-consoles",
"description": "Interactive Console support.",
"links": [],
"name": "RemoteConsoles",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-rescue",
"description": "Instance rescue mode.",
@ -496,14 +624,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-scheduler-hints",
"description": "Pass arbitrary key/value pairs to the scheduler.",
"links": [],
"name": "SchedulerHints",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-security-group-default-rules",
"description": "Default rules for security group support.",
@ -536,6 +656,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-group-quotas",
"description": "",
"links": [],
"name": "ServerGroupQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-groups",
"description": "Server group support.",
@ -544,6 +672,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-list-multi-status",
"description": "",
"links": [],
"name": "ServerListMultiStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-password",
"description": "Server password support.",
@ -553,10 +689,18 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-usage",
"description": "Adds launched_at and terminated_at on Servers.",
"alias": "os-server-sort-keys",
"description": "",
"links": [],
"name": "ServerUsage",
"name": "ServerSortKeys",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-start-stop",
"description": "",
"links": [],
"name": "ServerStartStop",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -608,6 +752,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-used-limits-for-admin",
"description": "",
"links": [],
"name": "UsedLimitsForAdmin",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-user-data",
"description": "Add user_data to the Create Server API.",
@ -616,6 +768,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-user-quotas",
"description": "",
"links": [],
"name": "UserQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-virtual-interfaces",
"description": "Virtual interface support.",
@ -624,6 +784,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-volume-attachment-update",
"description": "",
"links": [],
"name": "VolumeAttachmentUpdate",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-volumes",
"description": "Volumes support.",
@ -631,30 +799,6 @@
"name": "Volumes",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "server-metadata",
"description": "Server Metadata API.",
"links": [],
"name": "ServerMetadata",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "servers",
"description": "Servers.",
"links": [],
"name": "Servers",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "versions",
"description": "API Version information.",
"links": [],
"name": "Versions",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
}
]
}
}

View File

@ -7,4 +7,4 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
}
}
}

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import webob.exc
from nova.api.openstack import extensions
@ -21,6 +23,79 @@ from nova.openstack.common import log as logging
ALIAS = 'extensions'
LOG = logging.getLogger(__name__)
# NOTE(cyeoh): The following mappings are currently incomplete
# Having a v2.1 extension loaded can imply that several v2 extensions
# should also appear to be loaded (although they no longer do in v2.1)
v21_to_v2_extension_list_mapping = {
'os-quota-sets': [{'name': 'UserQuotas', 'alias': 'os-user-quotas'},
{'name': 'ExtendedQuotas',
'alias': 'os-extended-quotas'}],
'os-cells': [{'name': 'CellCapacities', 'alias': 'os-cell-capacities'}],
'os-baremetal-nodes': [{'name': 'BareMetalExtStatus',
'alias': 'os-baremetal-ext-status'}],
'os-block-device-mapping': [{'name': 'BlockDeviceMappingV2Boot',
'alias': 'os-block-device-mapping-v2-boot'}],
'os-cloudpipe': [{'name': 'CloudpipeUpdate',
'alias': 'os-cloudpipe-update'}],
'servers': [{'name': 'Createserverext', 'alias': 'os-create-server-ext'},
{'name': 'ExtendedIpsMac', 'alias': 'OS-EXT-IPS-MAC'},
{'name': 'ExtendedIps', 'alias': 'OS-EXT-IPS'},
{'name': 'ServerListMultiStatus',
'alias': 'os-server-list-multi-status'},
{'name': 'ServerSortKeys', 'alias': 'os-server-sort-keys'},
{'name': 'ServerStartStop', 'alias': 'os-server-start-stop'}],
'flavors': [{'name': 'FlavorDisabled', 'alias': 'OS-FLV-DISABLED'},
{'name': 'FlavorExtraData', 'alias': 'OS-FLV-EXT-DATA'},
{'name': 'FlavorSwap', 'alias': 'os-flavor-swap'}],
'os-services': [{'name': 'ExtendedServicesDelete',
'alias': 'os-extended-services-delete'},
{'name': 'ExtendedServices', 'alias':
'os-extended-services'}],
'os-evacuate': [{'name': 'ExtendedEvacuateFindHost',
'alias': 'os-extended-evacuate-find-host'}],
'os-floating-ips': [{'name': 'ExtendedFloatingIps',
'alias': 'os-extended-floating-ips'}],
'os-hypervisors': [{'name': 'ExtendedHypervisors',
'alias': 'os-extended-hypervisors'},
{'name': 'HypervisorStatus',
'alias': 'os-hypervisor-status'}],
'os-networks': [{'name': 'ExtendedNetworks',
'alias': 'os-extended-networks'}],
'os-rescue': [{'name': 'ExtendedRescueWithImage',
'alias': 'os-extended-rescue-with-image'}],
'os-extended-status': [{'name': 'ExtendedStatus',
'alias': 'OS-EXT-STS'}],
'os-virtual-interfaces': [{'name': 'ExtendedVIFNet',
'alias': 'OS-EXT-VIF-NET'}],
'os-used-limits': [{'name': 'UsedLimitsForAdmin',
'alias': 'os-used-limits-for-admin'}],
'os-volumes': [{'name': 'VolumeAttachmentUpdate',
'alias': 'os-volume-attachment-update'}],
'os-server-groups': [{'name': 'ServerGroupQuotas',
'alias': 'os-server-group-quotas'}],
}
# v2.1 plugins which should never appear in the v2 extension list
# This should be the v2.1 alias, not the V2.0 alias
v2_extension_suppress_list = ['servers', 'images', 'versions', 'flavors',
'os-block-device-mapping-v1', 'os-consoles',
'extensions', 'image-metadata', 'ips', 'limits',
'server-metadata'
]
# v2.1 plugins which should appear under a different name in v2
v21_to_v2_alias_mapping = {
'image-size': 'OS-EXT-IMG-SIZE',
'os-remote-consoles': 'os-consoles',
'os-disk-config': 'OS-DCF',
'os-extended-availability-zone': 'OS-EXT-AZ',
'os-extended-server-attributes': 'OS-EXT-SRV-ATTR',
'os-multinic': 'NMN',
'os-scheduler-hints': 'OS-SCH-HNT',
'os-server-usage': 'OS-SRV-USG',
'os-instance-usage-audit-log': 'os-instance_usage_audit_log',
}
# V2.1 does not support XML but we need to keep an entry in the
# /extensions information returned to the user for backwards
# compatibility
@ -43,14 +118,17 @@ class ExtensionInfoController(wsgi.Controller):
def _translate(self, ext):
ext_data = {}
ext_data['name'] = ext.name
ext_data['alias'] = ext.alias
ext_data['description'] = ext.__doc__
ext_data['namespace'] = FAKE_XML_URL
ext_data['updated'] = FAKE_UPDATED_DATE
ext_data['links'] = []
ext_data["name"] = ext.name
ext_data["alias"] = ext.alias
ext_data["description"] = ext.__doc__
ext_data["namespace"] = FAKE_XML_URL
ext_data["updated"] = FAKE_UPDATED_DATE
ext_data["links"] = []
return ext_data
def _create_fake_ext(self, alias, name):
return FakeExtension(alias, name)
def _get_extensions(self, context):
"""Filter extensions list based on policy."""
@ -63,6 +141,32 @@ class ExtensionInfoController(wsgi.Controller):
else:
LOG.debug("Filter out extension %s from discover list",
alias)
# Add fake v2 extensions to list
extra_exts = {}
for alias in discoverable_extensions:
if alias in v21_to_v2_extension_list_mapping:
for extra_ext in v21_to_v2_extension_list_mapping[alias]:
extra_exts[extra_ext["alias"]] = self._create_fake_ext(
extra_ext["name"], extra_ext["alias"])
discoverable_extensions.update(extra_exts)
# Supress extensions which we don't want to see in v2
for supress_ext in v2_extension_suppress_list:
try:
del discoverable_extensions[supress_ext]
except KeyError:
pass
# v2.1 to v2 extension name mapping
for rename_ext in v21_to_v2_alias_mapping:
if rename_ext in discoverable_extensions:
new_name = v21_to_v2_alias_mapping[rename_ext]
mod_ext = copy.deepcopy(
discoverable_extensions.pop(rename_ext))
mod_ext.alias = new_name
discoverable_extensions[new_name] = mod_ext
return discoverable_extensions
@extensions.expected_errors(())
@ -75,6 +179,7 @@ class ExtensionInfoController(wsgi.Controller):
extensions = []
for _alias, ext in sorted_ext_list:
extensions.append(self._translate(ext))
return dict(extensions=extensions)
@extensions.expected_errors(404)

View File

@ -1,31 +1,31 @@
{
"extensions": [
{
"alias": "extensions",
"description": "Extension information.",
"alias": "NMN",
"description": "Multiple network support.",
"links": [],
"name": "Extensions",
"name": "Multinic",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "flavors",
"description": "Flavors Extension.",
"alias": "OS-DCF",
"description": "Disk Management Extension.",
"links": [],
"name": "Flavors",
"name": "DiskConfig",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "image-metadata",
"description": "Image Metadata API.",
"alias": "OS-EXT-AZ",
"description": "Extended Availability Zone support.",
"links": [],
"name": "ImageMetadata",
"name": "ExtendedAvailabilityZone",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "image-size",
"alias": "OS-EXT-IMG-SIZE",
"description": "Adds image size to image listings.",
"links": [],
"name": "ImageSize",
@ -33,26 +33,74 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "images",
"description": "Proxying API for Images.",
"alias": "OS-EXT-IPS",
"description": "",
"links": [],
"name": "Images",
"name": "ExtendedIps",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "ips",
"description": "Server addresses.",
"alias": "OS-EXT-IPS-MAC",
"description": "",
"links": [],
"name": "Ips",
"name": "ExtendedIpsMac",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "limits",
"description": "Limits support.",
"alias": "OS-EXT-SRV-ATTR",
"description": "Extended Server Attributes support.",
"links": [],
"name": "Limits",
"name": "ExtendedServerAttributes",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-EXT-STS",
"description": "",
"links": [],
"name": "ExtendedStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-EXT-VIF-NET",
"description": "",
"links": [],
"name": "ExtendedVIFNet",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-FLV-DISABLED",
"description": "",
"links": [],
"name": "FlavorDisabled",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-FLV-EXT-DATA",
"description": "",
"links": [],
"name": "FlavorExtraData",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-SCH-HNT",
"description": "Pass arbitrary key/value pairs to the scheduler.",
"links": [],
"name": "SchedulerHints",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "OS-SRV-USG",
"description": "Adds launched_at and terminated_at on Servers.",
"links": [],
"name": "ServerUsage",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -120,6 +168,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-baremetal-ext-status",
"description": "",
"links": [],
"name": "BareMetalExtStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-baremetal-nodes",
"description": "Admin-only bare-metal node administration.",
@ -136,6 +192,22 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-block-device-mapping-v2-boot",
"description": "",
"links": [],
"name": "BlockDeviceMappingV2Boot",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cell-capacities",
"description": "",
"links": [],
"name": "CellCapacities",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cells",
"description": "Enables cells-related functionality such as adding neighbor cells,\n listing neighbor cells, and getting the capabilities of the local cell.\n ",
@ -160,6 +232,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-cloudpipe-update",
"description": "",
"links": [],
"name": "CloudpipeUpdate",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-config-drive",
"description": "Config Drive Extension.",
@ -186,9 +266,9 @@
},
{
"alias": "os-consoles",
"description": "Consoles.",
"description": "Interactive Console support.",
"links": [],
"name": "Consoles",
"name": "RemoteConsoles",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -201,18 +281,18 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-deferred-delete",
"description": "Instance deferred delete.",
"alias": "os-create-server-ext",
"description": "",
"links": [],
"name": "DeferredDelete",
"name": "Createserverext",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-disk-config",
"description": "Disk Management Extension.",
"alias": "os-deferred-delete",
"description": "Instance deferred delete.",
"links": [],
"name": "DiskConfig",
"name": "DeferredDelete",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -225,18 +305,66 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-availability-zone",
"description": "Extended Availability Zone support.",
"alias": "os-extended-evacuate-find-host",
"description": "",
"links": [],
"name": "ExtendedAvailabilityZone",
"name": "ExtendedEvacuateFindHost",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-server-attributes",
"description": "Extended Server Attributes support.",
"alias": "os-extended-floating-ips",
"description": "",
"links": [],
"name": "ExtendedServerAttributes",
"name": "ExtendedFloatingIps",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-hypervisors",
"description": "",
"links": [],
"name": "ExtendedHypervisors",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-networks",
"description": "",
"links": [],
"name": "ExtendedNetworks",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-quotas",
"description": "",
"links": [],
"name": "ExtendedQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-rescue-with-image",
"description": "",
"links": [],
"name": "ExtendedRescueWithImage",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-services",
"description": "",
"links": [],
"name": "ExtendedServices",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-extended-services-delete",
"description": "",
"links": [],
"name": "ExtendedServicesDelete",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -296,6 +424,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-flavor-swap",
"description": "",
"links": [],
"name": "FlavorSwap",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-floating-ip-dns",
"description": "Floating IP DNS support.",
@ -352,6 +488,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-hypervisor-status",
"description": "",
"links": [],
"name": "HypervisorStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-hypervisors",
"description": "Admin-only hypervisor administration.",
@ -369,7 +513,7 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-instance-usage-audit-log",
"alias": "os-instance_usage_audit_log",
"description": "Admin-only Task Log Monitoring.",
"links": [],
"name": "InstanceUsageAuditLog",
@ -408,14 +552,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-multinic",
"description": "Multiple network support.",
"links": [],
"name": "Multinic",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-multiple-create",
"description": "Allow multiple create in the Create Server v3 API.",
@ -480,14 +616,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-remote-consoles",
"description": "Interactive Console support.",
"links": [],
"name": "RemoteConsoles",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-rescue",
"description": "Instance rescue mode.",
@ -496,14 +624,6 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-scheduler-hints",
"description": "Pass arbitrary key/value pairs to the scheduler.",
"links": [],
"name": "SchedulerHints",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-security-group-default-rules",
"description": "Default rules for security group support.",
@ -536,6 +656,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-group-quotas",
"description": "",
"links": [],
"name": "ServerGroupQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-groups",
"description": "Server group support.",
@ -544,6 +672,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-list-multi-status",
"description": "",
"links": [],
"name": "ServerListMultiStatus",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-password",
"description": "Server password support.",
@ -553,10 +689,18 @@
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-usage",
"description": "Adds launched_at and terminated_at on Servers.",
"alias": "os-server-sort-keys",
"description": "",
"links": [],
"name": "ServerUsage",
"name": "ServerSortKeys",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-server-start-stop",
"description": "",
"links": [],
"name": "ServerStartStop",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
@ -608,6 +752,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-used-limits-for-admin",
"description": "",
"links": [],
"name": "UsedLimitsForAdmin",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-user-data",
"description": "Add user_data to the Create Server API.",
@ -616,6 +768,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-user-quotas",
"description": "",
"links": [],
"name": "UserQuotas",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-virtual-interfaces",
"description": "Virtual interface support.",
@ -624,6 +784,14 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-volume-attachment-update",
"description": "",
"links": [],
"name": "VolumeAttachmentUpdate",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "os-volumes",
"description": "Volumes support.",
@ -631,30 +799,6 @@
"name": "Volumes",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "server-metadata",
"description": "Server Metadata API.",
"links": [],
"name": "ServerMetadata",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "servers",
"description": "Servers.",
"links": [],
"name": "Servers",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
},
{
"alias": "versions",
"description": "API Version information.",
"links": [],
"name": "Versions",
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
}
]
}
}

View File

@ -7,4 +7,4 @@
"namespace": "http://docs.openstack.org/compute/ext/fake_xml",
"updated": "2014-12-03T00:00:00Z"
}
}
}

View File

@ -13,10 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import re
import mock
from oslo_serialization import jsonutils
from nova.api.openstack import extensions as api_extensions
from nova.tests.functional.v3 import api_sample_base
@ -49,33 +46,3 @@ class ExtensionInfoSamplesJsonTest(api_sample_base.ApiSampleTestBaseV3):
response = self._do_get('extensions/os-create-backup')
subs = self._get_regexes()
self._verify_response('extensions-get-resp', subs, response, 200)
class ExtensionInfoFormatTest(api_sample_base.ApiSampleTestBaseV3):
# NOTE: To check all extension formats, here makes authorize() return True
# always instead of fake_policy.py because most extensions are not set as
# "discoverable" in fake_policy.py.
all_extensions = True
def _test_list_extensions(self, key, pattern):
with mock.patch.object(api_extensions,
'soft_extension_authorizer') as api_mock:
def fake_soft_extension_authorizer(api_name, extension_name):
def authorize(context, action=None):
return True
return authorize
api_mock.side_effect = fake_soft_extension_authorizer
response = self._do_get('extensions')
response = jsonutils.loads(response.content)
extensions = response['extensions']
pattern_comp = re.compile(pattern)
for ext in extensions:
self.assertIsNotNone(pattern_comp.match(ext[key]),
'%s does not match with %s' % (ext[key],
pattern))
def test_list_extensions_name_format(self):
# name should be CamelCase.
pattern = '^[A-Z]{1}[a-z]{1}[a-zA-Z]*$'
self._test_list_extensions('name', pattern)

View File

@ -12,6 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import webob
from nova.api.openstack.compute import plugins
from nova.api.openstack.compute.plugins.v3 import extension_info
from nova import exception
@ -128,9 +132,29 @@ class ExtensionInfoV21Test(test.NoDBTestCase):
def test_extension_info_list(self):
req = fakes.HTTPRequest.blank('/extensions')
res_dict = self.controller.index(req)
self.assertEqual(5, len(res_dict['extensions']))
self.assertEqual(12, len(res_dict['extensions']))
expected_output = simulated_extension_list
expected_output = copy.deepcopy(simulated_extension_list)
del expected_output['images']
del expected_output['servers']
expected_output['os-cell-capacities'] = fake_extension(
'CellCapacities', 'os-cell-capacities', '', -1)
expected_output['os-server-sort-keys'] = fake_extension(
'ServerSortKeys', 'os-server-sort-keys', '', -1)
expected_output['os-user-quotas'] = fake_extension(
'UserQuotas', 'os-user-quotas', '', -1)
expected_output['os-extended-quotas'] = fake_extension(
'ExtendedQuotas', 'os-extended-quotas', '', -1)
expected_output['os-create-server-ext'] = fake_extension(
'Createserverext', 'os-create-server-ext', '', -1)
expected_output['OS-EXT-IPS'] = fake_extension(
'ExtendedIps', 'OS-EXT-IPS', '', -1)
expected_output['OS-EXT-IPS-MAC'] = fake_extension(
'ExtendedIpsMac', 'OS-EXT-IPS-MAC', '', -1)
expected_output['os-server-list-multi-status'] = fake_extension(
'ServerListMultiStatus', 'os-server-list-multi-status', '', -1)
expected_output['os-server-start-stop'] = fake_extension(
'ServerStartStop', 'os-server-start-stop', '', -1)
for e in res_dict['extensions']:
self.assertIn(e['alias'], expected_output)
@ -155,3 +179,8 @@ class ExtensionInfoV21Test(test.NoDBTestCase):
self.assertEqual(res_dict['extension']['updated'], FAKE_UPDATED_DATE)
self.assertEqual(res_dict['extension']['links'], [])
self.assertEqual(6, len(res_dict['extension']))
def test_extension_info_show_servers_not_present(self):
req = fakes.HTTPRequest.blank('/extensions/servers')
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
req, 'servers')

View File

@ -148,24 +148,13 @@ class UrlmapTest(test.NoDBTestCase):
body = jsonutils.loads(res.body)
self.assertEqual(body['version']['id'], 'v2.1')
def test_path_content_type_v21(self):
# Test URL path specifying JSON returns JSON content.
url = '/v2.1/fake/extensions/extensions.json'
req = webob.Request.blank(url)
req.accept = "application/xml"
res = req.get_response(fakes.wsgi_app_v21())
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['extension']['name'], 'Extensions')
def test_accept_content_type_v21(self):
# Test Accept header specifying JSON returns JSON content.
url = '/v2.1/fake/extensions/extensions'
req = webob.Request.blank(url)
req = webob.Request.blank('/')
req.content_type = "application/json;version=2.1"
req.accept = "application/xml;q=0.8, application/json"
res = req.get_response(fakes.wsgi_app_v21(init_only=('extensions',)))
res = req.get_response(fakes.wsgi_app_v21(init_only=('versions',)))
self.assertEqual(res.status_int, 200)
self.assertEqual(res.content_type, "application/json")
body = jsonutils.loads(res.body)
self.assertEqual(body['extension']['name'], 'Extensions')
self.assertEqual(body['version']['id'], 'v2.1')