NSX|V: add in locks for DHCP binding updates
The NSX does not support a DHCP update concurrently with a update on any other resource. This means that we need to ensure that these are also serialized. Change-Id: Ie1d7a0607b1d6aefad6bfcfa33ff9dc45b0c1760
This commit is contained in:
@@ -1721,6 +1721,7 @@ class EdgeManager(object):
|
|||||||
dhcp_binding = nsxv_db.get_edge_dhcp_static_binding(
|
dhcp_binding = nsxv_db.get_edge_dhcp_static_binding(
|
||||||
context.session, edge_id, mac_address)
|
context.session, edge_id, mac_address)
|
||||||
if dhcp_binding:
|
if dhcp_binding:
|
||||||
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
edge_id, dhcp_binding.binding_id)
|
edge_id, dhcp_binding.binding_id)
|
||||||
nsxv_db.delete_edge_dhcp_static_binding(
|
nsxv_db.delete_edge_dhcp_static_binding(
|
||||||
@@ -1739,6 +1740,7 @@ class EdgeManager(object):
|
|||||||
@vcns.retry_upon_exception(nsxapi_exc.VcnsApiException, max_delay=10)
|
@vcns.retry_upon_exception(nsxapi_exc.VcnsApiException, max_delay=10)
|
||||||
def _create_dhcp_binding(self, edge_id, binding):
|
def _create_dhcp_binding(self, edge_id, binding):
|
||||||
try:
|
try:
|
||||||
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
h, c = self.nsxv_manager.vcns.create_dhcp_binding(
|
h, c = self.nsxv_manager.vcns.create_dhcp_binding(
|
||||||
edge_id, binding)
|
edge_id, binding)
|
||||||
except nsxapi_exc.VcnsApiException as e:
|
except nsxapi_exc.VcnsApiException as e:
|
||||||
@@ -1767,6 +1769,7 @@ class EdgeManager(object):
|
|||||||
LOG.debug("Overlapping hostname %s with binding %s",
|
LOG.debug("Overlapping hostname %s with binding %s",
|
||||||
binding['hostname'], binding_id)
|
binding['hostname'], binding_id)
|
||||||
if binding_id:
|
if binding_id:
|
||||||
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
edge_id, binding_id)
|
edge_id, binding_id)
|
||||||
return h['location'].split('/')[-1]
|
return h['location'].split('/')[-1]
|
||||||
@@ -1799,6 +1802,7 @@ class EdgeManager(object):
|
|||||||
except nsxapi_exc.VcnsApiException:
|
except nsxapi_exc.VcnsApiException:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
for binding_id, mac_address in configured_bindings:
|
for binding_id, mac_address in configured_bindings:
|
||||||
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
edge_id, binding_id)
|
edge_id, binding_id)
|
||||||
nsxv_db.delete_edge_dhcp_static_binding(
|
nsxv_db.delete_edge_dhcp_static_binding(
|
||||||
|
Reference in New Issue
Block a user