Permit deleted instance types to be queried for active instances.
Fixes bug 994935. This removes the deleted=0 restriction for joining instance_types to instances. Active instances may be using old/deleted instance_types, so we still need to be able to look up that information for show/detail requests. Change-Id: Ica72801f19c7e5b04966e53ed3ea4c330df44ed1
This commit is contained in:
@@ -152,7 +152,7 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
'name two', 256, 1, 120, 200, flavorid)
|
'name two', 256, 1, 120, 200, flavorid)
|
||||||
|
|
||||||
def test_will_not_destroy_with_no_name(self):
|
def test_will_not_destroy_with_no_name(self):
|
||||||
"""Ensure destroy sad path of no name raises error"""
|
"""Ensure destroy said path of no name raises error"""
|
||||||
self.assertRaises(exception.InstanceTypeNotFoundByName,
|
self.assertRaises(exception.InstanceTypeNotFoundByName,
|
||||||
instance_types.destroy, None)
|
instance_types.destroy, None)
|
||||||
|
|
||||||
@@ -201,6 +201,24 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
fetched = instance_types.get_instance_type_by_flavor_id(flavorid)
|
fetched = instance_types.get_instance_type_by_flavor_id(flavorid)
|
||||||
self.assertEqual(default_instance_type, fetched)
|
self.assertEqual(default_instance_type, fetched)
|
||||||
|
|
||||||
|
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()
|
||||||
|
inst_type = instance_types.create("test", 256, 1, 120, 100, "test1")
|
||||||
|
|
||||||
|
instance_params = {"instance_type_id": inst_type["id"]}
|
||||||
|
instance = db.instance_create(ctxt, instance_params)
|
||||||
|
|
||||||
|
# NOTE(jk0): Delete the instance type and reload the instance from the
|
||||||
|
# DB. The instance_type object will still be available to the active
|
||||||
|
# instance, otherwise being None.
|
||||||
|
instance_types.destroy(inst_type["name"])
|
||||||
|
instance = db.instance_get_by_uuid(ctxt, instance["uuid"])
|
||||||
|
|
||||||
|
self.assertRaises(exception.InstanceTypeNotFound,
|
||||||
|
instance_types.get_instance_type, inst_type["name"])
|
||||||
|
self.assertTrue(instance["instance_type"])
|
||||||
|
|
||||||
|
|
||||||
class InstanceTypeFilteringTest(test.TestCase):
|
class InstanceTypeFilteringTest(test.TestCase):
|
||||||
"""Test cases for the filter option available for instance_type_get_all"""
|
"""Test cases for the filter option available for instance_type_get_all"""
|
||||||
|
Reference in New Issue
Block a user