From dcd38df7c2d69eca8da01cdf710d16ffcc18a0fd Mon Sep 17 00:00:00 2001 From: xudan Date: Tue, 31 Oct 2017 23:53:18 -0400 Subject: Get SUT's endpoint info Get the admin endpoints of all service. JIRA: DOVETAIL-546 Change-Id: Ie0ac3bc5b4eb0885046e207b73217994a4f0e358 Signed-off-by: xudan --- dovetail/run.py | 1 + dovetail/utils/dovetail_utils.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/dovetail/run.py b/dovetail/run.py index b7c78975..4778fa51 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -262,6 +262,7 @@ def main(*args, **kwargs): copy_userconfig_files(logger) copy_patch_files(logger) dt_utils.check_docker_version(logger) + dt_utils.get_openstack_endpoint(logger) validate_input(kwargs, dt_cfg.dovetail_config['validate_input'], logger) check_hosts_file(logger) configs = filter_config(kwargs, logger) diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py index 75f7356b..99d44484 100644 --- a/dovetail/utils/dovetail_utils.py +++ b/dovetail/utils/dovetail_utils.py @@ -297,3 +297,30 @@ def combine_files(file_path, result_file, logger=None): logger.exception("Failed to write file {}.".format(result_file)) return None return result_file + + +def get_openstack_endpoint(logger=None): + https_enabled = check_https_enabled(logger) + insecure_option = '' + insecure = os.getenv('OS_INSECURE',) + if https_enabled: + if insecure: + if insecure.lower() == "true": + insecure_option = ' --insecure ' + cmd = ("openstack {} endpoint list --interface admin -f json" + .format(insecure_option)) + ret, msg = exec_cmd(cmd, logger, verbose=False) + if ret != 0: + logger.error("Failed to get the endpoint info.") + return None + result_file = os.path.join(dt_cfg.dovetail_config['result_dir'], + 'endpoint_info.json') + try: + with open(result_file, 'w') as f: + f.write(msg) + logger.debug("Record all endpoint info into file {}." + .format(result_file)) + return result_file + except Exception: + logger.exception("Failed to write endpoint info into file.") + return None -- cgit 1.2.3-korg