dual-stack ansible bootstrap

Change-Id: Id0ac553abdd8affbfa2fe18853e9100ae6aa5226
This commit is contained in:
Tara Subedi 2024-05-03 11:18:54 -04:00
parent 69e075e250
commit dff4e308ef
4 changed files with 26 additions and 7 deletions

View File

@ -64,9 +64,25 @@ def get_region_name():
return None
def get_oam_ip():
cmd = 'source /etc/platform/openrc && ' \
'(system addrpool-list --nowrap | awk \'$4 == "oam" { print $14 }\')'
def _get_primary_pool(network_type):
cmd = f'source /etc/platform/openrc && ' \
f'(system network-list --nowrap | awk \'$8 == "{network_type}" {{ print $12 }}\')'
sub = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = sub.communicate()
if sub.returncode == 0:
return stdout.decode('utf-8').rstrip('\n')
else:
LOG.error('Command failed:\n %s\n. %s\n%s\n'
% (cmd, stdout.decode('utf-8'), stderr.decode('utf-8')))
raise Exception(f'Cannot retrieve primary {network_type} pool.')
def get_primary_oam_ip():
primary_oam_pool = _get_primary_pool('oam')
cmd = f'source /etc/platform/openrc && ' \
f'(system addrpool-list --nowrap | awk \'$2 == "{primary_oam_pool}" {{ print $14 }}\')'
sub = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@ -137,7 +153,7 @@ def retrieve_certificate(certificate, namespace='deployment'):
def get_old_default_CN_by_cert(certificate):
"""Return the old default CN per certificate
"""
oam_ip = get_oam_ip()
oam_ip = get_primary_oam_ip()
default_CN_by_cert = {
'system-restapi-gui-certificate': oam_ip,
'system-registry-local-certificate': oam_ip,

View File

@ -170,8 +170,10 @@ class NetworkAddresspoolController(rest.RestController):
if utils.get_system_mode() == constants.SYSTEM_MODE_SIMPLEX \
and net_pool.network_type == constants.NETWORK_TYPE_OAM:
if address_name == f"{constants.CONTROLLER}-{net_pool.network_type}":
addr_intf.update({'interface_id':
hostname_dict[hostname].interface_id})
# To re-visit: is last hostname looked up intended here ?
if 'hostname' in locals():
addr_intf.update({'interface_id':
hostname_dict[hostname].interface_id})
# Check for address existent before creation
try:

View File

@ -126,6 +126,7 @@ def create_host_overrides(filename):
}
data.update(pool_data)
# TODO: support for dual-stack
elif pool.name == 'management':
pool_data = {'management_subnet': subnet,
'management_start_address': range_start,

View File

@ -2515,7 +2515,7 @@ MGMT_IPSEC_DISABLED = 'disabled'
# If True, makes outputs compatible with single stack versions of ansible-playbooks and stx-puppet.
# Shall be removed when the other projects are updated.
DUAL_STACK_COMPATIBILITY_MODE = True
DUAL_STACK_COMPATIBILITY_MODE = False
# certificate constants
VALIDITY = "Validity"