@@ -3610,6 +3610,7 @@ def _get_subnets_from_port(self, context, port, client=None):
36103610 'gateway' : network_model .IP (
36113611 address = subnet ['gateway_ip' ],
36123612 type = 'gateway' ),
3613+ 'enable_dhcp' : False ,
36133614 }
36143615 if subnet .get ('ipv6_address_mode' ):
36153616 subnet_dict ['ipv6_address_mode' ] = subnet ['ipv6_address_mode' ]
@@ -3626,22 +3627,14 @@ def _get_subnets_from_port(self, context, port, client=None):
36263627 subnet_dict ['dhcp_server' ] = ip_pair ['ip_address' ]
36273628 break
36283629
3629- # NOTE(arnaudmorin): If enable_dhcp is set on subnet, but, for
3630- # some reason neutron did not have any DHCP port yet, we still
3631- # want the network_info to be populated with a valid dhcp_server
3632- # value. This is mostly useful for the metadata API (which is
3633- # relying on this value to give network_data to the instance).
3634- #
3635- # This will also help some providers which are using external
3636- # DHCP servers not handled by neutron.
3637- # In this case, neutron will never create any DHCP port in the
3638- # subnet.
3639- #
3640- # Also note that we cannot set the value to None because then the
3641- # value would be discarded by the metadata API.
3642- # So the subnet gateway will be used as fallback.
3643- if subnet .get ('enable_dhcp' ) and 'dhcp_server' not in subnet_dict :
3644- subnet_dict ['dhcp_server' ] = subnet ['gateway_ip' ]
3630+ # NOTE(stblatzheim): If enable_dhcp is set on subnet, but subnet
3631+ # has ovn native dhcp and no dhcp-agents. Network owner will be
3632+ # network:distributed
3633+ # Just rely on enable_dhcp flag given by neutron
3634+ # Fix for https://bugs.launchpad.net/nova/+bug/2055245
3635+
3636+ if subnet .get ('enable_dhcp' ):
3637+ subnet_dict ['enable_dhcp' ] = True
36453638
36463639 subnet_object = network_model .Subnet (** subnet_dict )
36473640 for dns in subnet .get ('dns_nameservers' , []):
0 commit comments