summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2012-05-29 16:42:26 -0500
committerJosh Kearney <josh@jk0.org>2012-05-29 17:12:30 -0500
commit16d26af6ef57a7de86c7acaa8ab2aa4f37be7097 (patch)
tree2dc33e8d44a4459efbdd1754b58a3ed9ec74294e
parentdab262af0d642c48c7d2b92bf8b0520ffc65daaf (diff)
downloadnova-16d26af6ef57a7de86c7acaa8ab2aa4f37be7097.tar.gz
nova-16d26af6ef57a7de86c7acaa8ab2aa4f37be7097.tar.xz
nova-16d26af6ef57a7de86c7acaa8ab2aa4f37be7097.zip
Revert "API users should not see deleted flavors."
This reverts commit f6e62c6120453fa90e2e690753fe6eaf157f2dde. We need to be able to query deleted flavors for instances that may be running on deleted flavors. Change-Id: I9ae80c525c9bc1e3172bd4e7ffe50fe74f2d3a51
-rw-r--r--nova/compute/instance_types.py2
-rw-r--r--nova/tests/test_instance_types.py16
2 files changed, 17 insertions, 1 deletions
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py
index c4a6f66f9..66c73c624 100644
--- a/nova/compute/instance_types.py
+++ b/nova/compute/instance_types.py
@@ -144,5 +144,5 @@ def get_instance_type_by_flavor_id(flavorid):
:raises: FlavorNotFound
"""
- ctxt = context.get_admin_context()
+ ctxt = context.get_admin_context(read_deleted="yes")
return db.instance_type_get_by_flavor_id(ctxt, flavorid)
diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py
index 0baeee770..ab4af3bc1 100644
--- a/nova/tests/test_instance_types.py
+++ b/nova/tests/test_instance_types.py
@@ -201,6 +201,22 @@ class InstanceTypeTestCase(test.TestCase):
fetched = instance_types.get_instance_type_by_flavor_id(flavorid)
self.assertEqual(default_instance_type, fetched)
+ def test_can_read_deleted_types_using_flavor_id(self):
+ """Ensure deleted instance types can be read when querying flavor_id"""
+ inst_type_name = "test"
+ inst_type_flavor_id = "test1"
+
+ inst_type = instance_types.create(inst_type_name, 256, 1, 120, 100,
+ inst_type_flavor_id)
+ self.assertEqual(inst_type_name, inst_type["name"])
+
+ # NOTE(jk0): The deleted flavor will show up here because the context
+ # in get_instance_type_by_flavor_id() is set to use read_deleted.
+ instance_types.destroy(inst_type["name"])
+ deleted_inst_type = instance_types.get_instance_type_by_flavor_id(
+ inst_type_flavor_id)
+ self.assertEqual(inst_type_name, deleted_inst_type["name"])
+
def test_will_list_deleted_type_for_active_instance(self):
"""Ensure deleted instance types with active instances can be read"""
ctxt = context.get_admin_context()