summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2011-09-15 14:00:19 -0500
committerJosh Kearney <josh@jk0.org>2011-09-15 14:00:19 -0500
commit47f0edd2aa06c99b5b3f8700e513f227a9097ee2 (patch)
treef718b8991f9329dd98b6fe9836f9e27737aa283d
parent11293e0c95c350e62c5a4d6fb437037312d4d6d1 (diff)
parent25b1c6727bdb04ec55a51023f3dab76ba57a54f7 (diff)
downloadnova-47f0edd2aa06c99b5b3f8700e513f227a9097ee2.tar.gz
nova-47f0edd2aa06c99b5b3f8700e513f227a9097ee2.tar.xz
nova-47f0edd2aa06c99b5b3f8700e513f227a9097ee2.zip
Merged trunk.
-rw-r--r--nova/api/openstack/contrib/flavorextradata.py46
-rw-r--r--nova/api/openstack/flavors.py4
-rw-r--r--nova/api/openstack/schemas/v1.1/flavor.rng4
-rw-r--r--nova/api/openstack/views/flavors.py3
-rw-r--r--nova/tests/api/openstack/test_extensions.py1
-rw-r--r--nova/tests/api/openstack/test_flavors.py52
6 files changed, 110 insertions, 0 deletions
diff --git a/nova/api/openstack/contrib/flavorextradata.py b/nova/api/openstack/contrib/flavorextradata.py
new file mode 100644
index 000000000..d0554c7b4
--- /dev/null
+++ b/nova/api/openstack/contrib/flavorextradata.py
@@ -0,0 +1,46 @@
+# Copyright 2011 Canonical Ltd.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+The Flavor extra data extension
+Openstack API version 1.1 lists "name", "ram", "disk", "vcpus" as flavor
+attributes. This extension adds to that list:
+ rxtx_cap
+ rxtx_quota
+ swap
+"""
+
+from nova.api.openstack import extensions
+
+
+class Flavorextradata(extensions.ExtensionDescriptor):
+ """The Flavor extra data extension for the OpenStack API."""
+
+ def get_name(self):
+ return "FlavorExtraData"
+
+ def get_alias(self):
+ return "os-flavor-extra-data"
+
+ def get_description(self):
+ return "Provide additional data for flavors"
+
+ def get_namespace(self):
+ return "http://docs.openstack.org/ext/flavor_extra_data/api/v1.1"
+
+ def get_updated(self):
+ return "2011-09-14T00:00:00+00:00"
+
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py
index 805aad772..8a310c900 100644
--- a/nova/api/openstack/flavors.py
+++ b/nova/api/openstack/flavors.py
@@ -92,6 +92,10 @@ class FlavorXMLSerializer(wsgi.XMLDictSerializer):
if detailed:
flavor_elem.set('ram', str(flavor_dict['ram']))
flavor_elem.set('disk', str(flavor_dict['disk']))
+
+ for attr in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
+ flavor_elem.set(attr, str(flavor_dict.get(attr, "")))
+
for link in flavor_dict.get('links', []):
elem = etree.SubElement(flavor_elem,
'{%s}link' % xmlutil.XMLNS_ATOM)
diff --git a/nova/api/openstack/schemas/v1.1/flavor.rng b/nova/api/openstack/schemas/v1.1/flavor.rng
index a00e4e9ee..6d3adc8dc 100644
--- a/nova/api/openstack/schemas/v1.1/flavor.rng
+++ b/nova/api/openstack/schemas/v1.1/flavor.rng
@@ -4,6 +4,10 @@
<attribute name="id"> <text/> </attribute>
<attribute name="ram"> <text/> </attribute>
<attribute name="disk"> <text/> </attribute>
+ <attribute name="rxtx_cap"> <text/> </attribute>
+ <attribute name="rxtx_quota"> <text/> </attribute>
+ <attribute name="swap"> <text/> </attribute>
+ <attribute name="vcpus"> <text/> </attribute>
<zeroOrMore>
<externalRef href="../atom-link.rng"/>
</zeroOrMore>
diff --git a/nova/api/openstack/views/flavors.py b/nova/api/openstack/views/flavors.py
index aea34b424..def969a6c 100644
--- a/nova/api/openstack/views/flavors.py
+++ b/nova/api/openstack/views/flavors.py
@@ -50,6 +50,9 @@ class ViewBuilder(object):
"disk": flavor_obj["local_gb"],
}
+ for key in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
+ detail[key] = flavor_obj.get(key, "")
+
detail.update(simple)
return detail
diff --git a/nova/tests/api/openstack/test_extensions.py b/nova/tests/api/openstack/test_extensions.py
index 31443242b..44f4eb055 100644
--- a/nova/tests/api/openstack/test_extensions.py
+++ b/nova/tests/api/openstack/test_extensions.py
@@ -87,6 +87,7 @@ class ExtensionControllerTest(test.TestCase):
self.ext_list = [
"Createserverext",
"FlavorExtraSpecs",
+ "FlavorExtraData",
"Floating_ips",
"Fox In Socks",
"Hosts",
diff --git a/nova/tests/api/openstack/test_flavors.py b/nova/tests/api/openstack/test_flavors.py
index a3c5bd107..348042bfe 100644
--- a/nova/tests/api/openstack/test_flavors.py
+++ b/nova/tests/api/openstack/test_flavors.py
@@ -112,12 +112,20 @@ class FlavorsTest(test.TestCase):
"name": "flavor 1",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
},
{
"id": "2",
"name": "flavor 2",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
},
]
self.assertEqual(flavors, expected)
@@ -132,6 +140,10 @@ class FlavorsTest(test.TestCase):
"name": "flavor 12",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
}
self.assertEqual(flavor, expected)
@@ -154,6 +166,10 @@ class FlavorsTest(test.TestCase):
"name": "flavor 12",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -221,6 +237,10 @@ class FlavorsTest(test.TestCase):
"name": "flavor 1",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -237,6 +257,10 @@ class FlavorsTest(test.TestCase):
"name": "flavor 2",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -276,6 +300,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "asdf",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -303,6 +331,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "asdf",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -340,6 +372,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "asdf",
"ram": 256,
"disk": 10,
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -378,6 +414,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "flavor 23",
"ram": "512",
"disk": "20",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -393,6 +433,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "flavor 13",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -435,6 +479,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "flavor 23",
"ram": "512",
"disk": "20",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",
@@ -450,6 +498,10 @@ class FlavorsXMLSerializationTest(test.TestCase):
"name": "flavor 13",
"ram": "256",
"disk": "10",
+ "rxtx_cap": "",
+ "rxtx_quota": "",
+ "swap": "",
+ "vcpus": "",
"links": [
{
"rel": "self",