bugfix: manage unhomogeneous OS_AUTH_URL 47/29347/1
authorMorgan Richomme <morgan.richomme@orange.com>
Fri, 24 Feb 2017 09:55:05 +0000 (10:55 +0100)
committerMorgan Richomme <morgan.richomme@orange.com>
Fri, 24 Feb 2017 09:55:05 +0000 (10:55 +0100)
the installers may use different format for the URL
use regex to retrieve the IP and the port
then build properly the V2 URL

Change-Id: I731d634eceb8f828ff5a22b2f800ee51c06fc341
Signed-off-by: Morgan Richomme <morgan.richomme@orange.com>
promise/test/functest/run_tests.py

index dee1c31..40074a8 100644 (file)
 import argparse
 import json
 import os
+import re
 import subprocess
 import time
 
 import functest.utils.functest_logger as ft_logger
-import functest.utils.functest_utils as ft_utils
 import functest.utils.openstack_utils as os_utils
 from functest.utils.constants import CONST
 
@@ -58,8 +58,6 @@ logger = ft_logger.Logger("promise").getLogger()
 
 
 def main():
-    start_time = time.time()
-
     change_keystone_version = False
     os_auth = os.environ["OS_AUTH_URL"]
 
@@ -67,7 +65,15 @@ def main():
     # if keystone v3, for keystone v2
     if os_utils.is_keystone_v3():
         os.environ["OS_IDENTITY_API_VERSION"] = "2"
-        os.environ["OS_AUTH_URL"] = os.environ["OS_AUTH_URL"] + "/v2.0"
+        # the OS_AUTH_URL may have different format according to the installer
+        # apex: OS_AUTH_URL=http://192.168.37.17:5000/v2.0
+        # fuel: OS_AUTH_URL='http://192.168.0.2:5000/'
+        #       OS_AUTH_URL='http://192.168.10.2:5000/v3
+        match = re.findall(r'[0-9]+(?:\.[0-9]+){3}:[0-9]+',
+                           os.environ["OS_AUTH_URL"])
+        new_url = "http://" + match[0] + "/v2.0"
+
+        os.environ["OS_AUTH_URL"] = new_url
         change_keystone_version = True
         logger.info("Force Keystone v2")