Merge "Fix Instance objects with empty security groups"
This commit is contained in:
commit
c4e7df7a98
@ -246,7 +246,7 @@ class Instance(base.NovaObject):
|
||||
instance_info_cache.InstanceInfoCache._from_db_object(
|
||||
context, instance['info_cache'], db_inst['info_cache'])
|
||||
if ('security_groups' in expected_attrs and
|
||||
db_inst.get('security_groups')):
|
||||
db_inst.get('security_groups') is not None):
|
||||
instance['security_groups'] = security_group.SecurityGroupList()
|
||||
security_group._make_secgroup_list(context,
|
||||
instance['security_groups'],
|
||||
|
@ -375,6 +375,17 @@ class _TestInstanceObject(object):
|
||||
inst.save()
|
||||
self.assertEqual(inst.security_groups.obj_what_changed(), set())
|
||||
|
||||
def test_with_empty_security_groups(self):
|
||||
ctxt = context.get_admin_context()
|
||||
fake_inst = dict(self.fake_instance, security_groups=[])
|
||||
fake_uuid = fake_inst['uuid']
|
||||
self.mox.StubOutWithMock(db, 'instance_get_by_uuid')
|
||||
db.instance_get_by_uuid(ctxt, fake_uuid, columns_to_join=[]
|
||||
).AndReturn(fake_inst)
|
||||
self.mox.ReplayAll()
|
||||
inst = instance.Instance.get_by_uuid(ctxt, fake_uuid)
|
||||
self.assertEqual(0, len(inst.security_groups))
|
||||
|
||||
def test_with_fault(self):
|
||||
ctxt = context.get_admin_context()
|
||||
fake_inst = dict(self.fake_instance)
|
||||
|
Loading…
Reference in New Issue
Block a user