From 0dcb113c36e5202fe4e5fcbab50ef9e35fec97c4 Mon Sep 17 00:00:00 2001 From: linb Date: Tue, 1 Sep 2015 10:25:49 +0800 Subject: [PATCH] Fix duplicate dhcp edge name error When we detaching subnet from one dhcp edge and deploying a new dhcp edge for the subnet, there is a chance that we would use a duplicate name for the new dhcp edge and it would lead to duplicate name error at the backend. Since the edge name is just a tag that we can easily read and it would not be used in plugin, the patch fixed the problem by using a randomly unique edge name. Change-Id: Ia764ec8c7b54e78ed36f827df4e3025d6e309062 Fixes-bug: #1508633 --- vmware_nsx/neutron/plugins/vmware/vshield/edge_utils.py | 3 ++- .../neutron/tests/unit/vmware/vshield/test_edge_utils.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/neutron/plugins/vmware/vshield/edge_utils.py b/vmware_nsx/neutron/plugins/vmware/vshield/edge_utils.py index 545f2bd219..15f9aecf32 100644 --- a/vmware_nsx/neutron/plugins/vmware/vshield/edge_utils.py +++ b/vmware_nsx/neutron/plugins/vmware/vshield/edge_utils.py @@ -631,7 +631,8 @@ class EdgeManager(object): router_id, binding['edge_id'], jobdata=jobdata, dist=dist) def _allocate_dhcp_edge_appliance(self, context, resource_id): - resource_name = resource_id + resource_name = (vcns_const.DHCP_EDGE_PREFIX + + _uuid())[:vcns_const.EDGE_NAME_LEN] self._allocate_edge_appliance( context, resource_id, resource_name, appliance_size=vcns_const.SERVICE_SIZE_MAPPING['dhcp']) diff --git a/vmware_nsx/neutron/tests/unit/vmware/vshield/test_edge_utils.py b/vmware_nsx/neutron/tests/unit/vmware/vshield/test_edge_utils.py index 7d25d4c3c1..785718d037 100644 --- a/vmware_nsx/neutron/tests/unit/vmware/vshield/test_edge_utils.py +++ b/vmware_nsx/neutron/tests/unit/vmware/vshield/test_edge_utils.py @@ -111,10 +111,9 @@ class EdgeDHCPManagerTestCase(EdgeUtilsTestCaseMixin): self.edge_manager.create_dhcp_edge_service(self.ctx, fake_network['id'], fake_subnet) - resource_id = resource_name = (vcns_const.DHCP_EDGE_PREFIX + - fake_network['id'])[:36] + resource_id = (vcns_const.DHCP_EDGE_PREFIX + fake_network['id'])[:36] self.nsxv_manager.update_edge.assert_called_once_with( - resource_id, 'edge-1', resource_name, None, + resource_id, 'edge-1', mock.ANY, None, appliance_size=vcns_const.SERVICE_SIZE_MAPPING['dhcp'], dist=False)