diff --git a/devstack/lib/vmware_nsx_v3 b/devstack/lib/vmware_nsx_v3 index 56a81a1b07..0795f7af02 100644 --- a/devstack/lib/vmware_nsx_v3 +++ b/devstack/lib/vmware_nsx_v3 @@ -30,8 +30,10 @@ NSX_GATEWAY_NETWORK_INTERFACE=${NSX_GATEWAY_NETWORK_INTERFACE:-} # Override default 'True' in devstack:lib/neutron_plugins/services/l3 Q_USE_PROVIDERNET_FOR_PUBLIC=False + # Native support from platform NATIVE_DHCP_METADATA=${NATIVE_DHCP_METADATA:-False} +NATIVE_METADATA_ROUTE=${NATIVE_METADATA_ROUTE:-169.254.169.254/32} METADATA_PROXY_SHARED_SECRET=${METADATA_PROXY_SHARED_SECRET:-} # Save trace setting @@ -153,6 +155,7 @@ function neutron_plugin_configure_service { _nsxv3_ini_set default_bridge_cluster $DEFAULT_BRIDGE_CLUSTER_UUID if [[ "$NATIVE_DHCP_METADATA" == "True" ]]; then _nsxv3_ini_set native_dhcp_metadata $NATIVE_DHCP_METADATA + _nsxv3_ini_set native_metadata_route $NATIVE_METADATA_ROUTE _nsxv3_ini_set dhcp_profile_uuid $DHCP_PROFILE_UUID _nsxv3_ini_set metadata_proxy_uuid $METADATA_PROXY_UUID iniset $NEUTRON_CONF DEFAULT dhcp_agent_notification False diff --git a/vmware_nsx/common/config.py b/vmware_nsx/common/config.py index 0801ffec49..dc66f66a30 100644 --- a/vmware_nsx/common/config.py +++ b/vmware_nsx/common/config.py @@ -353,6 +353,10 @@ nsx_v3_opts = [ default=False, help=_("If true, DHCP and metadata proxy services will be " "provided by NSX backend.")), + cfg.StrOpt('native_metadata_route', + default="169.254.169.254/32", + help=_("The metadata route used for native metadata proxy " + "service.")), cfg.StrOpt('dhcp_profile_uuid', help=_("This is the UUID of the NSX DHCP Profile that will be " "used to enable native DHCP service. It needs to be " diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 35cdd831fe..449bc894ff 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -1374,7 +1374,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, try: hostname = 'host-%s' % ip.replace('.', '-') options = {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': ip}]}} binding = self._dhcp_server.create_binding( dhcp_service_id, port['mac_address'], ip, hostname, @@ -1526,7 +1526,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, if ip != binding['ip_address']: data['host_name'] = 'host-%s' % ip.replace('.', '-') data['options'] = {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': ip}]}} self._dhcp_server.update_binding( binding['nsx_service_id'], binding['nsx_binding_id'], **data) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/dhcp_binding.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/dhcp_binding.py index cfda092e3c..337aace34b 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/dhcp_binding.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/dhcp_binding.py @@ -21,7 +21,6 @@ from oslo_config import cfg from vmware_nsx._i18n import _LI from vmware_nsx.common import nsx_constants from vmware_nsx.common import utils as comm_utils -from vmware_nsx.dhcp_meta import rpc as nsx_rpc from vmware_nsx.nsxlib import v3 as nsxlib from vmware_nsx.nsxlib.v3 import client from vmware_nsx.nsxlib.v3 import cluster @@ -102,7 +101,7 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs): for (mac, ip) in bindings: hostname = 'host-%s' % ip.replace('.', '-') options = {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': ip}]}} dhcp_server_resource.create_binding( dhcp_server_id, mac, ip, hostname, diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 01afe42b1f..91261f181d 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -49,7 +49,6 @@ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import nsx_constants from vmware_nsx.common import utils from vmware_nsx.db import db as nsx_db -from vmware_nsx.dhcp_meta import rpc as nsx_rpc from vmware_nsx.extensions import advancedserviceproviders as as_providers from vmware_nsx.nsxlib.v3 import client as nsx_client from vmware_nsx.nsxlib.v3 import cluster as nsx_cluster @@ -1053,7 +1052,8 @@ class NsxNativeDhcpTestCase(NsxV3PluginTestCaseMixin): ip = port['port']['fixed_ips'][0]['ip_address'] hostname = 'host-%s' % ip.replace('.', '-') options = {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % + cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': ip}]}} create_dhcp_binding.assert_called_once_with( dhcp_service['nsx_service_id'], @@ -1113,7 +1113,8 @@ class NsxNativeDhcpTestCase(NsxV3PluginTestCaseMixin): assert_data = {'host_name': 'host-%s' % new_ip.replace('.', '-'), 'ip_address': new_ip, 'options': {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % + cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': new_ip}]}}} self._verify_dhcp_binding(subnet, port_data, update_data, assert_data) @@ -1144,7 +1145,8 @@ class NsxNativeDhcpTestCase(NsxV3PluginTestCaseMixin): 'mac_address': new_mac, 'ip_address': new_ip, 'options': {'option121': {'static_routes': [ - {'network': '%s' % nsx_rpc.METADATA_DHCP_ROUTE, + {'network': '%s' % + cfg.CONF.nsx_v3.native_metadata_route, 'next_hop': new_ip}]}}} self._verify_dhcp_binding(subnet, port_data, update_data, assert_data)