Merge "Stop passing 'delete_type' to 'terminate_instance'"
This commit is contained in:
commit
89e32e2b85
|
@ -2258,19 +2258,7 @@ class API(base.Base):
|
|||
instance.terminated_at = timeutils.utcnow()
|
||||
instance.save()
|
||||
else:
|
||||
self.compute_rpcapi.terminate_instance(context, instance, bdms,
|
||||
delete_type='delete')
|
||||
self._update_queued_for_deletion(context, instance, True)
|
||||
|
||||
def _do_force_delete(self, context, instance, bdms, local=False):
|
||||
if local:
|
||||
instance.vm_state = vm_states.DELETED
|
||||
instance.task_state = None
|
||||
instance.terminated_at = timeutils.utcnow()
|
||||
instance.save()
|
||||
else:
|
||||
self.compute_rpcapi.terminate_instance(context, instance, bdms,
|
||||
delete_type='force_delete')
|
||||
self.compute_rpcapi.terminate_instance(context, instance, bdms)
|
||||
self._update_queued_for_deletion(context, instance, True)
|
||||
|
||||
def _do_soft_delete(self, context, instance, bdms, local=False):
|
||||
|
@ -2341,7 +2329,7 @@ class API(base.Base):
|
|||
must_have_launched=False)
|
||||
def force_delete(self, context, instance):
|
||||
"""Force delete an instance in any vm_state/task_state."""
|
||||
self._delete(context, instance, 'force_delete', self._do_force_delete,
|
||||
self._delete(context, instance, 'force_delete', self._do_delete,
|
||||
task_state=task_states.DELETING)
|
||||
|
||||
def force_stop(self, context, instance, do_cast=True, clean_shutdown=True):
|
||||
|
|
|
@ -987,16 +987,12 @@ class ComputeAPI(object):
|
|||
server=_compute_host(None, instance), version=version)
|
||||
cctxt.cast(ctxt, 'suspend_instance', instance=instance)
|
||||
|
||||
def terminate_instance(self, ctxt, instance, bdms, delete_type=None):
|
||||
# NOTE(rajesht): The `delete_type` parameter is passed because
|
||||
# the method signature has to match with `terminate_instance()`
|
||||
# method of cells rpcapi.
|
||||
def terminate_instance(self, ctxt, instance, bdms):
|
||||
client = self.router.client(ctxt)
|
||||
version = '5.0'
|
||||
cctxt = client.prepare(
|
||||
server=_compute_host(None, instance), version=version)
|
||||
cctxt.cast(ctxt, 'terminate_instance',
|
||||
instance=instance, bdms=bdms)
|
||||
cctxt.cast(ctxt, 'terminate_instance', instance=instance, bdms=bdms)
|
||||
|
||||
def unpause_instance(self, ctxt, instance):
|
||||
version = '5.0'
|
||||
|
|
|
@ -1173,7 +1173,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
mock_soft_delete.assert_called_once_with(self.context, inst)
|
||||
elif delete_type in ['delete', 'force_delete']:
|
||||
mock_terminate.assert_called_once_with(
|
||||
self.context, inst, [], delete_type=delete_type)
|
||||
self.context, inst, [])
|
||||
|
||||
if CONF.workarounds.enable_consoleauth:
|
||||
mock_del_token.assert_called_once_with(self.context, instance_uuid)
|
||||
|
@ -1319,8 +1319,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
mock_service_up.assert_called_once_with(
|
||||
mock_service_get.return_value)
|
||||
mock_terminate.assert_called_once_with(
|
||||
self.context, inst, mock_bdm_get.return_value,
|
||||
delete_type='delete')
|
||||
self.context, inst, mock_bdm_get.return_value)
|
||||
mock_local_delete.assert_not_called()
|
||||
|
||||
def test_delete_forced_when_task_state_is_not_none(self):
|
||||
|
|
Loading…
Reference in New Issue