diff options
author | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 09:04:24 +0200 |
---|---|---|
committer | Jernej Jakob <jernej.jakob@gmail.com> | 2020-06-11 22:10:47 +0200 |
commit | 49eab6aaf392d631e041a99239407f953c2d5e64 (patch) | |
tree | 20492ffd1aa9c7c581158dd4349e93cd92616b1c /src/conf_mode/host_name.py | |
parent | 71e088fbb42dbbb899dfe73989c306609a9b1135 (diff) | |
download | vyos-1x-49eab6aaf392d631e041a99239407f953c2d5e64.tar.gz vyos-1x-49eab6aaf392d631e041a99239407f953c2d5e64.zip |
host_name: T2486: remove conf.exists calls
The getter methods will return empty values if config nodes don't exist,
so there's no point in checking if they exist before.
Diffstat (limited to 'src/conf_mode/host_name.py')
-rwxr-xr-x | src/conf_mode/host_name.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index 4652050ab..6cefab2fd 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -48,12 +48,12 @@ default_config_data = { def get_config(conf): hosts = copy.deepcopy(default_config_data) - if conf.exists("system host-name"): - hosts['hostname'] = conf.return_value("system host-name") - # This may happen if the config is not loaded yet, - # e.g. if run by cloud-init - if not hosts['hostname']: - hosts['hostname'] = default_config_data['hostname'] + hosts['hostname'] = conf.return_value("system host-name") + + # This may happen if the config is not loaded yet, + # e.g. if run by cloud-init + if not hosts['hostname']: + hosts['hostname'] = default_config_data['hostname'] if conf.exists("system domain-name"): hosts['domain_name'] = conf.return_value("system domain-name") @@ -62,8 +62,7 @@ def get_config(conf): for search in conf.return_values("system domain-search domain"): hosts['domain_search'].append(search) - if conf.exists("system name-server"): - hosts['nameserver'] = conf.return_values("system name-server") + hosts['nameserver'] = conf.return_values("system name-server") hosts['nameservers_dhcp_interfaces'] = conf.return_values("system name-servers-dhcp") |