From 31bd496e31e38010ec5782b455a2a3ea28ad7fc1 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 18 Oct 2021 08:25:32 -0700 Subject: [PATCH] [NSX-P/NSX-v3] Metadata route: make windows route optional Introduce a new configuration option - windows_metadata_route. Specifies whether an explicit route for metadata proxy access on windows should be added. The default value will be True for backward compatibility. This option will need to be set to False for some guest OSes such as RHEL8 as a duplicate metadata route can cause failures while setting up networking. Change-Id: If7507d0d4242cce2c73c7a2239149ec35fef232f --- vmware_nsx/common/config.py | 4 ++++ vmware_nsx/plugins/common_v3/availability_zones.py | 4 ++++ vmware_nsx/plugins/common_v3/plugin.py | 12 ++++++++---- vmware_nsx/plugins/nsx_p/availability_zones.py | 1 + vmware_nsx/plugins/nsx_v3/availability_zones.py | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index 9914dec5db..9366ef921a 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -318,6 +318,10 @@ nsx_v3_and_p = [ default="169.254.169.254/31", help=_("The metadata route used for native metadata proxy " "service.")), + cfg.BoolOpt('windows_metadata_route', + default=True, + help=_("Inject a route for allowing windows guest access NSX " + "native metadata proxy service")), cfg.StrOpt('dns_domain', default='openstacklocal', help=_("Domain to use for building the hostnames.")), diff --git a/vmware_nsx/plugins/common_v3/availability_zones.py b/vmware_nsx/plugins/common_v3/availability_zones.py index 30df71913b..7074681979 100644 --- a/vmware_nsx/plugins/common_v3/availability_zones.py +++ b/vmware_nsx/plugins/common_v3/availability_zones.py @@ -60,6 +60,10 @@ class NsxV3AvailabilityZone(common_az.ConfiguredAvailabilityZone): native_metadata_route = az_info.get('native_metadata_route') if native_metadata_route: self.native_metadata_route = native_metadata_route + windows_metadata_route = az_info.get('windows_metadata_route') + # Careful - this is a boolean + if windows_metadata_route is not None: + self.windows_metadata_route = windows_metadata_route else: self.metadata_proxy = None self.dhcp_profile = None diff --git a/vmware_nsx/plugins/common_v3/plugin.py b/vmware_nsx/plugins/common_v3/plugin.py index 70d06448e2..7d352bc3f8 100644 --- a/vmware_nsx/plugins/common_v3/plugin.py +++ b/vmware_nsx/plugins/common_v3/plugin.py @@ -2617,11 +2617,15 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, subnet): # Always add option121. net_az = self.get_network_az_by_net_id(context, net_id) - options = {'option121': {'static_routes': [ + static_routes = [] + options = {'option121': {'static_routes': static_routes}} + if net_az.windows_metadata_route: + static_routes.append( + {'network': '%s' % net_az.native_metadata_route, + 'next_hop': '0.0.0.0'}) + static_routes.append( {'network': '%s' % net_az.native_metadata_route, - 'next_hop': '0.0.0.0'}, - {'network': '%s' % net_az.native_metadata_route, - 'next_hop': ip}]}} + 'next_hop': ip}) if subnet: sr, gateway_ip = self._build_static_routes( subnet.get('gateway_ip'), subnet.get('cidr'), diff --git a/vmware_nsx/plugins/nsx_p/availability_zones.py b/vmware_nsx/plugins/nsx_p/availability_zones.py index 10f98937b5..32c4ea21f9 100644 --- a/vmware_nsx/plugins/nsx_p/availability_zones.py +++ b/vmware_nsx/plugins/nsx_p/availability_zones.py @@ -40,6 +40,7 @@ class NsxPAvailabilityZone(v3_az.NsxV3AvailabilityZone): self.metadata_proxy = cfg.CONF.nsx_p.metadata_proxy self.dhcp_profile = cfg.CONF.nsx_p.dhcp_profile self.native_metadata_route = cfg.CONF.nsx_p.native_metadata_route + self.windows_metadata_route = cfg.CONF.nsx_p.windows_metadata_route self.default_overlay_tz = cfg.CONF.nsx_p.default_overlay_tz self.default_vlan_tz = cfg.CONF.nsx_p.default_vlan_tz self.default_tier0_router = cfg.CONF.nsx_p.default_tier0_router diff --git a/vmware_nsx/plugins/nsx_v3/availability_zones.py b/vmware_nsx/plugins/nsx_v3/availability_zones.py index 5a623b18a5..e5db0cc154 100644 --- a/vmware_nsx/plugins/nsx_v3/availability_zones.py +++ b/vmware_nsx/plugins/nsx_v3/availability_zones.py @@ -49,6 +49,7 @@ class NsxV3AvailabilityZone(v3_az.NsxV3AvailabilityZone): self.metadata_proxy = cfg.CONF.nsx_v3.metadata_proxy self.dhcp_profile = cfg.CONF.nsx_v3.dhcp_profile self.native_metadata_route = cfg.CONF.nsx_v3.native_metadata_route + self.windows_metadata_route = cfg.CONF.nsx_v3.windows_metadata_route self.dns_domain = cfg.CONF.nsx_v3.dns_domain self.nameservers = cfg.CONF.nsx_v3.nameservers self.default_overlay_tz = cfg.CONF.nsx_v3.default_overlay_tz