NSX|V handle duplicate hostname binding error
Ensure that the plugin handles a duplicate hostname with the dhcp bindings In this case we will retry after deleiting the existing one. Change-Id: I6e20551dc708ce899a58f395ddfb4cf2e2e1beca
This commit is contained in:
parent
5de373c544
commit
8f0ba85b96
|
@ -50,8 +50,9 @@ APPEND = -1
|
||||||
|
|
||||||
# error code
|
# error code
|
||||||
VCNS_ERROR_CODE_EDGE_NOT_RUNNING = 10013
|
VCNS_ERROR_CODE_EDGE_NOT_RUNNING = 10013
|
||||||
NSX_ERROR_DHCP_DUPLICATE_MAC = 12518
|
|
||||||
NSX_ERROR_DHCP_OVERLAPPING_IP = 12501
|
NSX_ERROR_DHCP_OVERLAPPING_IP = 12501
|
||||||
|
NSX_ERROR_DHCP_DUPLICATE_HOSTNAME = 12504
|
||||||
|
NSX_ERROR_DHCP_DUPLICATE_MAC = 12518
|
||||||
|
|
||||||
SUFFIX_LENGTH = 8
|
SUFFIX_LENGTH = 8
|
||||||
|
|
||||||
|
|
|
@ -1703,6 +1703,13 @@ class EdgeManager(object):
|
||||||
binding_id = bindings.get(binding['ipAddress'])
|
binding_id = bindings.get(binding['ipAddress'])
|
||||||
LOG.debug("Overlapping IP %s with binding %s",
|
LOG.debug("Overlapping IP %s with binding %s",
|
||||||
binding['ipAddress'], binding_id)
|
binding['ipAddress'], binding_id)
|
||||||
|
elif desc.get('errorCode') == (
|
||||||
|
vcns_const.NSX_ERROR_DHCP_DUPLICATE_HOSTNAME):
|
||||||
|
bindings = get_dhcp_binding_mappings_for_hostname(
|
||||||
|
self.nsxv_manager, edge_id)
|
||||||
|
binding_id = bindings.get(binding['hostname'])
|
||||||
|
LOG.debug("Overlapping hostname %s with binding %s",
|
||||||
|
binding['hostname'], binding_id)
|
||||||
if binding_id:
|
if binding_id:
|
||||||
self.nsxv_manager.vcns.delete_dhcp_binding(
|
self.nsxv_manager.vcns.delete_dhcp_binding(
|
||||||
edge_id, binding_id)
|
edge_id, binding_id)
|
||||||
|
@ -1858,6 +1865,15 @@ def get_dhcp_binding_mappings_for_ips(nsxv_manager, edge_id):
|
||||||
return bindings_get
|
return bindings_get
|
||||||
|
|
||||||
|
|
||||||
|
def get_dhcp_binding_mappings_for_hostname(nsxv_manager, edge_id):
|
||||||
|
dhcp_config = query_dhcp_service_config(nsxv_manager, edge_id)
|
||||||
|
bindings_get = {}
|
||||||
|
if dhcp_config:
|
||||||
|
for binding in dhcp_config['staticBindings']['staticBindings']:
|
||||||
|
bindings_get[binding['hostname']] = binding['bindingId']
|
||||||
|
return bindings_get
|
||||||
|
|
||||||
|
|
||||||
def query_dhcp_service_config(nsxv_manager, edge_id):
|
def query_dhcp_service_config(nsxv_manager, edge_id):
|
||||||
"""Retrieve the current DHCP configuration from the edge."""
|
"""Retrieve the current DHCP configuration from the edge."""
|
||||||
_, dhcp_config = nsxv_manager.vcns.query_dhcp_configuration(edge_id)
|
_, dhcp_config = nsxv_manager.vcns.query_dhcp_configuration(edge_id)
|
||||||
|
|
Loading…
Reference in New Issue