# use_namespaces = True will be enforced.
# use_namespaces = True
+# In some cases the neutron router is not present to provide the metadata
+# IP but the DHCP server can be used to provide this info. Setting this
+# value will force the DHCP server to append specific host routes to the
+# DHCP request. If this option is set, then the metadata service will be
+# activated for all the networks.
+# force_metadata = False
+
# The DHCP server can assist with providing metadata support on isolated
# networks. Setting this value to True will cause the DHCP server to append
# specific host routes to the DHCP request. The metadata service will only
# be activated when the subnet does not contain any router port. The guest
# instance must be configured to request host routes via DHCP (Option 121).
+# This option doesn't have any effect when force_metadata is set to True.
# enable_isolated_metadata = False
# Allows for serving metadata requests coming from a dedicated metadata
help=_("The driver used to manage the DHCP server.")),
cfg.BoolOpt('enable_isolated_metadata', default=False,
help=_("Support Metadata requests on isolated networks.")),
+ cfg.BoolOpt('force_metadata', default=False,
+ help=_("Force to use DHCP to get Metadata on all networks.")),
cfg.BoolOpt('enable_metadata_network', default=False,
help=_("Allows for serving metadata requests from a "
"dedicated network. Requires "
# Add host routes for isolated network segments
- if (isolated_subnets[subnet.id] and
+ if (self.conf.force_metadata or
+ (isolated_subnets[subnet.id] and
self.conf.enable_isolated_metadata and
- subnet.ip_version == 4):
+ subnet.ip_version == 4)):
subnet_dhcp_ip = subnet_to_interface_ip[subnet.id]
host_routes.append(
'%s/32,%s' % (METADATA_DEFAULT_IP, subnet_dhcp_ip)
A subnet is considered non-isolated if there is a port connected to
the subnet, and the port's ip address matches that of the subnet's
- gateway. The port must be owned by a nuetron router.
+ gateway. The port must be owned by a neutron router.
"""
isolated_subnets = collections.defaultdict(lambda: True)
subnets = dict((subnet.id, subnet) for subnet in network.subnets)
"""Determine whether the metadata proxy is needed for a network
This method returns True for truly isolated networks (ie: not attached
- to a router), when the enable_isolated_metadata flag is True.
+ to a router) when enable_isolated_metadata is True, or for all the
+ networks when the force_metadata flags is True.
This method also returns True when enable_metadata_network is True,
and the network passed as a parameter has a subnet in the link-local
providing access to the metadata service via logical routers built
with 3rd party backends.
"""
+ if conf.force_metadata:
+ return True
+
if conf.enable_metadata_network and conf.enable_isolated_metadata:
# check if the network has a metadata subnet
meta_cidr = netaddr.IPNetwork(METADATA_DEFAULT_CIDR)
self.mock_mgr = instance.start()
self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata',
default=True))
+ self.conf.register_opt(cfg.BoolOpt("force_metadata",
+ default=False))
self.conf.register_opt(cfg.BoolOpt('enable_metadata_network',
default=False))
self.config_parse(self.conf)
self.assertTrue(dhcp.Dnsmasq.should_enable_metadata(
self.conf, FakeV4MetadataNetwork()))
+ def test_should_force_metadata_returns_true(self):
+ self.conf.set_override("force_metadata", True)
+ self.assertTrue(dhcp.Dnsmasq.should_enable_metadata(self.conf,
+ mock.ANY))
+
class TestDeviceManager(TestConfBase):