From 63fa48bd836c8268e48108592987b63abdaef5d0 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 16 Feb 2019 15:31:28 +0100 Subject: hostname: additional test case fixes --- src/conf_mode/host_name.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index 4b6ce76b0..0f8d3b719 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -35,7 +35,6 @@ config_file_hosts = '/etc/hosts' config_file_resolv = '/etc/resolv.conf' config_tmpl_hosts = """ -### Autogenerated by host_name.py ### 127.0.0.1 localhost {{ hostname }}{% if domain_name %}.{{ domain_name }}{% endif %} # The following lines are desirable for IPv6 capable hosts @@ -85,7 +84,6 @@ default_config_data = { } def get_config(): - """Get configuration""" conf = Config() hosts = copy.deepcopy(default_config_data) @@ -102,8 +100,8 @@ def get_config(): return hosts def verify(config): - """Verify configuration""" - # check for invalid host + if config is None: + return None # pattern $VAR(@) "^[[:alnum:]][-.[:alnum:]]*[[:alnum:]]$" ; "invalid host name $VAR(@)" hostname_regex = re.compile("^[A-Za-z0-9][-.A-Za-z0-9]*[A-Za-z0-9]$") @@ -128,7 +126,6 @@ def verify(config): return None def generate(config): - """Generate configuration files""" if config is None: return None @@ -158,7 +155,9 @@ def generate(config): return None def apply(config): - """Apply configuration""" + if config is None: + return None + fqdn = config['hostname'] if config['domain_name']: fqdn += '.' + config['domain_name'] -- cgit v1.2.3