Validate all or no subnets use dns_nameservers

Follow up for https://review.opendev.org/667380

Adds a validation to ensure that dns_nameservers
are used for all subnets if used. If not subnets
defines dns_nameservers they all fall back to
use undercloud_nameservers which was has been the
default for some time.

Relates-Bug: #1834306
Change-Id: I1cc1d20f8e15d531fb94b02c8d1313888fc8964d
changes/96/668696/1
Harald Jensås 3 years ago
parent f1450b3ae8
commit a7dd7a6bbe
  1. 15
      tripleoclient/v1/undercloud_preflight.py

@ -462,6 +462,20 @@ def _validate_dnsnameservers(s):
raise FailedValidation(message)
def _check_all_or_no_subnets_use_dns_nameservers():
x = [CONF.get(s).get('dns_nameservers') for s in CONF.subnets]
if any(([len(y) == 0 for y in x])) and any(([len(y) > 0 for y in x])):
message = (_('Option dns_nameservers is defined for subnets: {0}. '
'Option dns_nameservers is also required for subnets: '
'{1}.').format(
', '.join([s for s in CONF.subnets if
CONF.get(s).get('dns_nameservers')]),
', '.join([s for s in CONF.subnets if
not CONF.get(s).get('dns_nameservers')])))
LOG.error(message)
raise FailedValidation(message)
def check(verbose_level, upgrade=False):
# Fetch configuration and use its log file param to add logging to a file
utils.load_config(CONF, constants.UNDERCLOUD_CONF_PATH)
@ -490,6 +504,7 @@ def check(verbose_level, upgrade=False):
_checking_status('Networking values')
_validate_value_formats()
_check_routed_networks_enabled_if_multiple_subnets_defined()
_check_all_or_no_subnets_use_dns_nameservers()
for subnet in CONF.subnets:
s = CONF.get(subnet)
_checking_status('Subnet "%s" is in CIDR' % subnet)

Loading…
Cancel
Save