NSX|V: do not connect DVR to DHCP edge if not DHCP enabled

Ensure that the subnet is not attached to a DHCP egde if there is
no DHCP enabled on the subnet

Co-Authored-By: Kobi Samoray <ksamoray@vmware.com>
Change-Id: I480267ee98efb4f88d8b75b732af6d2f82cc0267
This commit is contained in:
Gary Kotton 2016-12-13 06:39:41 -08:00 committed by Kobi Samoray
parent a966ca0708
commit 548776e81e
1 changed files with 12 additions and 2 deletions

View File

@ -270,8 +270,13 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
# Update edge's firewall rules to accept subnets flows.
self.plugin._update_subnets_and_dnat_firewall(context, router_db)
sids = self.plugin.get_subnets(context,
filters={'network_id': [network_id],
'enable_dhcp': [True]},
fields=['id'])
is_dhcp_network = len(sids) > 0
do_metadata = False
if self.plugin.metadata_proxy_handler:
if self.plugin.metadata_proxy_handler and is_dhcp_network:
for fixed_ip in port.get("fixed_ips", []):
if fixed_ip['ip_address'] == subnet['gateway_ip']:
do_metadata = True
@ -404,6 +409,11 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
vdr_dhcp_binding = nsxv_db.get_vdr_dhcp_binding_by_vdr(
context.session, router_id)
sids = self.plugin.get_subnets(context,
filters={'network_id': [network_id],
'enable_dhcp': [True]},
fields=['id'])
is_dhcp_network = len(sids) > 0
with locking.LockManager.get_lock(self._get_edge_id(context,
router_id)):
if router_db.gw_port and router_db.enable_snat:
@ -421,7 +431,7 @@ class RouterDistributedDriver(router_driver.RouterBaseDriver):
# If DHCP is disabled, this remove cannot trigger metadata change
# as metadata is served via DHCP Edge
elif (subnet['enable_dhcp']
elif (is_dhcp_network
and self.plugin.metadata_proxy_handler):
md_gw_data = self._get_metadata_gw_data(context, router_id)
if self._metadata_cfg_required_after_port_remove(