NSX|V3: Make metadata route configurable for native metadata service

This patch adds a new config parameter NATIVE_METADATA_ROUTE to
allow users to change metadata route used for native metadata service.
The default value is 169.254.169.254/32.

This can be used as a work-around for an existing cirros bug (#1607901),
where 169.254.169.254/32 is dropped by cirros DHCP client for option 121.
By setting NATIVE_METADATA_ROUTE=169.254.169.254/31, it can be accepted
by cirros thus allowing metadata requests sent to native metadata proxy.

Change-Id: Ibb5b76487284e748a60f75cc713bc7a17c553adb
Related-Bug: #1607901
This commit is contained in:
Shih-Hao Li 2016-07-31 23:07:14 -07:00 committed by Adit Sarfaty
parent 7a9336f09f
commit 20f58fc5ce
5 changed files with 16 additions and 8 deletions

View File

@ -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

View File

@ -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 "

View File

@ -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)

View File

@ -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,

View File

@ -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)