Add a configuration item to disable metadata proxy
Bug #1166543 Change-Id: If7aee8d79b7ca275f89cf9299eac1f76d5500fcc
This commit is contained in:
parent
08e3eaf289
commit
e2a08f41b8
@ -51,3 +51,7 @@ interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver
|
||||
# seconds to start to sync routers' data after
|
||||
# starting agent
|
||||
# periodic_fuzzy_delay = 5
|
||||
|
||||
# enable_metadata_proxy, which is true by default, can be set to False
|
||||
# if the Nova metadata server is not available
|
||||
# enable_metadata_proxy = True
|
@ -139,6 +139,8 @@ class L3NATAgent(manager.Manager):
|
||||
cfg.StrOpt('gateway_external_network_id', default='',
|
||||
help=_("UUID of external network for routers implemented "
|
||||
"by the agents.")),
|
||||
cfg.BoolOpt('enable_metadata_proxy', default=True,
|
||||
help=_("Allow running metadata proxy.")),
|
||||
]
|
||||
|
||||
def __init__(self, host, conf=None):
|
||||
@ -232,7 +234,8 @@ class L3NATAgent(manager.Manager):
|
||||
for c, r in self.metadata_nat_rules():
|
||||
ri.iptables_manager.ipv4['nat'].add_rule(c, r)
|
||||
ri.iptables_manager.apply()
|
||||
self._spawn_metadata_proxy(ri)
|
||||
if self.conf.enable_metadata_proxy:
|
||||
self._spawn_metadata_proxy(ri)
|
||||
|
||||
def _router_removed(self, router_id):
|
||||
ri = self.router_info[router_id]
|
||||
@ -245,7 +248,8 @@ class L3NATAgent(manager.Manager):
|
||||
for c, r in self.metadata_nat_rules():
|
||||
ri.iptables_manager.ipv4['nat'].remove_rule(c, r)
|
||||
ri.iptables_manager.apply()
|
||||
self._destroy_metadata_proxy(ri)
|
||||
if self.conf.enable_metadata_proxy:
|
||||
self._destroy_metadata_proxy(ri)
|
||||
del self.router_info[router_id]
|
||||
self._destroy_router_namespace(ri.ns_name())
|
||||
|
||||
|
@ -429,6 +429,35 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
||||
|
||||
self.assertEqual(agent._destroy_router_namespace.call_count, 1)
|
||||
|
||||
def _configure_metadata_proxy(self, enableflag=True):
|
||||
if not enableflag:
|
||||
self.conf.set_override('enable_metadata_proxy', False)
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
router_id = _uuid()
|
||||
router = {'id': _uuid(),
|
||||
'external_gateway_info': {},
|
||||
'routes': []}
|
||||
with mock.patch.object(
|
||||
agent, '_destroy_metadata_proxy') as destroy_proxy:
|
||||
with mock.patch.object(
|
||||
agent, '_spawn_metadata_proxy') as spawn_proxy:
|
||||
agent._router_added(router_id, router)
|
||||
if enableflag:
|
||||
spawn_proxy.assert_called_with(mock.ANY)
|
||||
else:
|
||||
self.assertFalse(spawn_proxy.call_count)
|
||||
agent._router_removed(router_id)
|
||||
if enableflag:
|
||||
destroy_proxy.assert_called_with(mock.ANY)
|
||||
else:
|
||||
self.assertFalse(destroy_proxy.call_count)
|
||||
|
||||
def test_enable_metadata_proxy(self):
|
||||
self._configure_metadata_proxy()
|
||||
|
||||
def test_disable_metadata_proxy_spawn(self):
|
||||
self._configure_metadata_proxy(enableflag=False)
|
||||
|
||||
|
||||
class TestL3AgentEventHandler(base.BaseTestCase):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user