Merge lp:~smoser/nova/lp849160 into lp:~hudson-openstack/nova/trunk

Proposed by Scott Moser
Status: Merged
Approved by: Brian Waldon
Approved revision: 1567
Merged at revision: 1574
Proposed branch: lp:~smoser/nova/lp849160
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 252 lines (+110/-0)
6 files modified
nova/api/openstack/contrib/flavorextradata.py (+46/-0)
nova/api/openstack/flavors.py (+4/-0)
nova/api/openstack/schemas/v1.1/flavor.rng (+4/-0)
nova/api/openstack/views/flavors.py (+3/-0)
nova/tests/api/openstack/test_extensions.py (+1/-0)
nova/tests/api/openstack/test_flavors.py (+52/-0)
To merge this branch: bzr merge lp:~smoser/nova/lp849160
Reviewer Review Type Date Requested Status
Brian Waldon (community) Approve
Devin Carlen (community) Approve
Review via email: mp+75237@code.launchpad.net

Commit message

Adding flavor extra data extension.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

yay, lgtm

review: Approve
Revision history for this message
Brian Waldon (bcwaldon) wrote :

I'm not against exposing these properties, but we need to do it properly:

1) We need to register this as an extension. Just an ExtensionDescriptor is necessary, this doesn't need to be an optional extension
2) The tests need to be updated. Currently, they do not pass.

review: Needs Fixing
lp:~smoser/nova/lp849160 updated
1557. By Scott Moser

make tests pass

1558. By Scott Moser

add extension description for FlavorExtraData

1559. By Scott Moser

fix test_extensions test to know of new extension FlavorExtraData

1560. By Scott Moser

fix white space for pep8

1561. By Scott Moser

add attributes to xml api

1562. By Scott Moser

resolve conflicts / merge with trunk revno 1569

1563. By Scott Moser

update variable name after merge: flavor_node -> flavor_elem

1564. By Scott Moser

make xml-api tests pass

1565. By Scott Moser

flavor_elem.setAttribute -> flavor_elem.set, flavor -> flavor_dict

1566. By Scott Moser

add necessary fields to flavor.rng schema

1567. By Scott Moser

fix pep8 whitespace error

Revision history for this message
Scott Moser (smoser) wrote :

Ok, i'm finally at the point where all the tests pass and the json and xml output now has these additional fields.
I've updated the flavor.rng schema to match the new output also.

In short, I think this is now *actually* ready for review.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

This is great, Scott. One very minor thing I would like you to change is line 22 in the diff. Can you remove "vcpus" from that module-level comment? Once you fix that, I'll approve.

Revision history for this message
Scott Moser (smoser) wrote :

On Wed, 14 Sep 2011, Brian Waldon wrote:

> This is great, Scott. One very minor thing I would like you to change is line 22 in the diff. Can you remove "vcpus" from that module-level comment? Once you fix that, I'll approve.

I assume you're meaning:
  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

I explicitly listed 'vcpus' there as they *are* listed in the 1.1 spec
that I read (os-compute-devguide-cactus.pdf).

I'm definitely OK to move that to the 'adds' list, if thats where it
should go.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Thanks, Scott. Sorry for the confusion!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'nova/api/openstack/contrib/flavorextradata.py'
--- nova/api/openstack/contrib/flavorextradata.py 1970-01-01 00:00:00 +0000
+++ nova/api/openstack/contrib/flavorextradata.py 2011-09-14 19:00:25 +0000
@@ -0,0 +1,46 @@
1# Copyright 2011 Canonical Ltd.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16"""
17The Flavor extra data extension
18Openstack API version 1.1 lists "name", "ram", "disk", "vcpus" as flavor
19attributes. This extension adds to that list:
20 rxtx_cap
21 rxtx_quota
22 swap
23"""
24
25from nova.api.openstack import extensions
26
27
28class Flavorextradata(extensions.ExtensionDescriptor):
29 """The Flavor extra data extension for the OpenStack API."""
30
31 def get_name(self):
32 return "FlavorExtraData"
33
34 def get_alias(self):
35 return "os-flavor-extra-data"
36
37 def get_description(self):
38 return "Provide additional data for flavors"
39
40 def get_namespace(self):
41 return "http://docs.openstack.org/ext/flavor_extra_data/api/v1.1"
42
43 def get_updated(self):
44 return "2011-09-14T00:00:00+00:00"
45
46# vim: tabstop=4 shiftwidth=4 softtabstop=4
047
=== modified file 'nova/api/openstack/flavors.py'
--- nova/api/openstack/flavors.py 2011-08-25 20:35:04 +0000
+++ nova/api/openstack/flavors.py 2011-09-14 19:00:25 +0000
@@ -92,6 +92,10 @@
92 if detailed:92 if detailed:
93 flavor_elem.set('ram', str(flavor_dict['ram']))93 flavor_elem.set('ram', str(flavor_dict['ram']))
94 flavor_elem.set('disk', str(flavor_dict['disk']))94 flavor_elem.set('disk', str(flavor_dict['disk']))
95
96 for attr in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
97 flavor_elem.set(attr, str(flavor_dict.get(attr, "")))
98
95 for link in flavor_dict.get('links', []):99 for link in flavor_dict.get('links', []):
96 elem = etree.SubElement(flavor_elem,100 elem = etree.SubElement(flavor_elem,
97 '{%s}link' % xmlutil.XMLNS_ATOM)101 '{%s}link' % xmlutil.XMLNS_ATOM)
98102
=== modified file 'nova/api/openstack/schemas/v1.1/flavor.rng'
--- nova/api/openstack/schemas/v1.1/flavor.rng 2011-08-24 18:08:25 +0000
+++ nova/api/openstack/schemas/v1.1/flavor.rng 2011-09-14 19:00:25 +0000
@@ -4,6 +4,10 @@
4 <attribute name="id"> <text/> </attribute>4 <attribute name="id"> <text/> </attribute>
5 <attribute name="ram"> <text/> </attribute>5 <attribute name="ram"> <text/> </attribute>
6 <attribute name="disk"> <text/> </attribute>6 <attribute name="disk"> <text/> </attribute>
7 <attribute name="rxtx_cap"> <text/> </attribute>
8 <attribute name="rxtx_quota"> <text/> </attribute>
9 <attribute name="swap"> <text/> </attribute>
10 <attribute name="vcpus"> <text/> </attribute>
7 <zeroOrMore>11 <zeroOrMore>
8 <externalRef href="../atom-link.rng"/>12 <externalRef href="../atom-link.rng"/>
9 </zeroOrMore>13 </zeroOrMore>
1014
=== modified file 'nova/api/openstack/views/flavors.py'
--- nova/api/openstack/views/flavors.py 2011-08-09 23:26:35 +0000
+++ nova/api/openstack/views/flavors.py 2011-09-14 19:00:25 +0000
@@ -50,6 +50,9 @@
50 "disk": flavor_obj["local_gb"],50 "disk": flavor_obj["local_gb"],
51 }51 }
5252
53 for key in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
54 detail[key] = flavor_obj.get(key, "")
55
53 detail.update(simple)56 detail.update(simple)
5457
55 return detail58 return detail
5659
=== modified file 'nova/tests/api/openstack/test_extensions.py'
--- nova/tests/api/openstack/test_extensions.py 2011-08-30 19:41:30 +0000
+++ nova/tests/api/openstack/test_extensions.py 2011-09-14 19:00:25 +0000
@@ -87,6 +87,7 @@
87 self.ext_list = [87 self.ext_list = [
88 "Createserverext",88 "Createserverext",
89 "FlavorExtraSpecs",89 "FlavorExtraSpecs",
90 "FlavorExtraData",
90 "Floating_ips",91 "Floating_ips",
91 "Fox In Socks",92 "Fox In Socks",
92 "Hosts",93 "Hosts",
9394
=== modified file 'nova/tests/api/openstack/test_flavors.py'
--- nova/tests/api/openstack/test_flavors.py 2011-08-25 20:35:04 +0000
+++ nova/tests/api/openstack/test_flavors.py 2011-09-14 19:00:25 +0000
@@ -112,12 +112,20 @@
112 "name": "flavor 1",112 "name": "flavor 1",
113 "ram": "256",113 "ram": "256",
114 "disk": "10",114 "disk": "10",
115 "rxtx_cap": "",
116 "rxtx_quota": "",
117 "swap": "",
118 "vcpus": "",
115 },119 },
116 {120 {
117 "id": "2",121 "id": "2",
118 "name": "flavor 2",122 "name": "flavor 2",
119 "ram": "256",123 "ram": "256",
120 "disk": "10",124 "disk": "10",
125 "rxtx_cap": "",
126 "rxtx_quota": "",
127 "swap": "",
128 "vcpus": "",
121 },129 },
122 ]130 ]
123 self.assertEqual(flavors, expected)131 self.assertEqual(flavors, expected)
@@ -132,6 +140,10 @@
132 "name": "flavor 12",140 "name": "flavor 12",
133 "ram": "256",141 "ram": "256",
134 "disk": "10",142 "disk": "10",
143 "rxtx_cap": "",
144 "rxtx_quota": "",
145 "swap": "",
146 "vcpus": "",
135 }147 }
136 self.assertEqual(flavor, expected)148 self.assertEqual(flavor, expected)
137149
@@ -154,6 +166,10 @@
154 "name": "flavor 12",166 "name": "flavor 12",
155 "ram": "256",167 "ram": "256",
156 "disk": "10",168 "disk": "10",
169 "rxtx_cap": "",
170 "rxtx_quota": "",
171 "swap": "",
172 "vcpus": "",
157 "links": [173 "links": [
158 {174 {
159 "rel": "self",175 "rel": "self",
@@ -221,6 +237,10 @@
221 "name": "flavor 1",237 "name": "flavor 1",
222 "ram": "256",238 "ram": "256",
223 "disk": "10",239 "disk": "10",
240 "rxtx_cap": "",
241 "rxtx_quota": "",
242 "swap": "",
243 "vcpus": "",
224 "links": [244 "links": [
225 {245 {
226 "rel": "self",246 "rel": "self",
@@ -237,6 +257,10 @@
237 "name": "flavor 2",257 "name": "flavor 2",
238 "ram": "256",258 "ram": "256",
239 "disk": "10",259 "disk": "10",
260 "rxtx_cap": "",
261 "rxtx_quota": "",
262 "swap": "",
263 "vcpus": "",
240 "links": [264 "links": [
241 {265 {
242 "rel": "self",266 "rel": "self",
@@ -276,6 +300,10 @@
276 "name": "asdf",300 "name": "asdf",
277 "ram": "256",301 "ram": "256",
278 "disk": "10",302 "disk": "10",
303 "rxtx_cap": "",
304 "rxtx_quota": "",
305 "swap": "",
306 "vcpus": "",
279 "links": [307 "links": [
280 {308 {
281 "rel": "self",309 "rel": "self",
@@ -303,6 +331,10 @@
303 "name": "asdf",331 "name": "asdf",
304 "ram": "256",332 "ram": "256",
305 "disk": "10",333 "disk": "10",
334 "rxtx_cap": "",
335 "rxtx_quota": "",
336 "swap": "",
337 "vcpus": "",
306 "links": [338 "links": [
307 {339 {
308 "rel": "self",340 "rel": "self",
@@ -340,6 +372,10 @@
340 "name": "asdf",372 "name": "asdf",
341 "ram": 256,373 "ram": 256,
342 "disk": 10,374 "disk": 10,
375 "rxtx_cap": "",
376 "rxtx_quota": "",
377 "swap": "",
378 "vcpus": "",
343 "links": [379 "links": [
344 {380 {
345 "rel": "self",381 "rel": "self",
@@ -378,6 +414,10 @@
378 "name": "flavor 23",414 "name": "flavor 23",
379 "ram": "512",415 "ram": "512",
380 "disk": "20",416 "disk": "20",
417 "rxtx_cap": "",
418 "rxtx_quota": "",
419 "swap": "",
420 "vcpus": "",
381 "links": [421 "links": [
382 {422 {
383 "rel": "self",423 "rel": "self",
@@ -393,6 +433,10 @@
393 "name": "flavor 13",433 "name": "flavor 13",
394 "ram": "256",434 "ram": "256",
395 "disk": "10",435 "disk": "10",
436 "rxtx_cap": "",
437 "rxtx_quota": "",
438 "swap": "",
439 "vcpus": "",
396 "links": [440 "links": [
397 {441 {
398 "rel": "self",442 "rel": "self",
@@ -435,6 +479,10 @@
435 "name": "flavor 23",479 "name": "flavor 23",
436 "ram": "512",480 "ram": "512",
437 "disk": "20",481 "disk": "20",
482 "rxtx_cap": "",
483 "rxtx_quota": "",
484 "swap": "",
485 "vcpus": "",
438 "links": [486 "links": [
439 {487 {
440 "rel": "self",488 "rel": "self",
@@ -450,6 +498,10 @@
450 "name": "flavor 13",498 "name": "flavor 13",
451 "ram": "256",499 "ram": "256",
452 "disk": "10",500 "disk": "10",
501 "rxtx_cap": "",
502 "rxtx_quota": "",
503 "swap": "",
504 "vcpus": "",
453 "links": [505 "links": [
454 {506 {
455 "rel": "self",507 "rel": "self",