Enable IPv6 check in haproxy template file
This patchset exposes "ipv6_enabled" variable which can be used to add IPv6 check to the haproxy template file. Change-Id: I1e7329323cbe4ea9d2d79e4196690efa015aa0f4 Closes-Bug: #1719280
This commit is contained in:
parent
96a0b1e95a
commit
82ba9595fa
|
@ -567,6 +567,13 @@ class APIConfigurationAdapter(ConfigurationAdapter):
|
|||
"""
|
||||
return getattr(self, 'prefer_ipv6', False)
|
||||
|
||||
@property
|
||||
def ipv6_enabled(self):
|
||||
"""
|
||||
@return True if IPv6 is enabled
|
||||
"""
|
||||
return not ch_ip.is_ipv6_disabled()
|
||||
|
||||
@property
|
||||
def local_address(self):
|
||||
"""Return remotely accessible address of charm (not localhost)
|
||||
|
|
|
@ -494,6 +494,20 @@ class TestAPIConfigurationAdapter(unittest.TestCase):
|
|||
self.assertEqual(c.local_host, 'ip6-localhost')
|
||||
self.assertEqual(c.haproxy_host, '::')
|
||||
|
||||
def test_ipv6_enabled(self):
|
||||
with mock.patch.object(adapters.ch_ip,
|
||||
'is_ipv6_disabled') as is_ipv6_disabled:
|
||||
|
||||
# IPv6 disabled
|
||||
is_ipv6_disabled.return_value = True
|
||||
a = adapters.APIConfigurationAdapter()
|
||||
self.assertEqual(a.ipv6_enabled, False)
|
||||
|
||||
# IPv6 enabled
|
||||
is_ipv6_disabled.return_value = False
|
||||
b = adapters.APIConfigurationAdapter()
|
||||
self.assertEqual(b.ipv6_enabled, True)
|
||||
|
||||
def test_external_ports(self):
|
||||
c = adapters.APIConfigurationAdapter(port_map=self.api_ports)
|
||||
self.assertEqual(c.external_ports, {9001, 9002, 9003})
|
||||
|
|
Loading…
Reference in New Issue