From 9ad3c6ac9bae578cd589b25ef39741639ab97ba0 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 7 Oct 2015 15:05:40 +0200 Subject: [PATCH] Removed release_port_fixed_ip dead code It's not used since I822cc4a92cb05cdef88679bb628fad4e5063cddd. Closes-Bug: #1212520 Change-Id: I1bb0755fa1379f3dad4241e7ae8d50c4c842d89e --- neutron/agent/dhcp/agent.py | 7 ----- neutron/api/rpc/handlers/dhcp_rpc.py | 30 +++---------------- neutron/tests/unit/agent/dhcp/test_agent.py | 4 --- .../unit/api/rpc/handlers/test_dhcp_rpc.py | 14 --------- 4 files changed, 4 insertions(+), 51 deletions(-) diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index f077d4fe1..dead17f48 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -452,13 +452,6 @@ class DhcpPluginApi(object): network_id=network_id, device_id=device_id, host=self.host) - def release_port_fixed_ip(self, network_id, device_id, subnet_id): - """Make a remote process call to release a fixed_ip on the port.""" - cctxt = self.client.prepare() - return cctxt.call(self.context, 'release_port_fixed_ip', - network_id=network_id, subnet_id=subnet_id, - device_id=device_id, host=self.host) - class NetworkCache(object): """Agent cache of the current network state.""" diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py index 9eb23f8eb..d7388e9e0 100644 --- a/neutron/api/rpc/handlers/dhcp_rpc.py +++ b/neutron/api/rpc/handlers/dhcp_rpc.py @@ -56,9 +56,12 @@ class DhcpRpcCallback(object): # RPC client for many releases, it should be OK to bump the # minor release instead and claim RPC compatibility with the # last few client versions. + # 1.3 - Removed release_port_fixed_ip. It's not used by reference DHCP + # agent since Juno, so similar rationale for not bumping the + # major version as above applies here too. target = oslo_messaging.Target( namespace=constants.RPC_NAMESPACE_DHCP_PLUGIN, - version='1.2') + version='1.3') def _get_active_networks(self, context, **kwargs): """Retrieve and return a list of the active networks.""" @@ -173,31 +176,6 @@ class DhcpRpcCallback(object): plugin = manager.NeutronManager.get_plugin() plugin.delete_ports_by_device_id(context, device_id, network_id) - @db_api.retry_db_errors - def release_port_fixed_ip(self, context, **kwargs): - """Release the fixed_ip associated the subnet on a port.""" - host = kwargs.get('host') - network_id = kwargs.get('network_id') - device_id = kwargs.get('device_id') - subnet_id = kwargs.get('subnet_id') - - LOG.debug('DHCP port remove fixed_ip for %(subnet_id)s request ' - 'from %(host)s', - {'subnet_id': subnet_id, 'host': host}) - plugin = manager.NeutronManager.get_plugin() - filters = dict(network_id=[network_id], device_id=[device_id]) - ports = plugin.get_ports(context, filters=filters) - - if ports: - port = ports[0] - - fixed_ips = port.get('fixed_ips', []) - for i in range(len(fixed_ips)): - if fixed_ips[i]['subnet_id'] == subnet_id: - del fixed_ips[i] - break - plugin.update_port(context, port['id'], dict(port=port)) - def update_lease_expiration(self, context, **kwargs): """Release the fixed_ip associated the subnet on a port.""" # NOTE(arosen): This method is no longer used by the DHCP agent but is diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index 89ff045f5..fb7355f14 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -1031,10 +1031,6 @@ class TestDhcpPluginApiProxy(base.BaseTestCase): self._test_dhcp_api('release_dhcp_port', network_id='fake_id', device_id='fake_id_2') - def test_release_port_fixed_ip(self): - self._test_dhcp_api('release_port_fixed_ip', network_id='fake_id', - device_id='fake_id_2', subnet_id='fake_id_3') - class TestNetworkCache(base.BaseTestCase): def test_put_network(self): diff --git a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py index d57632139..0f42bfc7d 100644 --- a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py +++ b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py @@ -211,17 +211,3 @@ class TestDhcpRpcCallback(base.BaseTestCase): self.plugin.assert_has_calls([ mock.call.delete_ports_by_device_id(mock.ANY, 'devid', 'netid')]) - - def test_release_port_fixed_ip(self): - port_retval = dict(id='port_id', fixed_ips=[dict(subnet_id='a')]) - port_update = dict(id='port_id', fixed_ips=[]) - self.plugin.get_ports.return_value = [port_retval] - - self.callbacks.release_port_fixed_ip(mock.ANY, network_id='netid', - device_id='devid', subnet_id='a') - - self.plugin.assert_has_calls([ - mock.call.get_ports(mock.ANY, filters=dict(network_id=['netid'], - device_id=['devid'])), - mock.call.update_port(mock.ANY, 'port_id', - dict(port=port_update))]) -- 2.45.2