From 7c80a919d009666e64c231403a98b356628edfc6 Mon Sep 17 00:00:00 2001 From: grakiss Date: Mon, 7 Aug 2017 14:53:15 +0800 Subject: fix base_url for public url Change-Id: I171e9b0bce1891594bf7ef577809e73f05556810 Signed-off-by: grakiss --- dovetail/utils/local_db/get_db_schema.py | 61 ++++++++++++++++++++++++++++++++ dovetail/utils/local_db/launch_db.sh | 9 +++-- 2 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 dovetail/utils/local_db/get_db_schema.py diff --git a/dovetail/utils/local_db/get_db_schema.py b/dovetail/utils/local_db/get_db_schema.py new file mode 100644 index 00000000..1106355c --- /dev/null +++ b/dovetail/utils/local_db/get_db_schema.py @@ -0,0 +1,61 @@ +############################################################################## +# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# 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 requests +import json + + +source_url = 'http://116.66.187.136:9999/api/v1' + + +def get(url): + try: + ret = requests.get(url) + return ret.json() + except: + return None + + +def pod(): + source = '{}/pods'.format(source_url) + try: + pods = get(source)['pods'] + with open("pods.json", "w") as f: + f.write(json.dumps(pods, indent=4)) + except: + return + + +def project(): + source = '{}/projects'.format(source_url) + + try: + projects = get(source)['projects'] + with open("projects.json", "w") as f: + f.write(json.dumps(projects, indent=4)) + except: + return + + for p in projects: + source = '{}/projects/{}/cases'.format(source_url, p['name']) + print(p['name']) + print(source) + try: + cases = get(source) + with open("cases.json", "a+") as f: + f.write(json.dumps(cases)) + f.write('\n') + f.close() + except: + print("useless data") + + +if __name__ == '__main__': + pod() + project() diff --git a/dovetail/utils/local_db/launch_db.sh b/dovetail/utils/local_db/launch_db.sh index 38a97331..a7439b66 100755 --- a/dovetail/utils/local_db/launch_db.sh +++ b/dovetail/utils/local_db/launch_db.sh @@ -8,13 +8,14 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -if [ "$#" -ne 1 ]; then +if [ "$#" -ne 2 ]; then echo "Error: missing parameter! try again like this:" echo "" - echo "./launch_db.sh 192.168.115.2" + echo "./launch_db.sh 192.168.115.2 http://116.66.187.136:9999" echo "" echo "parameters:" echo " db_host_ip: your localhost ip address " + echo " base_url: your public url for website" echo "" exit 1 fi @@ -22,6 +23,8 @@ fi export mongodb_port=${mongodb_port:-"27017"} export testapi_port=${testapi_port:-"8000"} export db_host_ip=${db_host_ip:-"$1"} +export base_url=${base_url:-"$2"} + set -e @@ -76,7 +79,7 @@ fi # run testapi container echo "Step3: run ${container_name} container." -cmd="sudo docker run -itd -p ${testapi_port}:8000 --name ${container_name} -e mongodb_url=mongodb://${db_host_ip}:${mongodb_port}/ ${testapi_img}" +cmd="sudo docker run -itd -p ${testapi_port}:8000 --name ${container_name} -e mongodb_url=mongodb://${db_host_ip}:${mongodb_port}/ -e base_url=${base_url} ${testapi_img}" echo $cmd ${cmd} -- cgit 1.2.3-korg