diff options
author | hagbard <vyosdev@derith.de> | 2019-04-05 10:50:18 -0700 |
---|---|---|
committer | hagbard <vyosdev@derith.de> | 2019-04-05 10:51:44 -0700 |
commit | 99b2bfc74f30987d00384e384e8caa4fad28528b (patch) | |
tree | 7efeb52b99c49a043585a9c732b0e3252bbb1b3a | |
parent | 1406c6179e9ca406dc07f16e670072123b9be58f (diff) | |
download | vyos-1x-99b2bfc74f30987d00384e384e8caa4fad28528b.tar.gz vyos-1x-99b2bfc74f30987d00384e384e8caa4fad28528b.zip |
T1264 - host_name.py improvements
- checks if a variable exists to avoid setting None on defined defaults
-rwxr-xr-x | src/conf_mode/host_name.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index 27e2d9170..b0972a8f1 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -110,17 +110,21 @@ def get_config(): conf = Config() hosts = copy.deepcopy(default_config_data) - hosts['hostname'] = conf.return_value("system host-name") - hosts['domain_name'] = conf.return_value("system domain-name") + if conf.exists("system host-name"): + hosts['hostname'] = conf.return_value("system host-name") - if hosts['domain_name']: + if conf.exists("system domain-name"): + hosts['domain_name'] = conf.return_value("system domain-name") hosts['domain_search'].append(hosts['domain_name']) for search in conf.return_values("system domain-search domain"): hosts['domain_search'].append(search) - hosts['nameserver'] = conf.return_values("system name-server") - hosts['no_dhcp_ns'] = conf.exists('system disable-dhcp-nameservers') + if conf.exists("system name-server"): + hosts['nameserver'] = conf.return_values("system name-server") + + if conf.exists("system disable-dhcp-nameservers"): + hosts['no_dhcp_ns'] = conf.exists('system disable-dhcp-nameservers') ## system static-host-mapping hosts['static_host_mapping'] = { 'hostnames' : {}} |