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

Change-Id: Icad25f951143c42609a26d7016f423a37f0c2f8e
Closes-Bug: 1536834
  • Loading branch information
npchandran committed Jan 22, 2016
1 parent f9647aa commit a9e2ada
Showing 1 changed file with 10 additions and 1 deletion.
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 a9e2ada

Please sign in to comment.