summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-11-16 06:30:35 -0500
committerxudan <xudan16@huawei.com>2017-11-16 06:30:35 -0500
commit81ea24a3e8fca5a11191129e92ab1b9bc985759d (patch)
treed4249dd385885a684461ffb7431720a69119fe06
parentadedf4e0a6e405ead72f004047c9c06cb7f90496 (diff)
Remove redundant log when launch local DB
The script launch_db.sh will print "Already Exists" logs when the DB has been initialized by the data stored in JumpHost. Ignore this kind of logs because it won't affect the launch of the DB but it will confuse users. JIRA: DOVETAIL-557 Change-Id: I23616b10bbadc49888731e943d0a4ee4425045f5 Signed-off-by: xudan <xudan16@huawei.com>
-rw-r--r--dovetail/utils/local_db/init_db.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/dovetail/utils/local_db/init_db.py b/dovetail/utils/local_db/init_db.py
index 365927b..c67ef56 100644
--- a/dovetail/utils/local_db/init_db.py
+++ b/dovetail/utils/local_db/init_db.py
@@ -16,7 +16,6 @@ db_host_ip = sys.argv[1]
testapi_port = sys.argv[2]
target_url = 'http://{}:{}/api/v1'.format(db_host_ip, testapi_port)
-print(target_url)
dir_path = os.path.dirname(os.path.realpath(__file__))
@@ -27,7 +26,15 @@ def get(url):
def post(url, data):
headers = {'Content-Type': 'application/json'}
res = requests.post(url, data=json.dumps(data), headers=headers)
- print(res.text)
+ try:
+ status_code = vars(res)["status_code"]
+ if (status_code == 403 and "Already Exists" in vars(res)["_content"]) \
+ or status_code == 200:
+ return
+ else:
+ print(res.text)
+ except Exception as e:
+ print("Error: exception {}.".format(e))
def pod():
@@ -55,7 +62,6 @@ def cases():
for c in cases["testcases"]:
target = '{}/projects/{}/cases'.format(target_url,
c['project_name'])
- print(target)
post(target, c)
except:
print("useless data")