From 643cf2d3c67a6c9728fd5c766a9cee3a09d67022 Mon Sep 17 00:00:00 2001 From: Alexei Kornienko Date: Thu, 27 Jun 2013 16:24:20 +0300 Subject: Merged flavor_swap extension into core API Partially implements blueprint nova-v3-api Change-Id: Ib58afac2159b25a38165882375e6d6ac57dc6da5 --- nova/api/openstack/compute/plugins/v3/flavors.py | 2 ++ nova/api/openstack/compute/schemas/v3/flavor.rng | 12 ++++++++++++ nova/api/openstack/compute/schemas/v3/flavors.rng | 6 ++++++ nova/api/openstack/xmlutil.py | 8 ++++---- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 nova/api/openstack/compute/schemas/v3/flavor.rng create mode 100644 nova/api/openstack/compute/schemas/v3/flavors.rng (limited to 'nova/api') diff --git a/nova/api/openstack/compute/plugins/v3/flavors.py b/nova/api/openstack/compute/plugins/v3/flavors.py index 733ff3750..31c0fa8b7 100644 --- a/nova/api/openstack/compute/plugins/v3/flavors.py +++ b/nova/api/openstack/compute/plugins/v3/flavors.py @@ -34,6 +34,8 @@ def make_flavor(elem, detailed=False): elem.set('ram') elem.set('disk') elem.set('vcpus', xmlutil.EmptyStringSelector('vcpus')) + # NOTE(vish): this was originally added without a namespace + elem.set('swap', xmlutil.EmptyStringSelector('swap')) xmlutil.make_links(elem, 'links') diff --git a/nova/api/openstack/compute/schemas/v3/flavor.rng b/nova/api/openstack/compute/schemas/v3/flavor.rng new file mode 100644 index 000000000..4b6b74001 --- /dev/null +++ b/nova/api/openstack/compute/schemas/v3/flavor.rng @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/nova/api/openstack/compute/schemas/v3/flavors.rng b/nova/api/openstack/compute/schemas/v3/flavors.rng new file mode 100644 index 000000000..b7a3acc01 --- /dev/null +++ b/nova/api/openstack/compute/schemas/v3/flavors.rng @@ -0,0 +1,6 @@ + + + + + diff --git a/nova/api/openstack/xmlutil.py b/nova/api/openstack/xmlutil.py index 04f5e28e3..37766b3e3 100644 --- a/nova/api/openstack/xmlutil.py +++ b/nova/api/openstack/xmlutil.py @@ -33,12 +33,12 @@ XMLNS_COMMON_V10 = 'http://docs.openstack.org/common/api/v1.0' XMLNS_ATOM = 'http://www.w3.org/2005/Atom' -def validate_schema(xml, schema_name): +def validate_schema(xml, schema_name, version='v1.1'): if isinstance(xml, str): xml = etree.fromstring(xml) - base_path = 'nova/api/openstack/compute/schemas/v1.1/' - if schema_name in ('atom', 'atom-link'): - base_path = 'nova/api/openstack/compute/schemas/' + base_path = 'nova/api/openstack/compute/schemas/' + if schema_name not in ('atom', 'atom-link'): + base_path += '%s/' % version schema_path = os.path.join(utils.novadir(), '%s%s.rng' % (base_path, schema_name)) schema_doc = etree.parse(schema_path) -- cgit