From 49eab6aaf392d631e041a99239407f953c2d5e64 Mon Sep 17 00:00:00 2001
From: Jernej Jakob <jernej.jakob@gmail.com>
Date: Thu, 11 Jun 2020 09:04:24 +0200
Subject: 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.
---
 src/conf_mode/host_name.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

(limited to 'src/conf_mode')

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")
 
-- 
cgit v1.2.3