Use Kingbird Bind host URL for Tempest
authorAshish Singh <ashishsingh2k8@gmail.com>
Mon, 8 Aug 2016 15:41:18 +0000 (21:11 +0530)
committerAshish Singh <ashishsingh2k8@gmail.com>
Mon, 8 Aug 2016 15:45:05 +0000 (21:15 +0530)
Earlier, there was external URL for accessing KB services
in tempest.conf which is not accessible from functest docker.

Use bind host URL for KB service to access from the docker.

Change-Id: I147ffc2cd9883a6913080f9e1ab245807e0ca707
Signed-off-by: ashish singh <ashishsingh2k8@gmail.com>
testcases/OpenStack/tempest/run_tempest.py

index d29b3f3..845c588 100755 (executable)
@@ -238,11 +238,55 @@ def configure_tempest_feature(deployment_dir, mode):
     if mode == 'feature_multisite':
         config.set('service_available', 'kingbird', 'true')
         cmd = "openstack endpoint show kingbird | grep publicurl |\
-               awk '{print $4}'"
-        kingbird_endpoint_details = "".join(os.popen(cmd).read().split())
-        kingbird_endpoint_url = kingbird_endpoint_details.rsplit('/', 1)[0] + \
-            '/'
-        kingbird_api_version = kingbird_endpoint_details.rsplit('/', 1)[1]
+               awk '{print $4}' | awk -F '/' '{print $4}'"
+        kingbird_api_version = os.popen(cmd).read()
+        if os.environ.get("INSTALLER_TYPE") == 'fuel':
+            # For MOS based setup, the service is accessible
+            # via bind host
+            kingbird_conf_path = "/etc/kingbird/kingbird.conf"
+            installer_type = os.getenv('INSTALLER_TYPE', 'Unknown')
+            installer_ip = os.getenv('INSTALLER_IP', 'Unknown')
+            installer_username = ft_utils.get_parameter_from_yaml(
+                "multisite." + installer_type +
+                "_environment.installer_username")
+            installer_password = ft_utils.get_parameter_from_yaml(
+                "multisite." + installer_type +
+                "_environment.installer_password")
+
+            ssh_options = "-o UserKnownHostsFile=/dev/null -o \
+                StrictHostKeyChecking=no"
+
+            # Get the controller IP from the fuel node
+            cmd = 'sshpass -p %s ssh 2>/dev/null %s %s@%s \
+                    \'fuel node --env 1| grep controller | grep "True\|  1" \
+                    | awk -F\| "{print \$5}"\'' % (installer_password,
+                                                   ssh_options,
+                                                   installer_username,
+                                                   installer_ip)
+            multisite_controller_ip = \
+                "".join(os.popen(cmd).read().split())
+
+            # Login to controller and get bind host details
+            cmd = 'sshpass -p %s ssh 2>/dev/null  %s %s@%s "ssh %s \\" \
+                grep -e "^bind_" %s  \\""' % (installer_password,
+                                              ssh_options,
+                                              installer_username,
+                                              installer_ip,
+                                              multisite_controller_ip,
+                                              kingbird_conf_path)
+            bind_details = os.popen(cmd).read()
+            bind_details = "".join(bind_details.split())
+            # Extract port number from the bind details
+            bind_port = re.findall(r"\D(\d{4})", bind_details)[0]
+            # Extract ip address from the bind details
+            bind_host = re.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}",
+                                   bind_details)[0]
+            kingbird_endpoint_url = "http://" + bind_host + ":" + bind_port + \
+                                    "/"
+        else:
+            cmd = "openstack endpoint show kingbird | grep publicurl |\
+                   awk '{print $4}' | awk -F '/' '{print $3}'"
+            kingbird_endpoint_url = os.popen(cmd).read()
         try:
             config.add_section("kingbird")
         except Exception: