Report instance-actions for live migration force complete API

There isn't instance-action reported by new live migration force
complete API. This is async API, so there isn't a way for user
to know if there is error happened in this API. This patch add
instance-actions report to it

Change-Id: I29dc8ce0aa576ef55d2a4dfbaa6bd1f2bfd90371
Closes-Bug: #1553050
This commit is contained in:
He Jie Xu 2016-03-07 14:35:08 +08:00 committed by Alex Xu
parent 3781ef8e0c
commit b9fbbc9df0
5 changed files with 14 additions and 2 deletions

View File

@ -3383,6 +3383,9 @@ class API(base.Base):
state=migration.status,
method='force complete')
self._record_action_start(
context, instance, instance_actions.LIVE_MIGRATION_FORCE_COMPLETE)
self.compute_rpcapi.live_migration_force_complete(
context, instance, migration.id)

View File

@ -50,4 +50,5 @@ SHELVE = 'shelve'
UNSHELVE = 'unshelve'
LIVE_MIGRATION = 'live-migration'
LIVE_MIGRATION_CANCEL = 'live_migration_cancel'
LIVE_MIGRATION_FORCE_COMPLETE = 'live_migration_force_complete'
TRIGGER_CRASH_DUMP = 'trigger_crash_dump'

View File

@ -5260,6 +5260,7 @@ class ComputeManager(manager.Manager):
migrate_data)
@wrap_exception()
@wrap_instance_event
@wrap_instance_fault
def live_migration_force_complete(self, context, instance, migration_id):
"""Force live migration to complete.

View File

@ -3353,8 +3353,9 @@ class _ComputeAPIUnitTestMixIn(object):
host_statuses[instance.uuid])
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
@mock.patch.object(objects.InstanceAction, 'action_start')
def test_live_migrate_force_complete_succeeded(
self, get_by_id_and_instance):
self, action_start, get_by_id_and_instance):
if self.cell_type == 'api':
# cell api has not been implemented.
@ -3377,6 +3378,9 @@ class _ComputeAPIUnitTestMixIn(object):
lm_force_complete.assert_called_once_with(self.context,
instance,
0)
action_start.assert_called_once_with(
self.context, instance.uuid, 'live_migration_force_complete',
want_result=False)
@mock.patch.object(objects.Migration, 'get_by_id_and_instance')
def test_live_migrate_force_complete_invalid_migration_state(

View File

@ -4370,12 +4370,14 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
migration.status = 'running'
migration.id = 0
@mock.patch.object(compute_utils.EventReporter, '__enter__')
@mock.patch.object(self.compute, '_notify_about_instance_usage')
@mock.patch.object(objects.Migration, 'get_by_id',
return_value=migration)
@mock.patch.object(self.compute.driver,
'live_migration_force_complete')
def _do_test(force_complete, get_by_id, _notify_about_instance_usage):
def _do_test(force_complete, get_by_id, _notify_about_instance_usage,
enter_event_reporter):
self.compute.live_migration_force_complete(
self.context, instance, migration.id)
@ -4389,6 +4391,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
]
_notify_about_instance_usage.assert_has_calls(_notify_usage_calls)
enter_event_reporter.assert_called_once_with()
_do_test()