add secondary address variable for public HAproxy config
This change adds the variable public_secondary_ip_address to platform::haproxy::params filled with the secondary OAM address pool floating address value, in a similar way that is done for the primary address pool. This will be used in HAproxy to bind the necessary L4 public ports to the secondary address. Test plan [PASS] Install and add a secondary pool via CLI and, then, after lock/unlock, check that all public endpoints (openstack endpoint list) are available in the primary and secondary addresses, on the following setups: - AIO-SX (prim:IPv4, sec:IPv6) - AIO-SX (prim:IPv6, sec:IPv4) - AIO-DX (prim:IPv4, sec:IPv6) with system-controller role - AIO-DX (prim:IPv6, sec:IPv4) with system-controller role [PASS] Access the public APIs on both protocols using curl. Story: 2011027 task: 49996 Change-Id: I1b79f4e462ab34ab2aa7187d92460202fa15ae7e Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
This commit is contained in:
parent
64021ed7da
commit
15ff90a905
|
@ -3726,7 +3726,7 @@ def get_primary_address_by_name(dbapi, db_address_name, networktype, raise_exc=F
|
|||
LOG.info(f"address {db_address_name} not found, returning")
|
||||
if raise_exc:
|
||||
raise exception.AddressNotFoundByName(name=db_address_name)
|
||||
return address
|
||||
return None
|
||||
|
||||
# if there is a single entry, return here
|
||||
if len(address) == 1:
|
||||
|
@ -3759,6 +3759,62 @@ def get_primary_address_by_name(dbapi, db_address_name, networktype, raise_exc=F
|
|||
return address
|
||||
|
||||
|
||||
def get_secondary_address_by_name(dbapi, db_address_name, networktype, raise_exc=False):
|
||||
"""Search address by database name to retrieve the relevant address from
|
||||
the secondary pool, if multipĺe entries for the same name are found, the
|
||||
query will use the network's pool_uuid to get the address family (IPv4 or
|
||||
IPv6) related to the secondary.
|
||||
|
||||
:param dbapi: the database api reference
|
||||
:param db_address_name: the address name in the database
|
||||
:param networktype: the network type
|
||||
:param raise_exc: raise AddressNotFoundByName instead of returning None
|
||||
|
||||
:return: the address object if found, None otherwise
|
||||
"""
|
||||
address = None
|
||||
secondary_pool = None
|
||||
|
||||
if not db_address_name or not networktype:
|
||||
LOG.err(f"no db_address_name={db_address_name} or networktype={networktype} provided")
|
||||
return address
|
||||
|
||||
try:
|
||||
networks = dbapi.networks_get_by_type(networktype)
|
||||
if networks and len(networks) == 1:
|
||||
net_pools = dbapi.network_addrpool_get_by_network_id(networks[0].id)
|
||||
if len(net_pools) == 2 and networks[0].pool_uuid:
|
||||
for net_pool in net_pools:
|
||||
if net_pool.address_pool_uuid != networks[0].pool_uuid:
|
||||
# this is the secondary
|
||||
secondary_pool = dbapi.address_pool_get(net_pool.address_pool_uuid)
|
||||
else:
|
||||
LOG.debug(f"network {networks[0].type},{networks[0].pool_uuid} have"
|
||||
f" {len(net_pools)} pools")
|
||||
else:
|
||||
LOG.debug(f"there should be only have one network obj for networktype={networktype}")
|
||||
|
||||
if secondary_pool:
|
||||
address = dbapi.address_get_by_name_and_family(db_address_name,
|
||||
secondary_pool.family)
|
||||
|
||||
except exception.AddressPoolNotFound:
|
||||
LOG.debug(f"cannot find address pool for name={db_address_name} with"
|
||||
f" network type={networktype}")
|
||||
pass
|
||||
except exception.AddressNotFoundByNameAndFamily:
|
||||
LOG.debug(f"cannot find secondary address for name={db_address_name} with"
|
||||
f" network type={networktype} and family={secondary_pool.family}")
|
||||
pass
|
||||
except Exception as ex:
|
||||
LOG.info(f"get_secondary_address_by_name general exception: {str(ex)}")
|
||||
pass
|
||||
|
||||
if not address and raise_exc:
|
||||
raise exception.AddressNotFoundByName(name=db_address_name)
|
||||
return address
|
||||
|
||||
|
||||
def update_config_file(config_filepath: str, values_to_update: list):
|
||||
"""Update a config file with the desired information
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ class BasePuppet(object):
|
|||
|
||||
def _get_address_by_name(self, name, networktype):
|
||||
"""
|
||||
Retrieve an address entry by name and scoped by network type
|
||||
Retrieve a primary address entry by name and scoped by network type
|
||||
"""
|
||||
addresses = self.context.setdefault('_address_names', {})
|
||||
address_name = utils.format_address_name(name, networktype)
|
||||
|
@ -179,7 +179,24 @@ class BasePuppet(object):
|
|||
address = utils.get_primary_address_by_name(self.dbapi,
|
||||
address_name,
|
||||
networktype, True)
|
||||
addresses[address_name] = address
|
||||
if address:
|
||||
addresses[address_name] = address
|
||||
|
||||
return address
|
||||
|
||||
def _get_secondary_address_by_name(self, name, networktype):
|
||||
"""
|
||||
Retrieve a secondary address entry by name and scoped by network type
|
||||
"""
|
||||
addresses = self.context.setdefault('_sec_address_names', {})
|
||||
address_name = utils.format_address_name(name, networktype)
|
||||
address = addresses.get(address_name)
|
||||
if address is None:
|
||||
address = utils.get_secondary_address_by_name(self.dbapi,
|
||||
address_name,
|
||||
networktype, True)
|
||||
if address:
|
||||
addresses[address_name] = address
|
||||
|
||||
return address
|
||||
|
||||
|
|
|
@ -321,6 +321,16 @@ class PlatformPuppet(base.BasePuppet):
|
|||
except exception.NotFound:
|
||||
pass
|
||||
|
||||
# add the secondary public address if exists
|
||||
try:
|
||||
sec_public_address = self._get_secondary_address_by_name(
|
||||
constants.CONTROLLER, constants.NETWORK_TYPE_OAM)
|
||||
if sec_public_address:
|
||||
config.update({'platform::haproxy::params::public_secondary_ip_address':
|
||||
sec_public_address.address})
|
||||
except exception.AddressNotFoundByName:
|
||||
pass
|
||||
|
||||
return config
|
||||
|
||||
def _get_sdn_config(self):
|
||||
|
|
Loading…
Reference in New Issue