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
1=== added file 'nova/api/openstack/contrib/flavorextradata.py'
2--- nova/api/openstack/contrib/flavorextradata.py 1970-01-01 00:00:00 +0000
3+++ nova/api/openstack/contrib/flavorextradata.py 2011-09-14 19:00:25 +0000
4@@ -0,0 +1,46 @@
5+# Copyright 2011 Canonical Ltd.
6+# All Rights Reserved.
7+#
8+# Licensed under the Apache License, Version 2.0 (the "License"); you may
9+# not use this file except in compliance with the License. You may obtain
10+# a copy of the License at
11+#
12+# http://www.apache.org/licenses/LICENSE-2.0
13+#
14+# Unless required by applicable law or agreed to in writing, software
15+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17+# License for the specific language governing permissions and limitations
18+# under the License.
19+
20+"""
21+The Flavor extra data extension
22+Openstack API version 1.1 lists "name", "ram", "disk", "vcpus" as flavor
23+attributes. This extension adds to that list:
24+ rxtx_cap
25+ rxtx_quota
26+ swap
27+"""
28+
29+from nova.api.openstack import extensions
30+
31+
32+class Flavorextradata(extensions.ExtensionDescriptor):
33+ """The Flavor extra data extension for the OpenStack API."""
34+
35+ def get_name(self):
36+ return "FlavorExtraData"
37+
38+ def get_alias(self):
39+ return "os-flavor-extra-data"
40+
41+ def get_description(self):
42+ return "Provide additional data for flavors"
43+
44+ def get_namespace(self):
45+ return "http://docs.openstack.org/ext/flavor_extra_data/api/v1.1"
46+
47+ def get_updated(self):
48+ return "2011-09-14T00:00:00+00:00"
49+
50+# vim: tabstop=4 shiftwidth=4 softtabstop=4
51
52=== modified file 'nova/api/openstack/flavors.py'
53--- nova/api/openstack/flavors.py 2011-08-25 20:35:04 +0000
54+++ nova/api/openstack/flavors.py 2011-09-14 19:00:25 +0000
55@@ -92,6 +92,10 @@
56 if detailed:
57 flavor_elem.set('ram', str(flavor_dict['ram']))
58 flavor_elem.set('disk', str(flavor_dict['disk']))
59+
60+ for attr in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
61+ flavor_elem.set(attr, str(flavor_dict.get(attr, "")))
62+
63 for link in flavor_dict.get('links', []):
64 elem = etree.SubElement(flavor_elem,
65 '{%s}link' % xmlutil.XMLNS_ATOM)
66
67=== modified file 'nova/api/openstack/schemas/v1.1/flavor.rng'
68--- nova/api/openstack/schemas/v1.1/flavor.rng 2011-08-24 18:08:25 +0000
69+++ nova/api/openstack/schemas/v1.1/flavor.rng 2011-09-14 19:00:25 +0000
70@@ -4,6 +4,10 @@
71 <attribute name="id"> <text/> </attribute>
72 <attribute name="ram"> <text/> </attribute>
73 <attribute name="disk"> <text/> </attribute>
74+ <attribute name="rxtx_cap"> <text/> </attribute>
75+ <attribute name="rxtx_quota"> <text/> </attribute>
76+ <attribute name="swap"> <text/> </attribute>
77+ <attribute name="vcpus"> <text/> </attribute>
78 <zeroOrMore>
79 <externalRef href="../atom-link.rng"/>
80 </zeroOrMore>
81
82=== modified file 'nova/api/openstack/views/flavors.py'
83--- nova/api/openstack/views/flavors.py 2011-08-09 23:26:35 +0000
84+++ nova/api/openstack/views/flavors.py 2011-09-14 19:00:25 +0000
85@@ -50,6 +50,9 @@
86 "disk": flavor_obj["local_gb"],
87 }
88
89+ for key in ("vcpus", "swap", "rxtx_quota", "rxtx_cap"):
90+ detail[key] = flavor_obj.get(key, "")
91+
92 detail.update(simple)
93
94 return detail
95
96=== modified file 'nova/tests/api/openstack/test_extensions.py'
97--- nova/tests/api/openstack/test_extensions.py 2011-08-30 19:41:30 +0000
98+++ nova/tests/api/openstack/test_extensions.py 2011-09-14 19:00:25 +0000
99@@ -87,6 +87,7 @@
100 self.ext_list = [
101 "Createserverext",
102 "FlavorExtraSpecs",
103+ "FlavorExtraData",
104 "Floating_ips",
105 "Fox In Socks",
106 "Hosts",
107
108=== modified file 'nova/tests/api/openstack/test_flavors.py'
109--- nova/tests/api/openstack/test_flavors.py 2011-08-25 20:35:04 +0000
110+++ nova/tests/api/openstack/test_flavors.py 2011-09-14 19:00:25 +0000
111@@ -112,12 +112,20 @@
112 "name": "flavor 1",
113 "ram": "256",
114 "disk": "10",
115+ "rxtx_cap": "",
116+ "rxtx_quota": "",
117+ "swap": "",
118+ "vcpus": "",
119 },
120 {
121 "id": "2",
122 "name": "flavor 2",
123 "ram": "256",
124 "disk": "10",
125+ "rxtx_cap": "",
126+ "rxtx_quota": "",
127+ "swap": "",
128+ "vcpus": "",
129 },
130 ]
131 self.assertEqual(flavors, expected)
132@@ -132,6 +140,10 @@
133 "name": "flavor 12",
134 "ram": "256",
135 "disk": "10",
136+ "rxtx_cap": "",
137+ "rxtx_quota": "",
138+ "swap": "",
139+ "vcpus": "",
140 }
141 self.assertEqual(flavor, expected)
142
143@@ -154,6 +166,10 @@
144 "name": "flavor 12",
145 "ram": "256",
146 "disk": "10",
147+ "rxtx_cap": "",
148+ "rxtx_quota": "",
149+ "swap": "",
150+ "vcpus": "",
151 "links": [
152 {
153 "rel": "self",
154@@ -221,6 +237,10 @@
155 "name": "flavor 1",
156 "ram": "256",
157 "disk": "10",
158+ "rxtx_cap": "",
159+ "rxtx_quota": "",
160+ "swap": "",
161+ "vcpus": "",
162 "links": [
163 {
164 "rel": "self",
165@@ -237,6 +257,10 @@
166 "name": "flavor 2",
167 "ram": "256",
168 "disk": "10",
169+ "rxtx_cap": "",
170+ "rxtx_quota": "",
171+ "swap": "",
172+ "vcpus": "",
173 "links": [
174 {
175 "rel": "self",
176@@ -276,6 +300,10 @@
177 "name": "asdf",
178 "ram": "256",
179 "disk": "10",
180+ "rxtx_cap": "",
181+ "rxtx_quota": "",
182+ "swap": "",
183+ "vcpus": "",
184 "links": [
185 {
186 "rel": "self",
187@@ -303,6 +331,10 @@
188 "name": "asdf",
189 "ram": "256",
190 "disk": "10",
191+ "rxtx_cap": "",
192+ "rxtx_quota": "",
193+ "swap": "",
194+ "vcpus": "",
195 "links": [
196 {
197 "rel": "self",
198@@ -340,6 +372,10 @@
199 "name": "asdf",
200 "ram": 256,
201 "disk": 10,
202+ "rxtx_cap": "",
203+ "rxtx_quota": "",
204+ "swap": "",
205+ "vcpus": "",
206 "links": [
207 {
208 "rel": "self",
209@@ -378,6 +414,10 @@
210 "name": "flavor 23",
211 "ram": "512",
212 "disk": "20",
213+ "rxtx_cap": "",
214+ "rxtx_quota": "",
215+ "swap": "",
216+ "vcpus": "",
217 "links": [
218 {
219 "rel": "self",
220@@ -393,6 +433,10 @@
221 "name": "flavor 13",
222 "ram": "256",
223 "disk": "10",
224+ "rxtx_cap": "",
225+ "rxtx_quota": "",
226+ "swap": "",
227+ "vcpus": "",
228 "links": [
229 {
230 "rel": "self",
231@@ -435,6 +479,10 @@
232 "name": "flavor 23",
233 "ram": "512",
234 "disk": "20",
235+ "rxtx_cap": "",
236+ "rxtx_quota": "",
237+ "swap": "",
238+ "vcpus": "",
239 "links": [
240 {
241 "rel": "self",
242@@ -450,6 +498,10 @@
243 "name": "flavor 13",
244 "ram": "256",
245 "disk": "10",
246+ "rxtx_cap": "",
247+ "rxtx_quota": "",
248+ "swap": "",
249+ "vcpus": "",
250 "links": [
251 {
252 "rel": "self",