Merge "NSX|V: add in locks for DHCP binding updates"

This commit is contained in:
Jenkins 2016-11-15 13:44:52 +00:00 committed by Gerrit Code Review
commit 88a423dc21

View File

@ -1721,6 +1721,7 @@ class EdgeManager(object):
dhcp_binding = nsxv_db.get_edge_dhcp_static_binding(
context.session, edge_id, mac_address)
if dhcp_binding:
with locking.LockManager.get_lock(str(edge_id)):
self.nsxv_manager.vcns.delete_dhcp_binding(
edge_id, dhcp_binding.binding_id)
nsxv_db.delete_edge_dhcp_static_binding(
@ -1739,6 +1740,7 @@ class EdgeManager(object):
@vcns.retry_upon_exception(nsxapi_exc.VcnsApiException, max_delay=10)
def _create_dhcp_binding(self, edge_id, binding):
try:
with locking.LockManager.get_lock(str(edge_id)):
h, c = self.nsxv_manager.vcns.create_dhcp_binding(
edge_id, binding)
except nsxapi_exc.VcnsApiException as e:
@ -1767,6 +1769,7 @@ class EdgeManager(object):
LOG.debug("Overlapping hostname %s with binding %s",
binding['hostname'], binding_id)
if binding_id:
with locking.LockManager.get_lock(str(edge_id)):
self.nsxv_manager.vcns.delete_dhcp_binding(
edge_id, binding_id)
return h['location'].split('/')[-1]
@ -1799,6 +1802,7 @@ class EdgeManager(object):
except nsxapi_exc.VcnsApiException:
with excutils.save_and_reraise_exception():
for binding_id, mac_address in configured_bindings:
with locking.LockManager.get_lock(str(edge_id)):
self.nsxv_manager.vcns.delete_dhcp_binding(
edge_id, binding_id)
nsxv_db.delete_edge_dhcp_static_binding(