From 747a4d28a519beed59bc791eaef231c9d1b85bb7 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 26 Apr 2017 15:20:41 +0300 Subject: [PATCH] AdminUtils: Fix NSX-V dhcp-edge recreate The admin utility: nsxadmin -r dhcp-binding -o nsx-recreate --property edge-id=edge-18 did not delete all the router_bindings entries in case of multiple networks on the same edge. This caused error messaged, and DuplicateEntries error in the sql code. Change-Id: I8c8486a77762bba9cf8c1b83c06ed938ec177418 --- .../shell/admin/plugins/nsxv/resources/dhcp_binding.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py index 53980bc2fe..760e867d57 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py @@ -130,12 +130,8 @@ def nsx_update_dhcp_edge_binding(resource, event, trigger, **kwargs): def delete_old_dhcp_edge(context, old_edge_id, bindings): LOG.info("Deleting the old DHCP edge: %s", old_edge_id) - # using one of the router-ids in the bindings for the deleting - dhcp_names = [binding['router_id'] for binding in bindings] - dhcp_name = dhcp_names[0] with locking.LockManager.get_lock(old_edge_id): # Delete from NSXv backend - # (using the first dhcp name as the "router name") # Note - If we will not delete the router, but free it - it will be # immediately used as the new one, So it is better to delete it. try: @@ -148,7 +144,7 @@ def delete_old_dhcp_edge(context, old_edge_id, bindings): try: # Remove bindings from Neutron DB - nsxv_db.delete_nsxv_router_binding(context.session, dhcp_name) + nsxv_db.clean_edge_router_binding(context.session, old_edge_id) nsxv_db.clean_edge_vnic_binding(context.session, old_edge_id) except Exception as e: LOG.warning("Failed to delete the old edge %(id)s from the "