Don't add neutron metadata_nat_rules if disable metadata proxy
This patchset fixes this issue by adding a condition when adding nat rules of neutron metadata proxy. fixes bug #1212168 Change-Id: I99775aad73c49a8df3043690440d214614279a2b
This commit is contained in:
parent
ff514f3938
commit
f9c55fbaa2
@ -534,9 +534,10 @@ class L3NATAgent(firewall_l3_agent.FWaaSL3AgentRpcCallback, manager.Manager):
|
|||||||
|
|
||||||
def metadata_nat_rules(self):
|
def metadata_nat_rules(self):
|
||||||
rules = []
|
rules = []
|
||||||
rules.append(('PREROUTING', '-s 0.0.0.0/0 -d 169.254.169.254/32 '
|
if self.conf.enable_metadata_proxy:
|
||||||
'-p tcp -m tcp --dport 80 -j REDIRECT '
|
rules.append(('PREROUTING', '-s 0.0.0.0/0 -d 169.254.169.254/32 '
|
||||||
'--to-port %s' % self.conf.metadata_port))
|
'-p tcp -m tcp --dport 80 -j REDIRECT '
|
||||||
|
'--to-port %s' % self.conf.metadata_port))
|
||||||
return rules
|
return rules
|
||||||
|
|
||||||
def external_gateway_nat_rules(self, ex_gw_ip, internal_cidrs,
|
def external_gateway_nat_rules(self, ex_gw_ip, internal_cidrs,
|
||||||
|
@ -634,6 +634,18 @@ class TestBasicRouterOperations(base.BaseTestCase):
|
|||||||
def test_disable_metadata_proxy_spawn(self):
|
def test_disable_metadata_proxy_spawn(self):
|
||||||
self._configure_metadata_proxy(enableflag=False)
|
self._configure_metadata_proxy(enableflag=False)
|
||||||
|
|
||||||
|
def test_metadata_nat_rules(self):
|
||||||
|
self.conf.set_override('enable_metadata_proxy', False)
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
self.assertEqual([], agent.metadata_nat_rules())
|
||||||
|
|
||||||
|
self.conf.set_override('metadata_port', '8775')
|
||||||
|
self.conf.set_override('enable_metadata_proxy', True)
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
rules = ('PREROUTING', '-s 0.0.0.0/0 -d 169.254.169.254/32 '
|
||||||
|
'-p tcp -m tcp --dport 80 -j REDIRECT --to-port 8775')
|
||||||
|
self.assertEqual([rules], agent.metadata_nat_rules())
|
||||||
|
|
||||||
|
|
||||||
class TestL3AgentEventHandler(base.BaseTestCase):
|
class TestL3AgentEventHandler(base.BaseTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user