Updates for testing period for 20.01 release
Includes updates to charmhelpers/charms.openstack for cert_utils and unit-get for the install hook error on Juju 2.9 * charm-helpers sync for classic charms * rebuild for reactive charms * ensure tox.ini is from release-tools * ensure requirements.txt files are from release-tools * On reactive charms: - ensure master branch for charms.openstack - ensure master branch for charm-helpers * Remove unit_get mock from unit tests as not in charmhelpers context Change-Id: Ic828c8d6dd45148a1684c74d3f2b2157cfe6bbc4
This commit is contained in:
parent
93efd6e81d
commit
51b3383b03
|
@ -30,7 +30,6 @@ from charmhelpers.core.hookenv import (
|
|||
relation_get,
|
||||
relation_ids,
|
||||
remote_service_name,
|
||||
unit_get,
|
||||
NoNetworkBinding,
|
||||
log,
|
||||
WARNING,
|
||||
|
@ -41,6 +40,7 @@ from charmhelpers.contrib.openstack.ip import (
|
|||
get_vip_in_network,
|
||||
ADDRESS_MAP,
|
||||
get_default_api_bindings,
|
||||
local_address,
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_relation_ip,
|
||||
|
@ -81,7 +81,7 @@ class CertRequest(object):
|
|||
|
||||
def add_hostname_cn(self):
|
||||
"""Add a request for the hostname of the machine"""
|
||||
ip = unit_get('private-address')
|
||||
ip = local_address(unit_get_fallback='private-address')
|
||||
addresses = [ip]
|
||||
# If a vip is being used without os-hostname config or
|
||||
# network spaces then we need to ensure the local units
|
||||
|
@ -194,7 +194,7 @@ def get_certificate_sans(bindings=None):
|
|||
:returns: List of binding string names
|
||||
:rtype: List[str]
|
||||
"""
|
||||
_sans = [unit_get('private-address')]
|
||||
_sans = [local_address(unit_get_fallback='private-address')]
|
||||
if bindings:
|
||||
# Add default API bindings to bindings list
|
||||
bindings = list(bindings + get_default_api_bindings())
|
||||
|
@ -260,7 +260,7 @@ def create_ip_cert_links(ssl_dir, custom_hostname_link=None, bindings=None):
|
|||
os.symlink(requested_key, key)
|
||||
|
||||
# Handle custom hostnames
|
||||
hostname = get_hostname(unit_get('private-address'))
|
||||
hostname = get_hostname(local_address(unit_get_fallback='private-address'))
|
||||
hostname_cert = os.path.join(
|
||||
ssl_dir,
|
||||
'cert_{}'.format(hostname))
|
||||
|
|
|
@ -49,7 +49,6 @@ from charmhelpers.core.hookenv import (
|
|||
relation_ids,
|
||||
related_units,
|
||||
relation_set,
|
||||
unit_get,
|
||||
unit_private_ip,
|
||||
charm_name,
|
||||
DEBUG,
|
||||
|
@ -98,6 +97,7 @@ from charmhelpers.contrib.openstack.ip import (
|
|||
ADMIN,
|
||||
PUBLIC,
|
||||
ADDRESS_MAP,
|
||||
local_address,
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_address_in_network,
|
||||
|
@ -247,7 +247,7 @@ class SharedDBContext(OSContextGenerator):
|
|||
hostname_key = "hostname"
|
||||
access_hostname = get_address_in_network(
|
||||
access_network,
|
||||
unit_get('private-address'))
|
||||
local_address(unit_get_fallback='private-address'))
|
||||
set_hostname = relation_get(attribute=hostname_key,
|
||||
unit=local_unit())
|
||||
if set_hostname != access_hostname:
|
||||
|
@ -1088,7 +1088,7 @@ class ApacheSSLContext(OSContextGenerator):
|
|||
# NOTE(jamespage): Fallback must always be private address
|
||||
# as this is used to bind services on the
|
||||
# local unit.
|
||||
fallback = unit_get("private-address")
|
||||
fallback = local_address(unit_get_fallback="private-address")
|
||||
if net_config:
|
||||
addr = get_address_in_network(net_config,
|
||||
fallback)
|
||||
|
@ -1260,7 +1260,7 @@ class NeutronContext(OSContextGenerator):
|
|||
if is_clustered():
|
||||
host = config('vip')
|
||||
else:
|
||||
host = unit_get('private-address')
|
||||
host = local_address(unit_get_fallback='private-address')
|
||||
|
||||
ctxt = {'network_manager': self.network_manager,
|
||||
'neutron_url': '%s://%s:%s' % (proto, host, '9696')}
|
||||
|
|
|
@ -123,6 +123,25 @@ def _get_address_override(endpoint_type=PUBLIC):
|
|||
return addr_override.format(service_name=service_name())
|
||||
|
||||
|
||||
def local_address(unit_get_fallback='public-address'):
|
||||
"""Return a network address for this unit.
|
||||
|
||||
Attempt to retrieve a 'default' IP address for this unit
|
||||
from network-get. If this is running with an old version of Juju then
|
||||
fallback to unit_get.
|
||||
|
||||
:param unit_get_fallback: Either 'public-address' or 'private-address'.
|
||||
Only used with old versions of Juju.
|
||||
:type unit_get_fallback: str
|
||||
:returns: IP Address
|
||||
:rtype: str
|
||||
"""
|
||||
try:
|
||||
return network_get_primary_address('juju-info')
|
||||
except NotImplementedError:
|
||||
return unit_get(unit_get_fallback)
|
||||
|
||||
|
||||
def resolve_address(endpoint_type=PUBLIC, override=True):
|
||||
"""Return unit address depending on net config.
|
||||
|
||||
|
@ -176,7 +195,7 @@ def resolve_address(endpoint_type=PUBLIC, override=True):
|
|||
if config('prefer-ipv6'):
|
||||
fallback_addr = get_ipv6_addr(exc_list=vips)[0]
|
||||
else:
|
||||
fallback_addr = unit_get(net_fallback)
|
||||
fallback_addr = local_address(unit_get_fallback=net_fallback)
|
||||
|
||||
if net_addr:
|
||||
resolved_address = get_address_in_network(net_addr, fallback_addr)
|
||||
|
|
|
@ -137,7 +137,6 @@ class NovaComputeContextTests(CharmTestCase):
|
|||
@mock.patch('charmhelpers.contrib.openstack.context.get_relation_ip')
|
||||
@mock.patch('charmhelpers.contrib.openstack.context.mkdir')
|
||||
@mock.patch.object(neutron, 'network_manager')
|
||||
@mock.patch('charmhelpers.contrib.openstack.context.unit_get')
|
||||
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
|
||||
@mock.patch('charmhelpers.contrib.openstack.context.kv')
|
||||
@mock.patch('charmhelpers.contrib.openstack.context.'
|
||||
|
@ -150,12 +149,11 @@ class NovaComputeContextTests(CharmTestCase):
|
|||
def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr,
|
||||
mock_local_unit, mock_get_netmask_for_address,
|
||||
mock_get_address_in_network, mock_kv, mock_https,
|
||||
mock_unit_get, mock_network_manager, mock_mkdir,
|
||||
mock_network_manager, mock_mkdir,
|
||||
mock_get_relation_ip, mock_config, mock_rids):
|
||||
self.os_release.return_value = 'ocata'
|
||||
mock_config.side_effect = self.test_config.get
|
||||
mock_https.return_value = False
|
||||
mock_unit_get.return_value = '127.0.0.1'
|
||||
mock_network_manager.return_value = 'neutron'
|
||||
mock_rids.return_value = []
|
||||
ctxt = context.HAProxyContext()()
|
||||
|
|
Loading…
Reference in New Issue