summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/cells/messaging.py4
-rw-r--r--nova/db/sqlalchemy/api.py16
-rw-r--r--nova/db/sqlalchemy/models.py7
-rw-r--r--nova/tests/cells/test_cells_messaging.py1
-rw-r--r--nova/tests/test_db_api.py20
-rw-r--r--nova/tests/test_instance_types.py18
6 files changed, 3 insertions, 63 deletions
diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py
index f83f141dc..82f0a6a48 100644
--- a/nova/cells/messaging.py
+++ b/nova/cells/messaging.py
@@ -749,8 +749,8 @@ class _BroadcastMessageMethods(_BaseMessageMethods):
# 'metadata' is only updated in the API cell, so don't overwrite
# it based on what child cells say. Make sure to update
# 'cell_name' based on the routing path.
- items_to_remove = ['id', 'security_groups', 'instance_type',
- 'volumes', 'cell_name', 'name', 'metadata']
+ items_to_remove = ['id', 'security_groups', 'volumes', 'cell_name',
+ 'name', 'metadata']
for key in items_to_remove:
instance.pop(key, None)
instance['cell_name'] = _reverse_path(message.routing_path)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 0bd9cfce7..f35f23e56 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -1429,9 +1429,6 @@ def instance_create(context, values):
instance_ref.security_groups = _get_sec_group_models(session,
security_groups)
instance_ref.save(session=session)
- # NOTE(comstud): This forces instance_type to be loaded so it
- # exists in the ref when we return. Fixes lazy loading issues.
- instance_ref.instance_type
# create the instance uuid to ec2_id mapping entry for instance
db.ec2_instance_create(context, instance_ref['uuid'])
@@ -1521,7 +1518,6 @@ def _build_instance_get(context, session=None):
options(joinedload_all('security_groups.rules')).\
options(joinedload('info_cache')).\
options(joinedload('metadata')).\
- options(joinedload('instance_type')).\
options(joinedload('system_metadata'))
@@ -1529,7 +1525,7 @@ def _build_instance_get(context, session=None):
def instance_get_all(context, columns_to_join=None):
if columns_to_join is None:
columns_to_join = ['info_cache', 'security_groups', 'metadata',
- 'instance_type', 'system_metadata']
+ 'system_metadata']
query = model_query(context, models.Instance)
for column in columns_to_join:
query = query.options(joinedload(column))
@@ -1559,7 +1555,6 @@ def instance_get_all_by_filters(context, filters, sort_key, sort_dir,
options(joinedload('security_groups')).\
options(joinedload('system_metadata')).\
options(joinedload('metadata')).\
- options(joinedload('instance_type')).\
order_by(sort_fn[sort_dir](getattr(models.Instance, sort_key)))
# Make a copy of the filters dictionary to use going forward, as we'll
@@ -1658,7 +1653,6 @@ def instance_get_active_by_window_joined(context, begin, end=None,
query = query.options(joinedload('info_cache')).\
options(joinedload('security_groups')).\
options(joinedload('metadata')).\
- options(joinedload('instance_type')).\
options(joinedload('system_metadata')).\
filter(or_(models.Instance.terminated_at == None,
models.Instance.terminated_at > begin))
@@ -1678,7 +1672,6 @@ def _instance_get_all_query(context, project_only=False):
options(joinedload('info_cache')).\
options(joinedload('security_groups')).\
options(joinedload('metadata')).\
- options(joinedload('instance_type')).\
options(joinedload('system_metadata'))
@@ -1847,13 +1840,6 @@ def _instance_update(context, instance_uuid, values, copy_old_instance=False):
instance_ref.update(values)
instance_ref.save(session=session)
- if 'instance_type_id' in values:
- # NOTE(comstud): It appears that sqlalchemy doesn't refresh
- # the instance_type model after you update the ID. You end
- # up with an instance_type model that only has 'id' updated,
- # but the rest of the model has the data from the old
- # instance_type.
- session.refresh(instance_ref['instance_type'])
return (old_instance_ref, instance_ref)
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index a675357df..3f45c614b 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -273,13 +273,6 @@ class InstanceTypes(BASE, NovaBase):
disabled = Column(Boolean, default=False)
is_public = Column(Boolean, default=True)
- instances = relationship(Instance,
- backref=backref('instance_type', uselist=False),
- foreign_keys=id,
- primaryjoin='and_('
- 'Instance.instance_type_id == '
- 'InstanceTypes.id)')
-
class Volume(BASE, NovaBase):
"""Represents a block storage device that can be attached to a VM."""
diff --git a/nova/tests/cells/test_cells_messaging.py b/nova/tests/cells/test_cells_messaging.py
index effe27660..3c7dd1941 100644
--- a/nova/tests/cells/test_cells_messaging.py
+++ b/nova/tests/cells/test_cells_messaging.py
@@ -938,7 +938,6 @@ class CellsBroadcastMethodsTestCase(test.TestCase):
fake_instance = {'id': 2,
'uuid': 'fake_uuid',
'security_groups': 'fake',
- 'instance_type': 'fake',
'volumes': 'fake',
'cell_name': 'fake',
'name': 'fake',
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py
index 0a2d81fb1..2b81f66f7 100644
--- a/nova/tests/test_db_api.py
+++ b/nova/tests/test_db_api.py
@@ -327,26 +327,6 @@ class DbApiTestCase(DbTestCase):
system_meta = db.instance_system_metadata_get(ctxt, instance['uuid'])
self.assertEqual('baz', system_meta['original_image_ref'])
- def test_instance_update_of_instance_type_id(self):
- ctxt = context.get_admin_context()
-
- inst_type1 = db.instance_type_get_by_name(ctxt, 'm1.tiny')
- inst_type2 = db.instance_type_get_by_name(ctxt, 'm1.small')
-
- values = {'instance_type_id': inst_type1['id']}
- instance = db.instance_create(ctxt, values)
-
- self.assertEqual(instance['instance_type']['id'], inst_type1['id'])
- self.assertEqual(instance['instance_type']['name'],
- inst_type1['name'])
-
- values = {'instance_type_id': inst_type2['id']}
- instance = db.instance_update(ctxt, instance['uuid'], values)
-
- self.assertEqual(instance['instance_type']['id'], inst_type2['id'])
- self.assertEqual(instance['instance_type']['name'],
- inst_type2['name'])
-
def test_instance_update_unique_name(self):
otherprojectcontext = context.RequestContext(self.user_id,
"%s2" % self.project_id)
diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py
index 7ca867f77..147ab25f7 100644
--- a/nova/tests/test_instance_types.py
+++ b/nova/tests/test_instance_types.py
@@ -365,24 +365,6 @@ class InstanceTypeTestCase(test.TestCase):
"test1", read_deleted="no")
self.assertEqual("instance_type1_redo", instance_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()
- 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 InstanceTypeToolsTest(test.TestCase):
def _dict_to_metadata(self, data):