Add kingbird endpoint information to functest. 19/17219/6
authorDimitri Mazmanov <dimitri.mazmanov@ericsson.com>
Wed, 20 Jul 2016 11:42:30 +0000 (13:42 +0200)
committerDimitri Mazmanov <dimitri.mazmanov@ericsson.com>
Wed, 20 Jul 2016 11:51:01 +0000 (13:51 +0200)
The patch multihops to the fuel node and dynamically retrieves kingbird
endpoint information. It also resolves the controller ip instead of
using the hardcoded value from the config ONLY if the installer type is
Fuel.

Signed-off-by: Dimitri Mazmanov <dimitri.mazmanov@ericsson.com>
Change-Id: I5161df5df3da7283f6374efa6bd1108246c1095a

ci/config_functest.yaml
testcases/OpenStack/tempest/run_tempest.py

index d0460b5..ecfa79a 100644 (file)
@@ -145,7 +145,14 @@ ONOS:
         installer_master: '10.20.0.2'
         installer_master_username: 'root'
         installer_master_password: 'r00tme'
-
+multisite:
+    fuel_environment:
+        installer_username: 'root'
+        installer_password: 'r00tme'
+    compass_environment:
+        installer_username: 'root'
+        installer_password: 'root'
+        multisite_controller_ip: '10.1.0.50'
 promise:
     general:
         tenant_name: promise
index 452e1fd..d48dde6 100755 (executable)
@@ -27,7 +27,6 @@ import functest.utils.functest_utils as ft_utils
 import functest.utils.openstack_utils as os_utils
 import yaml
 
-
 modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing',
          'identity', 'image', 'network', 'object_storage', 'orchestration',
          'telemetry', 'volume', 'custom', 'defcore', 'feature_multisite']
@@ -57,7 +56,6 @@ logger = ft_logger.Logger("run_tempest").getLogger()
 
 REPO_PATH = os.environ['repos_dir'] + '/functest/'
 
-
 with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
     functest_yaml = yaml.safe_load(f)
 f.close()
@@ -120,7 +118,6 @@ def get_info(file_result):
 
 
 def create_tempest_resources():
-
     keystone_client = os_utils.get_keystone_client()
     neutron_client = os_utils.get_neutron_client()
     glance_client = os_utils.get_glance_client()
@@ -224,13 +221,61 @@ def configure_tempest_feature(deployment_dir, mode):
         config.set('service_available', 'kingbird', 'true')
         cmd = "openstack endpoint show kingbird | grep publicurl |\
                awk '{print $4}' | awk -F '/' '{print $3}'"
-        kingbird_endpoint_url = os.popen(cmd).read()
-        cmd = "openstack endpoint show kingbird | grep publicurl |\
-               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")
+            multisite_controller_ip = ft_utils.get_parameter_from_yaml(
+                "multisite." + installer_type +
+                "_environment.multisite_controller_ip")
+
+            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).reawd().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:
+        except Exception:
             logger.info('kingbird section exist')
         config.set('kingbird', 'endpoint_type', 'publicURL')
         config.set('kingbird', 'TIME_TO_SYNC', '20')