diff options
author | Eddie Arrage <eddie.arrage@huawei.com> | 2018-02-05 14:11:25 -0800 |
---|---|---|
committer | Eddie Arrage <eddie.arrage@huawei.com> | 2018-02-05 20:12:22 -0800 |
commit | e57e40687c47c3a50ecaae43e153b2ca8981423c (patch) | |
tree | 5ed1c94f2fdf0be879e6958c914161bb4b7a8e39 | |
parent | 2b9b8e3340af8087ebdcc1e7f8b33fdff4304ec0 (diff) |
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 <eddie.arrage@huawei.com>
-rwxr-xr-x | dovetail/run.py | 19 |
1 files 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() |