diff --git a/unit_tests/charm_tests/test_utils.py b/unit_tests/charm_tests/test_utils.py index a415360..280e2e2 100644 --- a/unit_tests/charm_tests/test_utils.py +++ b/unit_tests/charm_tests/test_utils.py @@ -30,15 +30,3 @@ class TestOpenStackBaseTest(unittest.TestCase): MyTestClass.setUpClass('foo', 'bar') _setUpClass.assert_called_with('foo', 'bar') - - -class TestUtils(unittest.TestCase): - - def test_format_addr(self): - self.assertEquals('1.2.3.4', test_utils.format_addr('1.2.3.4')) - self.assertEquals( - '[2001:db8::42]', test_utils.format_addr('2001:db8::42')) - with self.assertRaises(ValueError): - test_utils.format_addr('999.999.999.999') - with self.assertRaises(ValueError): - test_utils.format_addr('2001:db8::g') diff --git a/zaza/openstack/charm_tests/test_utils.py b/zaza/openstack/charm_tests/test_utils.py index 83595b0..2994629 100644 --- a/zaza/openstack/charm_tests/test_utils.py +++ b/zaza/openstack/charm_tests/test_utils.py @@ -14,7 +14,6 @@ """Module containing base class for implementing charm tests.""" import contextlib import logging -import ipaddress import subprocess import tenacity import unittest @@ -541,20 +540,3 @@ class OpenStackBaseTest(BaseCharmTest): instance_2 = self.retrieve_guest( '{}-ins-1'.format(self.RESOURCE_PREFIX)) return instance_1, instance_2 - - -def format_addr(addr): - """Validate and format IP address. - - :param addr: IPv6 or IPv4 address - :type addr: str - :returns: Address string, optionally encapsulated in brackets([]) - :rtype: str - :raises: ValueError - """ - ipaddr = ipaddress.ip_address(addr) - if isinstance(ipaddr, ipaddress.IPv6Address): - fmt = '[{}]' - else: - fmt = '{}' - return fmt.format(ipaddr) diff --git a/zaza/openstack/charm_tests/vault/utils.py b/zaza/openstack/charm_tests/vault/utils.py index a708d78..9814243 100644 --- a/zaza/openstack/charm_tests/vault/utils.py +++ b/zaza/openstack/charm_tests/vault/utils.py @@ -27,7 +27,7 @@ import yaml import collections import zaza.model -import zaza.openstack.charm_tests.test_utils as test_utils +import zaza.utilities.networking as network_utils AUTH_FILE = "vault_tests.yaml" CharmVaultClient = collections.namedtuple( @@ -102,7 +102,7 @@ def get_unit_api_url(ip): transport = 'http' if vault_config['ssl-cert']['value']: transport = 'https' - return '{}://{}:8200'.format(transport, test_utils.format_addr(ip)) + return '{}://{}:8200'.format(transport, network_utils.format_addr(ip)) def get_hvac_client(vault_url, cacert=None): diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 14c708c..34d7e7b 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -68,6 +68,8 @@ from zaza.openstack.utilities import ( exceptions, generic as generic_utils, ) +import zaza.utilities.networking as network_utils + CIRROS_RELEASE_URL = 'http://download.cirros-cloud.net/version/released' CIRROS_IMAGE_URL = 'http://download.cirros-cloud.net' @@ -1704,6 +1706,7 @@ def get_overcloud_auth(address=None, model_name=None): if not address: address = get_keystone_ip(model_name=model_name) + address = network_utils.format_addr(address) password = juju_utils.leader_get( 'keystone',