From 03ade964103d88af4d9a4f729d3bb00c12bff489 Mon Sep 17 00:00:00 2001 From: Leo Wang Date: Tue, 2 May 2017 16:50:02 -0700 Subject: local db support offline mode JIRA: DOVETAIL-415 The local db also need to support offline, move all the git clone/apt/yum/pip/wget/curl into the Dockerfile Change-Id: I2392dc9f4a6bd6f6a5a3f4849625a576c51a44f8 Signed-off-by: Leo Wang --- utils/init_db.py | 80 -------------------------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 utils/init_db.py (limited to 'utils/init_db.py') diff --git a/utils/init_db.py b/utils/init_db.py deleted file mode 100644 index 129c61f8..00000000 --- a/utils/init_db.py +++ /dev/null @@ -1,80 +0,0 @@ -############################################################################## -# 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 -import sys - -db_host_ip = sys.argv[1] -testapi_port = sys.argv[2] - -source_url = 'http://testresults.opnfv.org/test/api/v1' -target_url = 'http://{}:{}/api/v1'.format(db_host_ip, testapi_port) -print(target_url) - - -def get(url): - return requests.get(url).json() - - -def post(url, data): - headers = {'Content-Type': 'application/json'} - res = requests.post(url, data=json.dumps(data), headers=headers) - print(res.text) - - -def pod(): - source = '{}/pods'.format(source_url) - target = '{}/pods'.format(target_url) - - pods = get(source)['pods'] - for p in pods: - post(target, p) - - add_pod('master', 'metal') - add_pod('virtual_136_2', 'virtual') - - -def project(): - source = '{}/projects'.format(source_url) - target = '{}/projects'.format(target_url) - - projects = get(source)['projects'] - for p in projects: - post(target, p) - - -def cases(): - project_list = ['yardstick', 'functest', 'dovetail'] - - for p in project_list: - source = '{}/projects/{}/cases'.format(source_url, p) - target = '{}/projects/{}/cases'.format(target_url, p) - - cases = get(source)['testcases'] - for c in cases: - post(target, c) - - -def add_pod(name, mode): - data = { - "role": "", - "name": name, - "details": '', - "mode": mode, - "creation_date": "2017-2-23 11:23:03.765581" - } - pod_url = '{}/pods'.format(target_url) - post(pod_url, data) - - -if __name__ == '__main__': - pod() - project() - cases() -- cgit 1.2.3-korg