From e57e40687c47c3a50ecaae43e153b2ca8981423c Mon Sep 17 00:00:00 2001 From: Eddie Arrage Date: Mon, 5 Feb 2018 14:11:25 -0800 Subject: Add default to --report CLI option - Try new license header to deal with anteater failure - Ability to specify 'default' as argument to --report, which fetches host IP automatically and forms URL with 8000 as testapi port - This should not break the previous behavior of report option, if default option not specified Change-Id: I1e05bb52cf4fc211c59796d4e763e2e04177b406 Signed-off-by: Eddie Arrage --- dovetail/run.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dovetail/run.py b/dovetail/run.py index e5154ad1..8b29fbab 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -1,11 +1,13 @@ #!/usr/bin/env python + +############################################################################## +# Copyright (c) 2017 grakiss.wanglei@huawei.com and others. # -# grakiss.wanglei@huawei.com # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 -# +############################################################################## import click @@ -123,10 +125,11 @@ def validate_input(input_dict, check_dict, logger): # for 'report' option report = input_dict['report'] if report: - if not (report.startswith("http") or report == "file"): - logger.error("Report type can't be {}, valid types are 'file' " - "and 'http'.".format(input_dict['report'])) - raise SystemExit(1) + if report != "default": + if not (report.startswith("http") or report == "file"): + logger.error("Report type can't be {}, valid types are 'file' " + "and 'http'.".format(input_dict['report'])) + raise SystemExit(1) def filter_config(input_dict, logger): @@ -273,6 +276,10 @@ def main(*args, **kwargs): if kwargs['report']: if(kwargs['report'].endswith('/')): kwargs['report'] = kwargs['report'][0:kwargs['report'].rfind('/')] + if(kwargs['report'] == "default"): + host_ip = os.popen( + "/sbin/ip route|awk '/default/ { print $3 }'").read().rstrip() + kwargs['report'] = "http://" + host_ip + ":8000/api/v1/results" dt_cfg.dovetail_config['report_dest'] = kwargs['report'] dt_cfg.update_cmds() -- cgit 1.2.3-korg