Remove/deprecate conductor instance_update()

Calls that used to proxy through conductor method instance_update()
has been converted to objects, so remove from conductor.

Change-Id: I169998c0171480c366d7cb5b66f3c5a828b4180d
This commit is contained in:
Hans Lindgren 2015-06-07 21:01:56 +02:00
parent 2c18f78e4f
commit f66758509d
4 changed files with 30 additions and 60 deletions

View File

@ -61,11 +61,6 @@ class LocalAPI(object):
# nothing to wait for in the local case.
pass
def instance_update(self, context, instance_uuid, **updates):
"""Perform an instance update in the database."""
return self._manager.instance_update(context, instance_uuid,
updates, 'compute')
def provider_fw_rule_get_all(self, context):
return self._manager.provider_fw_rule_get_all(context)
@ -184,11 +179,6 @@ class API(LocalAPI):
'Reattempting establishment of '
'nova-conductor connection...'))
def instance_update(self, context, instance_uuid, **updates):
"""Perform an instance update in the database."""
return self._manager.instance_update(context, instance_uuid,
updates, 'conductor')
class ComputeTaskAPI(object):
"""ComputeTask API that queues up compute tasks for nova-conductor."""

View File

@ -111,6 +111,7 @@ class ConductorManager(manager.Manager):
self._compute_api = compute_api.API()
return self._compute_api
# NOTE(hanlind): This can be removed in version 3.0 of the RPC API
@messaging.expected_exceptions(KeyError, ValueError,
exception.InvalidUUID,
exception.InstanceNotFound,

View File

@ -182,6 +182,7 @@ class ConductorAPI(object):
* Remove task_log_end_task()
* Remove security_groups_trigger_members_refresh()
* Remove vol_usage_update()
* Remove instance_update()
"""
@ -203,15 +204,6 @@ class ConductorAPI(object):
version_cap=version_cap,
serializer=serializer)
def instance_update(self, context, instance_uuid, updates,
service=None):
updates_p = jsonutils.to_primitive(updates)
cctxt = self.client.prepare()
return cctxt.call(context, 'instance_update',
instance_uuid=instance_uuid,
updates=updates_p,
service=service)
def provider_fw_rule_get_all(self, context):
cctxt = self.client.prepare()
return cctxt.call(context, 'provider_fw_rule_get_all')

View File

@ -94,6 +94,31 @@ class _BaseTestCase(object):
fake_utils.stub_out_utils_spawn_n(self.stubs)
def test_provider_fw_rule_get_all(self):
fake_rules = ['a', 'b', 'c']
self.mox.StubOutWithMock(db, 'provider_fw_rule_get_all')
db.provider_fw_rule_get_all(self.context).AndReturn(fake_rules)
self.mox.ReplayAll()
result = self.conductor.provider_fw_rule_get_all(self.context)
self.assertEqual(result, fake_rules)
def test_compute_node_create(self):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(self.context, 'fake-values').AndReturn(
'fake-result')
self.mox.ReplayAll()
result = self.conductor.compute_node_create(self.context,
'fake-values')
self.assertEqual(result, 'fake-result')
class ConductorTestCase(_BaseTestCase, test.TestCase):
"""Conductor Manager Tests."""
def setUp(self):
super(ConductorTestCase, self).setUp()
self.conductor = conductor_manager.ConductorManager()
self.conductor_manager = self.conductor
def _create_fake_instance(self, params=None, type_name='m1.tiny'):
if not params:
params = {}
@ -137,31 +162,6 @@ class _BaseTestCase(object):
self.assertRaises(KeyError,
self._do_update, 'any-uuid', foobar=1)
def test_provider_fw_rule_get_all(self):
fake_rules = ['a', 'b', 'c']
self.mox.StubOutWithMock(db, 'provider_fw_rule_get_all')
db.provider_fw_rule_get_all(self.context).AndReturn(fake_rules)
self.mox.ReplayAll()
result = self.conductor.provider_fw_rule_get_all(self.context)
self.assertEqual(result, fake_rules)
def test_compute_node_create(self):
self.mox.StubOutWithMock(db, 'compute_node_create')
db.compute_node_create(self.context, 'fake-values').AndReturn(
'fake-result')
self.mox.ReplayAll()
result = self.conductor.compute_node_create(self.context,
'fake-values')
self.assertEqual(result, 'fake-result')
class ConductorTestCase(_BaseTestCase, test.TestCase):
"""Conductor Manager Tests."""
def setUp(self):
super(ConductorTestCase, self).setUp()
self.conductor = conductor_manager.ConductorManager()
self.conductor_manager = self.conductor
def test_instance_get_by_uuid(self):
orig_instance = self._create_fake_instance()
copy_instance = self.conductor.instance_get_by_uuid(
@ -800,12 +800,6 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
self.conductor_manager = self.conductor_service.manager
self.db = None
def _do_update(self, instance_uuid, **updates):
# NOTE(danms): the public API takes actual keyword arguments,
# so override the base class here to make the call correctly
return self.conductor.instance_update(self.context, instance_uuid,
**updates)
def test_wait_until_ready(self):
timeouts = []
calls = dict(count=0)
@ -832,14 +826,6 @@ class ConductorLocalAPITestCase(ConductorAPITestCase):
self.conductor_manager = self.conductor._manager._target
self.db = db
def test_client_exceptions(self):
instance = self._create_fake_instance()
# NOTE(danms): The LocalAPI should not raise exceptions wrapped
# in ClientException. KeyError should be raised if an invalid
# update key is passed, so use that to validate.
self.assertRaises(KeyError,
self._do_update, instance['uuid'], foo='bar')
def test_wait_until_ready(self):
# Override test in ConductorAPITestCase
pass
@ -869,7 +855,7 @@ class ConductorImportTest(test.TestCase):
class ConductorPolicyTest(test.TestCase):
def test_all_allowed_keys(self):
ctxt = context.RequestContext('fake-user', 'fake-project')
conductor = conductor_api.LocalAPI()
conductor = conductor_manager.ConductorManager()
updates = {}
for key in conductor_manager.allowed_updates:
if key in conductor_manager.datetime_fields:
@ -893,7 +879,8 @@ class ConductorPolicyTest(test.TestCase):
with mock.patch.object(objects.Instance, 'save',
side_effect=fake_save,
autospec=True) as mock_save:
conductor.instance_update(ctxt, 'fake-instance', **updates)
conductor.instance_update(ctxt, 'fake-instance', updates,
'conductor')
mock_save.assert_called_once_with(mock.ANY)
def test_allowed_keys_are_real(self):