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."""
# 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."""
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
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):
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))])