diff --git a/src/client/preconfig.py b/src/client/preconfig.py index 63c687d9..c854a051 100755 --- a/src/client/preconfig.py +++ b/src/client/preconfig.py @@ -203,6 +203,7 @@ def set_os_version(self): def preconfig(self): self.set_os_version() + #self.preconfig_verify_domain() self.preconfig_hosts_file() self.preconfig_unauthenticated_packages() self.preconfig_repos() @@ -243,6 +244,12 @@ def preconfig_hosts_file(self): self.verify_puppet_host() self.verify_setup_hostname() + def preconfig_verify_domain(self): + if self.domain == "": + log.error('Domain name is not configured. ' \ + 'All target nodes has to be setup with proper domain name') + raise RuntimeError('Domain name is not configured for (%s)' % self.ip) + def preconfig_unauthenticated_packages(self): apt_auth = r'APT::Get::AllowUnauthenticated \"true\"\;' status, output = self.exec_cmd('grep --quiet \"^%s\" /etc/apt/apt.conf' % apt_auth) diff --git a/src/client/testbed_parser.py b/src/client/testbed_parser.py index b838ec81..f884065b 100755 --- a/src/client/testbed_parser.py +++ b/src/client/testbed_parser.py @@ -10,6 +10,7 @@ import os import re import shutil +import socket import sys from tempfile import mkdtemp @@ -400,9 +401,17 @@ def __init__(self, testbed, cluster_id=None): self.set_host_ids() self.set_hosts() + def get_host_ip_from_hostid(self, host_id): + username, host_ip = host_id.split('@') + # Quick check for IPv4 address + if not re.match(r'^([\d]{1,3}\.){3}[\d]{1,3}$', host_ip.strip()): + log.debug('Retrieve IP address of host (%s)' % host_ip) + host_ip = socket.gethostbyname(host_ip) + return username, host_ip + def set_hosts(self): for host_id in self.host_ids: - username, host_ip = host_id.split('@') + username, host_ip = self.get_host_ip_from_hostid(host_id) password = self.passwords.get(host_id, None) if password is None: raise RuntimeError('No Password defined for Host ID (%s)' % host_id)