Validate all or no subnets use dns_nameservers

Follow up for

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
Harald Jensås 3 years ago
parent f1450b3ae8
commit a7dd7a6bbe
  1. 15

@ -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: '
', '.join([s for s in CONF.subnets if
', '.join([s for s in CONF.subnets if
not CONF.get(s).get('dns_nameservers')])))
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')
for subnet in CONF.subnets:
s = CONF.get(subnet)
_checking_status('Subnet "%s" is in CIDR' % subnet)