Merge lp:~jakedahn/nova/lp829687 into lp:~hudson-openstack/nova/trunk

Proposed by Jake Dahn
Status: Work in progress
Proposed branch: lp:~jakedahn/nova/lp829687
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 176 lines (+24/-5)
3 files modified
nova/api/openstack/flavors.py (+1/-0)
nova/api/openstack/views/flavors.py (+1/-0)
nova/tests/api/openstack/test_flavors.py (+22/-5)
To merge this branch: bzr merge lp:~jakedahn/nova/lp829687
Reviewer Review Type Date Requested Status
Brian Waldon (community) Needs Fixing
Vish Ishaya Pending
Joshua McKenty Pending
Review via email: mp+72259@code.launchpad.net

Description of the change

Adding vcpu count to flavors details.

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Unfortunately this is not defined in the spec, so it needs to be registered as an extension. I know it feels ridiculous, but we need to be able to identify when our responses differ from the spec. All you need to do is add an ExtensionDescriptor in contrib. You will also need to update tests to expect the new value you are returning. May I also ask why call this 'vcpu' rather than 'vcpus' or 'cores'?

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

Whew, too fast! Ignore me if you are planning to change anything I mentioned. Next time, you should uncheck the 'Needs Review' checkbox when you register your merge prop :)

Revision history for this message
Jesse Andrews (anotherjesse) wrote :

bcwaldon - I'd like to know where I can propose a patch for 1.1 api then - since this really doesn't feel like an extension at all.

Revision history for this message
Jesse Andrews (anotherjesse) wrote :
Revision history for this message
Jake Dahn (jakedahn) wrote :

Since it has been added to the v1.1 draft, I'm marking this as needs reviews.

Unmerged revisions

1469. By Jake Dahn

fixing tests for flavors

1468. By Jake Dahn

flavors api now displays vcpus

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/flavors.py'
2--- nova/api/openstack/flavors.py 2011-07-20 21:06:36 +0000
3+++ nova/api/openstack/flavors.py 2011-08-19 21:53:26 +0000
4@@ -88,6 +88,7 @@
5 if detailed:
6 flavor_node.setAttribute('ram', str(flavor['ram']))
7 flavor_node.setAttribute('disk', str(flavor['disk']))
8+ flavor_node.setAttribute('vcpus', str(flavor['vcpus']))
9
10 link_nodes = self._create_link_nodes(xml_doc, flavor['links'])
11 for link_node in link_nodes:
12
13=== modified file 'nova/api/openstack/views/flavors.py'
14--- nova/api/openstack/views/flavors.py 2011-07-07 14:02:06 +0000
15+++ nova/api/openstack/views/flavors.py 2011-08-19 21:53:26 +0000
16@@ -45,6 +45,7 @@
17 detail = {
18 "ram": flavor_obj["memory_mb"],
19 "disk": flavor_obj["local_gb"],
20+ "vcpus": flavor_obj["vcpus"],
21 }
22
23 detail.update(simple)
24
25=== modified file 'nova/tests/api/openstack/test_flavors.py'
26--- nova/tests/api/openstack/test_flavors.py 2011-07-22 21:36:41 +0000
27+++ nova/tests/api/openstack/test_flavors.py 2011-08-19 21:53:26 +0000
28@@ -27,12 +27,13 @@
29 from nova import wsgi
30
31
32-def stub_flavor(flavorid, name, memory_mb="256", local_gb="10"):
33+def stub_flavor(flavorid, name, memory_mb="256", local_gb="10", vcpus="2"):
34 return {
35 "flavorid": str(flavorid),
36 "name": name,
37 "memory_mb": memory_mb,
38 "local_gb": local_gb,
39+ "vcpus": vcpus
40 }
41
42
43@@ -107,12 +108,14 @@
44 "name": "flavor 1",
45 "ram": "256",
46 "disk": "10",
47+ "vcpus": "2",
48 },
49 {
50 "id": "2",
51 "name": "flavor 2",
52 "ram": "256",
53 "disk": "10",
54+ "vcpus": "2",
55 },
56 ]
57 self.assertEqual(flavors, expected)
58@@ -127,6 +130,7 @@
59 "name": "flavor 12",
60 "ram": "256",
61 "disk": "10",
62+ "vcpus": "2",
63 }
64 self.assertEqual(flavor, expected)
65
66@@ -149,6 +153,7 @@
67 "name": "flavor 12",
68 "ram": "256",
69 "disk": "10",
70+ "vcpus": "2",
71 "links": [
72 {
73 "rel": "self",
74@@ -216,6 +221,7 @@
75 "name": "flavor 1",
76 "ram": "256",
77 "disk": "10",
78+ "vcpus": "2",
79 "links": [
80 {
81 "rel": "self",
82@@ -232,6 +238,7 @@
83 "name": "flavor 2",
84 "ram": "256",
85 "disk": "10",
86+ "vcpus": "2",
87 "links": [
88 {
89 "rel": "self",
90@@ -271,6 +278,7 @@
91 "name": "asdf",
92 "ram": "256",
93 "disk": "10",
94+ "vcpus": "2",
95 "links": [
96 {
97 "rel": "self",
98@@ -293,7 +301,8 @@
99 id="12"
100 name="asdf"
101 ram="256"
102- disk="10">
103+ disk="10"
104+ vcpus="2">
105 <atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
106 <atom:link href="http://localhost/flavors/12" rel="bookmark"/>
107 </flavor>
108@@ -310,6 +319,7 @@
109 "name": "asdf",
110 "ram": 256,
111 "disk": 10,
112+ "vcpus": 2,
113 "links": [
114 {
115 "rel": "self",
116@@ -332,7 +342,8 @@
117 id="12"
118 name="asdf"
119 ram="256"
120- disk="10">
121+ disk="10"
122+ vcpus="2">
123 <atom:link href="http://localhost/v1.1/flavors/12" rel="self"/>
124 <atom:link href="http://localhost/flavors/12" rel="bookmark"/>
125 </flavor>
126@@ -350,6 +361,7 @@
127 "name": "flavor 23",
128 "ram": "512",
129 "disk": "20",
130+ "vcpus": "2",
131 "links": [
132 {
133 "rel": "self",
134@@ -365,6 +377,7 @@
135 "name": "flavor 13",
136 "ram": "256",
137 "disk": "10",
138+ "vcpus": "2",
139 "links": [
140 {
141 "rel": "self",
142@@ -388,14 +401,16 @@
143 <flavor id="23"
144 name="flavor 23"
145 ram="512"
146- disk="20">
147+ disk="20"
148+ vcpus="2">
149 <atom:link href="http://localhost/v1.1/flavors/23" rel="self"/>
150 <atom:link href="http://localhost/flavors/23" rel="bookmark"/>
151 </flavor>
152 <flavor id="13"
153 name="flavor 13"
154 ram="256"
155- disk="10">
156+ disk="10"
157+ vcpus="2">
158 <atom:link href="http://localhost/v1.1/flavors/13" rel="self"/>
159 <atom:link href="http://localhost/flavors/13" rel="bookmark"/>
160 </flavor>
161@@ -414,6 +429,7 @@
162 "name": "flavor 23",
163 "ram": "512",
164 "disk": "20",
165+ "vcpus": "2",
166 "links": [
167 {
168 "rel": "self",
169@@ -429,6 +445,7 @@
170 "name": "flavor 13",
171 "ram": "256",
172 "disk": "10",
173+ "vcpus": "2",
174 "links": [
175 {
176 "rel": "self",