summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorKen Pepple <ken.pepple@gmail.com>2011-03-02 16:32:09 -0800
committerKen Pepple <ken.pepple@gmail.com>2011-03-02 16:32:09 -0800
commit86aed7edae3dd90741d0da704a99460701b8bcc7 (patch)
treed050143fc31736349de1509b3c83b5b66c80140e /nova/api
parent22ec4e190ccf9e30a7862e1ee7d90f2a0858c438 (diff)
downloadnova-86aed7edae3dd90741d0da704a99460701b8bcc7.tar.gz
nova-86aed7edae3dd90741d0da704a99460701b8bcc7.tar.xz
nova-86aed7edae3dd90741d0da704a99460701b8bcc7.zip
added in req.environ for context
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/flavors.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/nova/api/openstack/flavors.py b/nova/api/openstack/flavors.py
index 4db812c2d..f3d040ba3 100644
--- a/nova/api/openstack/flavors.py
+++ b/nova/api/openstack/flavors.py
@@ -41,25 +41,19 @@ class Controller(wsgi.Controller):
def detail(self, req):
"""Return all flavors in detail."""
- items = [self.show(req, id)['flavor'] for id in self._all_ids()]
+ items = [self.show(req, id)['flavor'] for id in self._all_ids(req)]
return dict(flavors=items)
def show(self, req, id):
"""Return data about the given flavor id."""
- # FIXME(kpepple) do we really need admin context here ?
- ctxt = context.get_admin_context()
+ ctxt = req.environ['nova.context']
values = db.instance_type_get_by_flavor_id(ctxt, id)
- # FIXME(kpepple) refactor db call to return dict
- # v = val.values()[0]
- # item = dict(ram=v['memory_mb'], disk=v['local_gb'],
- # id=v['flavorid'], name=val.keys()[0])
return dict(flavor=values)
raise faults.Fault(exc.HTTPNotFound())
- def _all_ids(self):
+ def _all_ids(self, req):
"""Return the list of all flavorids."""
- # FIXME(kpepple) do we really need admin context here ?
- ctxt = context.get_admin_context()
+ ctxt = req.environ['nova.context']
inst_types = db.instance_type_get_all(ctxt)
flavor_ids = [inst_types[i]['flavorid'] for i in inst_types.keys()]
- return flavor_ids
+ return sorted(flavor_ids)