remove the unnecessary parem of set_vm_state_and_notify

Change eaaa659333 has refactor
set_vm_state_and_notify. It uses instance object, does not operate
the instance db directly any more.

Change-Id: Ifec95656c5ffcd64488655ea6c1442a949cdb9d4
This commit is contained in:
ShaoHe Feng 2016-02-03 15:12:14 +08:00
parent 5e52d3bec0
commit 66d014731c
4 changed files with 10 additions and 18 deletions

View File

@ -250,7 +250,7 @@ class ComputeTaskManager(base.Base):
ex, request_spec):
scheduler_utils.set_vm_state_and_notify(
context, instance_uuid, 'compute_task', method, updates,
ex, request_spec, self.db)
ex, request_spec)
def _cleanup_allocated_networks(
self, context, instance, requested_networks):
@ -272,7 +272,7 @@ class ComputeTaskManager(base.Base):
dict(vm_state=vm_state,
task_state=task_state,
expected_task_state=task_states.MIGRATING,),
ex, request_spec, self.db)
ex, request_spec)
migration = objects.Migration(context=context.elevated())
migration.dest_compute = destination

View File

@ -85,7 +85,7 @@ def build_request_spec(ctxt, image, instances, instance_type=None):
def set_vm_state_and_notify(context, instance_uuid, service, method, updates,
ex, request_spec, db):
ex, request_spec):
"""changes VM state and notifies."""
LOG.warning(_LW("Failed to %(service)s_%(method)s: %(ex)s"),
{'service': service, 'method': method, 'ex': ex})

View File

@ -66,7 +66,6 @@ class FakeContext(context.RequestContext):
class _BaseTestCase(object):
def setUp(self):
super(_BaseTestCase, self).setUp()
self.db = None
self.user_id = 'fake'
self.project_id = 'fake'
self.context = FakeContext(self.user_id, self.project_id)
@ -215,7 +214,6 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
'conductor', manager='nova.conductor.manager.ConductorManager')
self.conductor = conductor_api.API()
self.conductor_manager = self.conductor_service.manager
self.db = None
def test_wait_until_ready(self):
timeouts = []
@ -255,7 +253,6 @@ class ConductorLocalAPITestCase(ConductorAPITestCase):
super(ConductorLocalAPITestCase, self).setUp()
self.conductor = conductor_api.LocalAPI()
self.conductor_manager = self.conductor._manager._target
self.db = db
def test_wait_until_ready(self):
# Override test in ConductorAPITestCase
@ -529,7 +526,7 @@ class _BaseTaskTestCase(object):
for instance in instances:
set_state_calls.append(mock.call(
self.context, instance.uuid, 'compute_task', 'build_instances',
updates, exception, spec, self.conductor_manager.db))
updates, exception, spec))
cleanup_network_calls.append(mock.call(
self.context, mock.ANY, None))
state_mock.assert_has_calls(set_state_calls)
@ -570,8 +567,7 @@ class _BaseTaskTestCase(object):
filter_properties, instances[0].uuid)
set_vm_state_and_notify.assert_called_once_with(
self.context, instances[0].uuid, 'compute_task',
'build_instances', updates, mock.ANY, {},
self.conductor_manager.db)
'build_instances', updates, mock.ANY, {})
cleanup_mock.assert_called_once_with(self.context, mock.ANY, None)
_test()
@ -1012,8 +1008,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
{'vm_state': vm_states.ACTIVE,
'task_state': None,
'expected_task_state': task_states.MIGRATING},
ex, self._build_request_spec(inst_obj),
self.conductor_manager.db)
ex, self._build_request_spec(inst_obj))
def test_migrate_server_deals_with_invalidcpuinfo_exception(self):
instance = fake_instance.fake_db_instance(uuid='uuid',
@ -1037,8 +1032,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
{'vm_state': vm_states.ACTIVE,
'task_state': None,
'expected_task_state': task_states.MIGRATING},
ex, self._build_request_spec(inst_obj),
self.conductor_manager.db)
ex, self._build_request_spec(inst_obj))
self.mox.ReplayAll()
self.conductor = utils.ExceptionHelper(self.conductor)
@ -1087,7 +1081,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
dict(vm_state=vm_states.ERROR,
task_state=inst_obj.task_state,
expected_task_state=task_states.MIGRATING,),
expected_ex, request_spec, self.conductor.db)
expected_ex, request_spec)
self.assertEqual(ex.kwargs['reason'], six.text_type(expected_ex))
def test_set_vm_state_and_notify(self):
@ -1095,7 +1089,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
'set_vm_state_and_notify')
scheduler_utils.set_vm_state_and_notify(
self.context, 1, 'compute_task', 'method', 'updates',
'ex', 'request_spec', self.conductor.db)
'ex', 'request_spec')
self.mox.ReplayAll()

View File

@ -24,7 +24,6 @@ import six
from nova.compute import flavors
from nova.compute import utils as compute_utils
from nova import db
from nova import exception
from nova import objects
from nova import rpc
@ -96,8 +95,7 @@ class SchedulerUtilsTestCase(test.NoDBTestCase):
method,
updates,
exc_info,
request_spec,
db)
request_spec)
mock_save.assert_called_once_with()
mock_add.assert_called_once_with(self.context, mock.ANY,
exc_info, mock.ANY)