summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdovetail/run.py19
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()