From 9b463939030f922826c1fc947dc795c3c06c356f Mon Sep 17 00:00:00 2001 From: Roey Chen Date: Sun, 7 Jun 2015 05:18:16 -0700 Subject: [PATCH] Removing port dhcp binding when detaching interface Change-Id: Ie6d41ad0dd3a26b22ecb28cbb324f47a9eafed6b --- vmware_nsx/neutron/plugins/vmware/plugins/nsx_v.py | 3 ++- vmware_nsx/neutron/tests/unit/vmware/test_nsx_v_plugin.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/neutron/plugins/vmware/plugins/nsx_v.py b/vmware_nsx/neutron/plugins/vmware/plugins/nsx_v.py index 835af3b7a8..6d4899a910 100644 --- a/vmware_nsx/neutron/plugins/vmware/plugins/nsx_v.py +++ b/vmware_nsx/neutron/plugins/vmware/plugins/nsx_v.py @@ -908,7 +908,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin, vnic_id = self._get_port_vnic_id(vnic_idx, device_id) curr_sgids = original_port.get(ext_sg.SECURITYGROUPS) if ret_port['device_id'] != device_id: - # Update change device_id - remove port-vnic assosiation and + # Update change device_id - remove port-vnic association and # delete security-groups memberships for the vnic self._delete_security_groups_port_mapping( context.session, vnic_id, curr_sgids) @@ -916,6 +916,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin, self._remove_vnic_from_spoofguard_policy( context.session, original_port['network_id'], vnic_id) self._delete_port_vnic_index_mapping(context, id) + self._delete_dhcp_static_binding(context, original_port) else: # Update vnic with the newest approved IP addresses if has_port_security and updates_fixed_ips: diff --git a/vmware_nsx/neutron/tests/unit/vmware/test_nsx_v_plugin.py b/vmware_nsx/neutron/tests/unit/vmware/test_nsx_v_plugin.py index 8f4f143209..8de20adb49 100644 --- a/vmware_nsx/neutron/tests/unit/vmware/test_nsx_v_plugin.py +++ b/vmware_nsx/neutron/tests/unit/vmware/test_nsx_v_plugin.py @@ -439,7 +439,8 @@ class TestPortsV2(NsxVPluginV2TestCase, res = self.deserialize('json', req.get_response(self.api)) return res - def test_update_port_index(self): + @mock.patch.object(edge_utils, 'delete_dhcp_binding') + def test_update_port_index(self, delete_dhcp_binding): q_context = context.Context('', 'tenant_1') device_id = _uuid() with self.subnet() as subnet: @@ -468,6 +469,7 @@ class TestPortsV2(NsxVPluginV2TestCase, vnic_id = '%s.%03d' % (device_id, vnic_index) (self.fc2.inactivate_vnic_assigned_addresses. assert_called_once_with(policy_id, vnic_id)) + self.assertTrue(delete_dhcp_binding.called) def test_update_port_with_compute_device_owner(self): """