From e220baf1b10ebeec11151cb8e8a50a230ab42c49 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: 2013年8月14日 13:24:27 +0900 Subject: [PATCH] Port "Make flavors is_public option .." to v3 tree The following commit(I5b37fa0bb19683fe1642fd81222547d4a317054e) have not been merged to v3 tree now, because the commit was merged to the existing api after porting flavors.py to v3 tree. commit b65d506a5f9d9b2b20777a9aceb44a8ffed6a5de Author: Russell Bryant Date: Thu Jun 27 21:00:05 2013 +0000 Make flavors is_public option actually work This patch ports the commit to v3 tree. Partially implements blueprint nova-v3-api Change-Id: I3c7f11c53594118456d0cd62eb1ddf74634b77c3 --- nova/api/openstack/compute/plugins/v3/flavor_access.py | 2 +- nova/api/openstack/compute/plugins/v3/flavors.py | 3 ++- .../api/openstack/compute/plugins/v3/test_flavor_access.py | 2 +- nova/tests/api/openstack/compute/plugins/v3/test_flavors.py | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nova/api/openstack/compute/plugins/v3/flavor_access.py b/nova/api/openstack/compute/plugins/v3/flavor_access.py index 4baa8bf37fb2..848009ed581e 100644 --- a/nova/api/openstack/compute/plugins/v3/flavor_access.py +++ b/nova/api/openstack/compute/plugins/v3/flavor_access.py @@ -95,7 +95,7 @@ class FlavorAccessController(object): authorize(context) try: - flavor = flavors.get_flavor_by_flavor_id(flavor_id) + flavor = flavors.get_flavor_by_flavor_id(flavor_id, ctxt=context) except exception.FlavorNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/plugins/v3/flavors.py b/nova/api/openstack/compute/plugins/v3/flavors.py index bf15ba81a664..9250d9b68e49 100644 --- a/nova/api/openstack/compute/plugins/v3/flavors.py +++ b/nova/api/openstack/compute/plugins/v3/flavors.py @@ -93,8 +93,9 @@ class FlavorsController(wsgi.Controller): @wsgi.serializers(xml=FlavorTemplate) def show(self, req, id): """Return data about the given flavor id.""" + context = req.environ['nova.context'] try: - flavor = flavors.get_flavor_by_flavor_id(id) + flavor = flavors.get_flavor_by_flavor_id(id, ctxt=context) req.cache_db_flavor(flavor) except exception.FlavorNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py b/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py index c2455d327ef8..f4c750829985 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_flavor_access.py @@ -68,7 +68,7 @@ def fake_get_flavor_access_by_flavor_id(flavorid): return res -def fake_get_flavor_by_flavor_id(flavorid): +def fake_get_flavor_by_flavor_id(flavorid, ctxt=None): return INSTANCE_TYPES[flavorid] diff --git a/nova/tests/api/openstack/compute/plugins/v3/test_flavors.py b/nova/tests/api/openstack/compute/plugins/v3/test_flavors.py index 223b9850c954..c600b29642e3 100644 --- a/nova/tests/api/openstack/compute/plugins/v3/test_flavors.py +++ b/nova/tests/api/openstack/compute/plugins/v3/test_flavors.py @@ -58,7 +58,7 @@ FAKE_FLAVORS = { } -def fake_flavor_get_by_flavor_id(flavorid): +def fake_flavor_get_by_flavor_id(flavorid, ctxt=None): return FAKE_FLAVORS['flavor %s' % flavorid] @@ -98,7 +98,7 @@ def empty_get_all_flavors_sorted_list(context=None, inactive=False, return [] -def return_flavor_not_found(flavor_id): +def return_flavor_not_found(flavor_id, ctxt=None): raise exception.FlavorNotFound(flavor_id=flavor_id)

AltStyle によって変換されたページ (->オリジナル) /