diff options
| author | matt.dietz@rackspace.com <> | 2011-03-17 17:18:43 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-03-17 17:18:43 +0000 |
| commit | aec13f3e7edb0425d89f3e779340b1f1b7bb2e36 (patch) | |
| tree | 7e246f9488a2c82a762351236f8b3f4e4e20aa64 | |
| parent | 0a08d4728b8d209fd62f994539c982d8fbac3ce5 (diff) | |
| parent | f17fb9370d4af42267837a36c937f213669b0291 (diff) | |
| download | nova-aec13f3e7edb0425d89f3e779340b1f1b7bb2e36.tar.gz nova-aec13f3e7edb0425d89f3e779340b1f1b7bb2e36.tar.xz nova-aec13f3e7edb0425d89f3e779340b1f1b7bb2e36.zip | |
Fixes lp736343 - Incorrect mapping of instance type id to flavor id in Openstack API
| -rw-r--r-- | nova/api/openstack/flavors.py | 3 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_flavors.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py index f3d040ba3..1c440b3a9 100644 --- a/nova/api/openstack/flavors.py +++ b/nova/api/openstack/flavors.py @@ -36,7 +36,7 @@ class Controller(wsgi.Controller): def index(self, req): """Return all flavors in brief.""" - return dict(flavors=[dict(id=flavor['id'], name=flavor['name']) + return dict(flavors=[dict(id=flavor['flavorid'], name=flavor['name']) for flavor in self.detail(req)['flavors']]) def detail(self, req): @@ -48,6 +48,7 @@ class Controller(wsgi.Controller): """Return data about the given flavor id.""" ctxt = req.environ['nova.context'] values = db.instance_type_get_by_flavor_id(ctxt, id) + values['id'] = values['flavorid'] return dict(flavor=values) raise faults.Fault(exc.HTTPNotFound()) diff --git a/nova/tests/api/openstack/test_flavors.py b/nova/tests/api/openstack/test_flavors.py index 8280a505f..30326dc50 100644 --- a/nova/tests/api/openstack/test_flavors.py +++ b/nova/tests/api/openstack/test_flavors.py @@ -15,6 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. +import json import stubout import webob @@ -50,3 +51,5 @@ class FlavorsTest(test.TestCase): req = webob.Request.blank('/v1.0/flavors/1') res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 200) + body = json.loads(res.body) + self.assertEqual(body['flavor']['id'], 1) |
