Skip to content

Commit

Permalink
Cisco N1kv: Remove vmnetwork delete REST call on last port delete
Browse files Browse the repository at this point in the history
Remove the check for last port delete and subseqeuent call to delete
the vm network. This check was moved to VSM to prevent a race
condition and ensure that the vm network is deleted from the
database when the port count becomes 0.

Change-Id: I6c08a099adfce2fdba8eefec6aadeb68a780ac37
Closes-Bug: 1373547
(cherry picked from commit 4e1c4cb)
  • Loading branch information
abhiraut authored and sdhillman committed Oct 15, 2014
1 parent 7f13cbc commit 553fbce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 0 additions & 2 deletions neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,6 @@ def _send_delete_port_request(self, context, port, vm_network):
LOG.debug(_('_send_delete_port_request: %s'), port['id'])
n1kvclient = n1kv_client.Client()
n1kvclient.delete_n1kv_port(vm_network['name'], port['id'])
if vm_network['port_count'] == 0:
n1kvclient.delete_vm_network(vm_network['name'])

def _get_segmentation_id(self, context, id):
"""
Expand Down
18 changes: 18 additions & 0 deletions neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,24 @@ def test_create_next_port_rollback_vmnetwork_count(self):
# for network object clean up to succeed.
client_patch.stop()

def test_delete_last_port_vmnetwork_cleanup(self):
"""Test whether VMNetwork is cleaned up from db on last port delete."""
db_session = db.get_session()
with self.port(no_delete=True) as port:
pt = port['port']
self.assertIsNotNone(n1kv_db_v2.
get_vm_network(db_session,
pt['n1kv:profile_id'],
pt['network_id']))
req = self.new_delete_request('ports', port['port']['id'])
req.get_response(self.api)
# Verify VMNetwork is cleaned up from the database on port delete.
self.assertRaises(c_exc.VMNetworkNotFound,
n1kv_db_v2.get_vm_network,
db_session,
pt['n1kv:profile_id'],
pt['network_id'])


class TestN1kvPolicyProfiles(N1kvPluginTestCase):
def test_populate_policy_profile(self):
Expand Down

0 comments on commit 553fbce

Please sign in to comment.