Merge "NSX|V: add in locks for DHCP binding updates"
This commit is contained in:
commit
88a423dc21
@ -1721,8 +1721,9 @@ 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:
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
edge_id, dhcp_binding.binding_id)
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
|
edge_id, dhcp_binding.binding_id)
|
||||||
nsxv_db.delete_edge_dhcp_static_binding(
|
nsxv_db.delete_edge_dhcp_static_binding(
|
||||||
context.session, edge_id, mac_address)
|
context.session, edge_id, mac_address)
|
||||||
else:
|
else:
|
||||||
@ -1739,8 +1740,9 @@ 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:
|
||||||
h, c = self.nsxv_manager.vcns.create_dhcp_binding(
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
edge_id, binding)
|
h, c = self.nsxv_manager.vcns.create_dhcp_binding(
|
||||||
|
edge_id, binding)
|
||||||
except nsxapi_exc.VcnsApiException as e:
|
except nsxapi_exc.VcnsApiException as e:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
binding_id = None
|
binding_id = None
|
||||||
@ -1767,8 +1769,9 @@ 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:
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
edge_id, binding_id)
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
|
edge_id, binding_id)
|
||||||
return h['location'].split('/')[-1]
|
return h['location'].split('/')[-1]
|
||||||
|
|
||||||
def create_dhcp_bindings(self, context, port_id, network_id, bindings):
|
def create_dhcp_bindings(self, context, port_id, network_id, bindings):
|
||||||
@ -1799,8 +1802,9 @@ 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:
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
with locking.LockManager.get_lock(str(edge_id)):
|
||||||
edge_id, binding_id)
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
|
edge_id, binding_id)
|
||||||
nsxv_db.delete_edge_dhcp_static_binding(
|
nsxv_db.delete_edge_dhcp_static_binding(
|
||||||
context.session, edge_id, mac_address)
|
context.session, edge_id, mac_address)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user