Remove instance_info_cache_update() from conductor

After network api was converted to use InfoCache object it no longer
depends on the conductor instance_info_cache_update() method.

This change removes this method from conductor and in addition removes
conductor parameter in calls to network api from within compute manager,
previously needed by the @refrech_cache() decorator in network api for
its calls to this same conductor method.

Change-Id: I5bb535062b5f5948e2b6ba1daa089f3d93471394
This commit is contained in:
Hans Lindgren
2013-10-12 18:22:43 +02:00
parent a9a23591d3
commit 198720f441
9 changed files with 31 additions and 59 deletions

View File

@@ -1225,7 +1225,6 @@ class ComputeManager(manager.SchedulerDependentManager):
context, instance, vpn=is_vpn,
requested_networks=requested_networks,
macs=macs,
conductor_api=self.conductor_api,
security_groups=security_groups,
dhcp_options=dhcp_options)
LOG.debug(_('Instance network_info: |%s|'), nwinfo,
@@ -3168,7 +3167,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context, instance, "create_ip.start")
self.network_api.add_fixed_ip_to_instance(context, instance,
network_id, conductor_api=self.conductor_api)
network_id)
inst_obj = instance_obj.Instance._from_db_object(
context, instance_obj.Instance(), instance)
@@ -3194,7 +3193,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context, instance, "delete_ip.start")
self.network_api.remove_fixed_ip_from_instance(context, instance,
address, conductor_api=self.conductor_api)
address)
inst_obj = instance_obj.Instance._from_db_object(
context, instance_obj.Instance(), instance)
@@ -3867,8 +3866,7 @@ class ComputeManager(manager.SchedulerDependentManager):
requested_ip=None):
"""Use hotplug to add an network adapter to an instance."""
network_info = self.network_api.allocate_port_for_instance(
context, instance, port_id, network_id, requested_ip,
conductor_api=self.conductor_api)
context, instance, port_id, network_id, requested_ip)
if len(network_info) != 1:
LOG.error(_('allocate_port_for_instance returned %(ports)s ports')
% dict(ports=len(network_info)))
@@ -3897,7 +3895,7 @@ class ComputeManager(manager.SchedulerDependentManager):
"attached") % port_id)
self.network_api.deallocate_port_for_instance(context, instance,
port_id, conductor_api=self.conductor_api)
port_id)
self.driver.detach_interface(instance, condemned)
def _get_compute_info(self, context, host):

View File

@@ -98,11 +98,6 @@ class LocalAPI(object):
return self._manager.instance_get_active_by_window_joined(
context, begin, end, project_id, host)
def instance_info_cache_update(self, context, instance, values):
return self._manager.instance_info_cache_update(context,
instance,
values)
def instance_info_cache_delete(self, context, instance):
return self._manager.instance_info_cache_delete(context, instance)

View File

@@ -368,6 +368,8 @@ class ConductorManager(manager.Manager):
def instance_info_cache_delete(self, context, instance):
self.db.instance_info_cache_delete(context, instance['uuid'])
# NOTE(hanlind): This method is now deprecated and can be removed in
# version v2.0 of the RPC API.
def instance_info_cache_update(self, context, instance, values):
self.db.instance_info_cache_update(context, instance['uuid'],
values)

View File

@@ -110,6 +110,7 @@ class ConductorAPI(rpcclient.RpcProxy):
migration_get_unconfirmed_by_dest_compute
1.57 - Remove migration_create()
1.58 - Remove migration_get()
1.59 - Remove instance_info_cache_update()
"""
BASE_RPC_API_VERSION = '1.0'
@@ -360,12 +361,6 @@ class ConductorAPI(rpcclient.RpcProxy):
cctxt = self.client.prepare(version='1.25')
return cctxt.call(context, 'action_event_finish', values=values_p)
def instance_info_cache_update(self, context, instance, values):
instance_p = jsonutils.to_primitive(instance)
cctxt = self.client.prepare(version='1.26')
return cctxt.call(context, 'instance_info_cache_update',
instance=instance_p, values=values)
def service_create(self, context, values):
cctxt = self.client.prepare(version='1.27')
return cctxt.call(context, 'service_create', values=values)

View File

@@ -261,7 +261,7 @@ class API(base.Base):
@refresh_cache
def allocate_for_instance(self, context, instance, vpn,
requested_networks, macs=None,
conductor_api=None, security_groups=None,
security_groups=None,
dhcp_options=None):
"""Allocates all network structures for an instance.
@@ -273,7 +273,6 @@ class API(base.Base):
:param macs: None or a set of MAC addresses that the instance
should use. macs is supplied by the hypervisor driver (contrast
with requested_networks which is user supplied).
:param conductor_api: The conductor api.
:param security_groups: None or security groups to allocate for
instance.
:param dhcp_options: None or a set of key/value pairs that should
@@ -318,13 +317,11 @@ class API(base.Base):
# NOTE(danms): Here for neutron compatibility
def allocate_port_for_instance(self, context, instance, port_id,
network_id=None, requested_ip=None,
conductor_api=None):
network_id=None, requested_ip=None):
raise NotImplementedError()
# NOTE(danms): Here for neutron compatibility
def deallocate_port_for_instance(self, context, instance, port_id,
conductor_api=None):
def deallocate_port_for_instance(self, context, instance, port_id):
raise NotImplementedError()
# NOTE(danms): Here for neutron compatibility
@@ -337,8 +334,7 @@ class API(base.Base):
@wrap_check_policy
@refresh_cache
def add_fixed_ip_to_instance(self, context, instance, network_id,
conductor_api=None):
def add_fixed_ip_to_instance(self, context, instance, network_id):
"""Adds a fixed ip to instance from specified network."""
instance_type = flavors.extract_flavor(instance)
args = {'instance_id': instance['uuid'],
@@ -349,8 +345,7 @@ class API(base.Base):
@wrap_check_policy
@refresh_cache
def remove_fixed_ip_from_instance(self, context, instance, address,
conductor_api=None):
def remove_fixed_ip_from_instance(self, context, instance, address):
"""Removes a fixed ip from instance from specified network."""
instance_type = flavors.extract_flavor(instance)

View File

@@ -418,16 +418,13 @@ class API(base.Base):
@refresh_cache
def allocate_port_for_instance(self, context, instance, port_id,
network_id=None, requested_ip=None,
conductor_api=None):
network_id=None, requested_ip=None):
"""Allocate a port for the instance."""
return self.allocate_for_instance(context, instance,
requested_networks=[(network_id, requested_ip, port_id)],
conductor_api=conductor_api)
requested_networks=[(network_id, requested_ip, port_id)])
@refresh_cache
def deallocate_port_for_instance(self, context, instance, port_id,
conductor_api=None):
def deallocate_port_for_instance(self, context, instance, port_id):
"""Remove a specified port from the instance.
Return network information for the instance
@@ -464,8 +461,7 @@ class API(base.Base):
return network_model.NetworkInfo.hydrate(nw_info)
@refresh_cache
def add_fixed_ip_to_instance(self, context, instance, network_id,
conductor_api=None):
def add_fixed_ip_to_instance(self, context, instance, network_id):
"""Add a fixed ip to the instance from specified network."""
search_opts = {'network_id': network_id}
data = neutronv2.get_client(context).list_subnets(**search_opts)
@@ -500,8 +496,7 @@ class API(base.Base):
instance_id=instance['uuid'])
@refresh_cache
def remove_fixed_ip_from_instance(self, context, instance, address,
conductor_api=None):
def remove_fixed_ip_from_instance(self, context, instance, address):
"""Remove a fixed ip from the instance."""
zone = 'compute:%s' % instance['availability_zone']
search_opts = {'device_id': instance['uuid'],

View File

@@ -2958,7 +2958,6 @@ class ComputeTestCase(BaseTestCase):
mox.IgnoreArg(),
requested_networks=None,
vpn=False, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=[], dhcp_options=None).AndReturn(
fake_network.fake_get_instance_nw_info(self.stubs, 1, 1))
@@ -2980,7 +2979,6 @@ class ComputeTestCase(BaseTestCase):
mox.IgnoreArg(),
requested_networks=None,
vpn=False, macs=None,
conductor_api=self.compute.conductor_api,
security_groups=[], dhcp_options=None
).AndRaise(rpc_common.RemoteError())
self.compute.network_api.deallocate_for_instance(
@@ -4955,8 +4953,6 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.network_api,
'get_instance_nw_info')
self.mox.StubOutWithMock(self.compute.conductor_api,
'instance_info_cache_update')
self.mox.StubOutWithMock(self.compute.conductor_api,
'instance_get_by_uuid')
@@ -7550,8 +7546,8 @@ class ComputeAPITestCase(BaseTestCase):
port_id = nwinfo[0]['id']
req_ip = '1.2.3.4'
self.compute.network_api.allocate_port_for_instance(
self.context, instance, port_id, network_id, req_ip,
conductor_api=self.compute.conductor_api).AndReturn(nwinfo)
self.context, instance, port_id, network_id, req_ip
).AndReturn(nwinfo)
self.mox.ReplayAll()
vif = self.compute.attach_interface(self.context,
instance,
@@ -7567,7 +7563,7 @@ class ComputeAPITestCase(BaseTestCase):
lambda *a, **k: nwinfo)
self.stubs.Set(self.compute.network_api,
'deallocate_port_for_instance',
lambda a, b, c, conductor_api=None: [])
lambda a, b, c: [])
self.compute.detach_interface(self.context, {}, port_id)
self.assertEqual(self.compute.driver._interfaces, {})

View File

@@ -67,7 +67,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
nwapi.allocate_for_instance(
self.context, instance, vpn=is_vpn,
requested_networks=req_networks, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=sec_groups,
dhcp_options=dhcp_options).AndRaise(
test.TestingException())
@@ -76,7 +75,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
nwapi.allocate_for_instance(
self.context, instance, vpn=is_vpn,
requested_networks=req_networks, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=sec_groups,
dhcp_options=dhcp_options).AndReturn(final_result)
@@ -106,7 +104,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
nwapi.allocate_for_instance(
self.context, instance, vpn=is_vpn,
requested_networks=req_networks, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=sec_groups,
dhcp_options=dhcp_options).AndRaise(test.TestingException())
@@ -134,7 +131,6 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
nwapi.allocate_for_instance(
self.context, instance, vpn=is_vpn,
requested_networks=req_networks, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=sec_groups,
dhcp_options=dhcp_options).AndRaise(test.TestingException())

View File

@@ -315,17 +315,6 @@ class _BaseTestCase(object):
self.conductor.instance_info_cache_delete(self.context,
{'uuid': 'fake-uuid'})
def test_instance_info_cache_update(self):
fake_values = {'key1': 'val1', 'key2': 'val2'}
fake_inst = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_info_cache_update')
db.instance_info_cache_update(self.context, 'fake-uuid',
fake_values)
self.mox.ReplayAll()
self.conductor.instance_info_cache_update(self.context,
fake_inst,
fake_values)
def test_flavor_get(self):
self.mox.StubOutWithMock(db, 'flavor_get')
db.flavor_get(self.context, 'fake-id').AndReturn('fake-type')
@@ -579,6 +568,17 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
self.conductor = conductor_manager.ConductorManager()
self.conductor_manager = self.conductor
def test_instance_info_cache_update(self):
fake_values = {'key1': 'val1', 'key2': 'val2'}
fake_inst = {'uuid': 'fake-uuid'}
self.mox.StubOutWithMock(db, 'instance_info_cache_update')
db.instance_info_cache_update(self.context, 'fake-uuid',
fake_values)
self.mox.ReplayAll()
self.conductor.instance_info_cache_update(self.context,
fake_inst,
fake_values)
def test_migration_get(self):
migration = db.migration_create(self.context.elevated(),
{'instance_uuid': 'fake-uuid',