diff --git a/instack_undercloud/undercloud.py b/instack_undercloud/undercloud.py index 2eac8ce27..461e582a8 100644 --- a/instack_undercloud/undercloud.py +++ b/instack_undercloud/undercloud.py @@ -41,6 +41,7 @@ import novaclient as nc from novaclient import client as novaclient from novaclient import exceptions from oslo_config import cfg +from oslo_utils import netutils import psutil import pystache import six @@ -668,6 +669,14 @@ def _check_ipv6_enabled(): return os.path.isfile('/proc/net/if_inet6') +def _wrap_ipv6(ip): + """Wrap a IP address in square brackets if IPv6 + """ + if netutils.is_valid_ipv6(ip): + return "[%s]" % ip + return ip + + def _check_sysctl(): """Check sysctl option availability @@ -1046,7 +1055,8 @@ class InstackEnvironment(dict): 'TRIPLEO_INSTALL_USER', 'TRIPLEO_UNDERCLOUD_CONF_FILE', 'TRIPLEO_UNDERCLOUD_PASSWORD_FILE', 'ENABLED_POWER_INTERFACES', - 'ENABLED_MANAGEMENT_INTERFACES', 'SYSCTL_SETTINGS'} + 'ENABLED_MANAGEMENT_INTERFACES', 'SYSCTL_SETTINGS', + 'LOCAL_IP_WRAPPED'} """The variables we calculate in _generate_environment call.""" PUPPET_KEYS = DYNAMIC_KEYS | {opt.name.upper() for _, group in list_opts() @@ -1193,6 +1203,7 @@ def _generate_environment(instack_root): instack_env['PUBLIC_INTERFACE_IP'] = instack_env['LOCAL_IP'] instack_env['LOCAL_IP'] = instack_env['LOCAL_IP'].split('/')[0] + instack_env['LOCAL_IP_WRAPPED'] = _wrap_ipv6(instack_env['LOCAL_IP']) if instack_env['UNDERCLOUD_SERVICE_CERTIFICATE']: instack_env['UNDERCLOUD_SERVICE_CERTIFICATE'] = os.path.abspath( instack_env['UNDERCLOUD_SERVICE_CERTIFICATE']) diff --git a/requirements.txt b/requirements.txt index 2a9195a31..bb32b05cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ python-novaclient>=9.1.0 # Apache-2.0 python-mistralclient>=3.1.0 # Apache-2.0 python-swiftclient>=3.2.0 # Apache-2.0 oslo.config!=4.3.0,!=4.4.0,>=4.0.0 # Apache-2.0 +oslo.utils>=3.20.0 # Apache-2.0 psutil>=3.2.2 # BSD netaddr!=0.7.16,>=0.7.13 # BSD netifaces>=0.10.4 # MIT diff --git a/templates/config.json.template b/templates/config.json.template index 9ab6f649d..1e108bf1e 100644 --- a/templates/config.json.template +++ b/templates/config.json.template @@ -9,6 +9,7 @@ "puppet-stack-config" ]}, "local-ip": "{{LOCAL_IP}}", + "local-ip-wrapped": "{{LOCAL_IP_WRAPPED}}", "masquerade_networks": ["{{MASQUERADE_NETWORK}}"], "service_certificate": "{{UNDERCLOUD_SERVICE_CERTIFICATE}}", "public_host": "{{UNDERCLOUD_PUBLIC_HOST}}",