diff --git a/test/utils.py b/test/utils.py index cbbd8d4..ceeef98 100755 --- a/test/utils.py +++ b/test/utils.py @@ -1,16 +1,18 @@ #!/usr/bin/python import subprocess import re def run_cmd(cmd): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate() return (stdout, stderr, p.returncode) def get_IP(): (stdout, stderr, returncode) = run_cmd(['hostname', '-i']) if returncode != 0: raise RuntimeError, "Failed to run hostname -i:\n" + stderr - # in case multiple IP addresses are returned, use only the first. - return re.sub(r'\s.*', '', stdout) + # in case multiple IP addresses are returned, use only the first + # and also strip '%' part possibly present with IPv6 address + ret = re.sub(r'\s.*', '', stdout) + return "::1" if '%' in ret else ret