summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2019-04-05 10:50:18 -0700
committerhagbard <vyosdev@derith.de>2019-04-05 10:51:44 -0700
commit99b2bfc74f30987d00384e384e8caa4fad28528b (patch)
tree7efeb52b99c49a043585a9c732b0e3252bbb1b3a
parent1406c6179e9ca406dc07f16e670072123b9be58f (diff)
downloadvyos-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-xsrc/conf_mode/host_name.py14
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' : {}}