Removing port dhcp binding when detaching interface

Change-Id: Ie6d41ad0dd3a26b22ecb28cbb324f47a9eafed6b
This commit is contained in:
Roey Chen 2015-06-07 05:18:16 -07:00
parent b41632c936
commit 9b46393903
2 changed files with 5 additions and 2 deletions

View File

@ -908,7 +908,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
vnic_id = self._get_port_vnic_id(vnic_idx, device_id) vnic_id = self._get_port_vnic_id(vnic_idx, device_id)
curr_sgids = original_port.get(ext_sg.SECURITYGROUPS) curr_sgids = original_port.get(ext_sg.SECURITYGROUPS)
if ret_port['device_id'] != device_id: 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 # delete security-groups memberships for the vnic
self._delete_security_groups_port_mapping( self._delete_security_groups_port_mapping(
context.session, vnic_id, curr_sgids) context.session, vnic_id, curr_sgids)
@ -916,6 +916,7 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
self._remove_vnic_from_spoofguard_policy( self._remove_vnic_from_spoofguard_policy(
context.session, original_port['network_id'], vnic_id) context.session, original_port['network_id'], vnic_id)
self._delete_port_vnic_index_mapping(context, id) self._delete_port_vnic_index_mapping(context, id)
self._delete_dhcp_static_binding(context, original_port)
else: else:
# Update vnic with the newest approved IP addresses # Update vnic with the newest approved IP addresses
if has_port_security and updates_fixed_ips: if has_port_security and updates_fixed_ips:

View File

@ -439,7 +439,8 @@ class TestPortsV2(NsxVPluginV2TestCase,
res = self.deserialize('json', req.get_response(self.api)) res = self.deserialize('json', req.get_response(self.api))
return res 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') q_context = context.Context('', 'tenant_1')
device_id = _uuid() device_id = _uuid()
with self.subnet() as subnet: with self.subnet() as subnet:
@ -468,6 +469,7 @@ class TestPortsV2(NsxVPluginV2TestCase,
vnic_id = '%s.%03d' % (device_id, vnic_index) vnic_id = '%s.%03d' % (device_id, vnic_index)
(self.fc2.inactivate_vnic_assigned_addresses. (self.fc2.inactivate_vnic_assigned_addresses.
assert_called_once_with(policy_id, vnic_id)) assert_called_once_with(policy_id, vnic_id))
self.assertTrue(delete_dhcp_binding.called)
def test_update_port_with_compute_device_owner(self): def test_update_port_with_compute_device_owner(self):
""" """