Merge "Fixed instance deletion issue from Nova API."
This commit is contained in:
commit
066b3930cf
@ -957,7 +957,6 @@ class API(base.Base):
|
||||
elevated = context.elevated()
|
||||
self.network_api.deallocate_for_instance(elevated,
|
||||
instance)
|
||||
self.db.instance_destroy(context, instance_uuid)
|
||||
system_meta = self.db.instance_system_metadata_get(context,
|
||||
instance_uuid)
|
||||
|
||||
@ -982,6 +981,7 @@ class API(base.Base):
|
||||
vm_state=vm_states.DELETED,
|
||||
task_state=None,
|
||||
terminated_at=timeutils.utcnow())
|
||||
self.db.instance_destroy(context, instance_uuid)
|
||||
compute_utils.notify_about_instance_usage(
|
||||
context, instance, "delete.end", system_metadata=system_meta)
|
||||
|
||||
|
@ -3181,7 +3181,7 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
|
||||
def dummy(*args, **kwargs):
|
||||
self.network_api_called = True
|
||||
pass
|
||||
|
||||
self.stubs.Set(self.compute_api.network_api, 'deallocate_for_instance',
|
||||
dummy)
|
||||
|
||||
@ -3197,10 +3197,13 @@ class ComputeAPITestCase(BaseTestCase):
|
||||
self.assertEqual(instance['task_state'], None)
|
||||
self.assertTrue(self.network_api_called)
|
||||
|
||||
#local delete, so db should be clean
|
||||
self.assertRaises(exception.InstanceNotFound, db.instance_destroy,
|
||||
self.context,
|
||||
instance['uuid'])
|
||||
# fetch the instance state from db and verify deletion.
|
||||
deleted_context = context.RequestContext('fake', 'fake',
|
||||
read_deleted='yes')
|
||||
instance = db.instance_get_by_uuid(deleted_context, instance_uuid)
|
||||
self.assertEqual(instance['vm_state'], vm_states.DELETED)
|
||||
self.assertEqual(instance['task_state'], None)
|
||||
self.assertTrue(instance['deleted'])
|
||||
|
||||
def test_repeated_delete_quota(self):
|
||||
in_use = {'instances': 1}
|
||||
|
Loading…
Reference in New Issue
Block a user