Skip to content

Commit

Permalink
SMLITE: Fixing testbed_parser.py is bailing out, if hostname are spec…
Browse files Browse the repository at this point in the history
…ified with dns entry names

Convert Given host name to IP address

Closes-Bug: 1536834

SMLITE: preconfig script to halt if domain name is not configured

*including the fix but not enabling them for now

Partial-Bug: 1531614

Change-Id: I1f71c7995dedda3ea4881c50171ff0074f01c994
  • Loading branch information
npchandran committed Jan 23, 2016
1 parent 50a1391 commit 784e8af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/client/preconfig.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion src/client/testbed_parser.py
Expand Up @@ -10,6 +10,7 @@
import os
import re
import shutil
import socket
import sys
from tempfile import mkdtemp

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 784e8af

Please sign in to comment.