NSX|P: update dhcp config on segent subnet

Make sure to set the DHCP config only if there is a dhcp server ip.
Missing ip can happen during the process of deleting a subnet.

Change-Id: I1e8071935a01a7e07732c5033744f74769210043
This commit is contained in:
asarfaty 2020-06-09 11:51:11 +02:00
parent 801c074587
commit 828ebac314
1 changed files with 21 additions and 19 deletions

View File

@ -1142,9 +1142,11 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
dhcp_subnet_id = dhcp_subnet['id'] dhcp_subnet_id = dhcp_subnet['id']
dhcp_subnet_ids.append(dhcp_subnet_id) dhcp_subnet_ids.append(dhcp_subnet_id)
gw_addr = self._get_gateway_addr_from_subnet(dhcp_subnet) gw_addr = self._get_gateway_addr_from_subnet(dhcp_subnet)
cidr_prefix = int(dhcp_subnet['cidr'].split('/')[1])
dhcp_server_ip = self._get_sunbet_dhcp_server_ip( dhcp_server_ip = self._get_sunbet_dhcp_server_ip(
context, net_id, dhcp_subnet_id) context, net_id, dhcp_subnet_id)
dhcp_config = None
if dhcp_server_ip:
cidr_prefix = int(dhcp_subnet['cidr'].split('/')[1])
dns_nameservers = dhcp_subnet['dns_nameservers'] dns_nameservers = dhcp_subnet['dns_nameservers']
if not net_az: if not net_az:
net_az = self.get_network_az_by_net_id(context, net_id) net_az = self.get_network_az_by_net_id(context, net_id)