sync with lp:~xianghui/charm-helpers/lp1385162, use get_adrresses() in charms-helpers instead.
This commit is contained in:
@@ -586,29 +586,11 @@ class ApacheSSLContext(OSContextGenerator):
|
||||
cns.append(k.lstrip('ssl_key_'))
|
||||
return list(set(cns))
|
||||
|
||||
def __call__(self):
|
||||
if isinstance(self.external_ports, basestring):
|
||||
self.external_ports = [self.external_ports]
|
||||
if (not self.external_ports or not https()):
|
||||
return {}
|
||||
|
||||
self.configure_ca()
|
||||
self.enable_modules()
|
||||
|
||||
ctxt = {
|
||||
'namespace': self.service_namespace,
|
||||
'endpoints': [],
|
||||
'ext_ports': []
|
||||
}
|
||||
|
||||
for cn in self.canonical_names():
|
||||
self.configure_cert(cn)
|
||||
|
||||
def get_addresses(self):
|
||||
addresses = []
|
||||
vips = []
|
||||
if config('vip'):
|
||||
vips = config('vip').split()
|
||||
|
||||
for network_type in ['os-internal-network',
|
||||
'os-admin-network',
|
||||
'os-public-network']:
|
||||
@@ -627,7 +609,27 @@ class ApacheSSLContext(OSContextGenerator):
|
||||
addresses.append((address, config('vip')))
|
||||
else:
|
||||
addresses.append((address, address))
|
||||
return addresses
|
||||
|
||||
def __call__(self):
|
||||
if isinstance(self.external_ports, basestring):
|
||||
self.external_ports = [self.external_ports]
|
||||
if (not self.external_ports or not https()):
|
||||
return {}
|
||||
|
||||
self.configure_ca()
|
||||
self.enable_modules()
|
||||
|
||||
ctxt = {
|
||||
'namespace': self.service_namespace,
|
||||
'endpoints': [],
|
||||
'ext_ports': []
|
||||
}
|
||||
|
||||
for cn in self.canonical_names():
|
||||
self.configure_cert(cn)
|
||||
|
||||
addresses = self.get_addresses()
|
||||
for address, endpoint in set(addresses):
|
||||
for api_port in self.external_ports:
|
||||
ext_port = determine_apache_port(api_port)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from charmhelpers.core.hookenv import config, unit_get, log
|
||||
from charmhelpers.core.hookenv import config
|
||||
|
||||
from charmhelpers.core.host import mkdir, write_file
|
||||
|
||||
@@ -6,15 +6,11 @@ from charmhelpers.contrib.openstack import context
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
determine_apache_port,
|
||||
determine_api_port,
|
||||
is_clustered
|
||||
determine_api_port
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.apache import install_ca_cert
|
||||
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_address_in_network, is_address_in_network)
|
||||
|
||||
import os
|
||||
|
||||
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
|
||||
@@ -49,29 +45,12 @@ class ApacheSSLContext(context.ApacheSSLContext):
|
||||
install_ca_cert(ca.get_ca_bundle())
|
||||
|
||||
def canonical_names(self):
|
||||
addresses = []
|
||||
vips = []
|
||||
if config('vip'):
|
||||
vips = config('vip').split()
|
||||
for network_type in ['os-internal-network',
|
||||
'os-admin-network',
|
||||
'os-public-network']:
|
||||
address = get_address_in_network(config(network_type),
|
||||
unit_get('private-address'))
|
||||
if len(vips) > 1 and is_clustered():
|
||||
if not config(network_type):
|
||||
log("Multinet is used, but network_type (%s) is None."
|
||||
% network_type, level='WARNING')
|
||||
continue
|
||||
for vip in vips:
|
||||
if is_address_in_network(config(network_type), vip):
|
||||
addresses.append(vip)
|
||||
break
|
||||
elif is_clustered():
|
||||
addresses.append(config('vip'))
|
||||
else:
|
||||
addresses.append(address)
|
||||
return list(set(addresses))
|
||||
addresses = self.get_addresses()
|
||||
addrs = []
|
||||
for address, endpoint in addresses:
|
||||
addrs.append(endpoint)
|
||||
|
||||
return list(set(addrs))
|
||||
|
||||
|
||||
class HAProxyContext(context.HAProxyContext):
|
||||
|
||||
@@ -92,10 +92,10 @@ class TestKeystoneContexts(CharmTestCase):
|
||||
}
|
||||
)
|
||||
|
||||
@patch('keystone_context.log')
|
||||
@patch('keystone_context.config')
|
||||
@patch('keystone_context.unit_get')
|
||||
@patch('keystone_context.is_clustered')
|
||||
@patch('charmhelpers.contrib.openstack.context.log')
|
||||
@patch('charmhelpers.contrib.openstack.context.config')
|
||||
@patch('charmhelpers.contrib.openstack.context.unit_get')
|
||||
@patch('charmhelpers.contrib.openstack.context.is_clustered')
|
||||
@patch('charmhelpers.contrib.network.ip.get_address_in_network')
|
||||
def test_canonical_names_without_network_splits(self,
|
||||
mock_get_address,
|
||||
@@ -115,5 +115,6 @@ class TestKeystoneContexts(CharmTestCase):
|
||||
mock_config.side_effect = lambda key: config[key]
|
||||
apache = context.ApacheSSLContext()
|
||||
apache.canonical_names()
|
||||
msg = "Multinet is used, but network_type (os-public-network) is None."
|
||||
msg = "Multiple networks configured but network_type" \
|
||||
"(os-public-network) is None."
|
||||
mock_log.assert_called_with(msg, level="WARNING")
|
||||
|
||||
Reference in New Issue
Block a user