summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorhongbo tian <hongbo.tianhongbo@huawei.com>2017-05-03 17:27:38 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-05-03 17:27:38 +0000
commitbae197167f137c478f8bb3268d9e047a6b6839b6 (patch)
tree128579d90d3ac724c04c164ec3f8f7a028d56092 /docker
parentfdc6128e73f6fb109673a5b522f33879ca749554 (diff)
parent03ade964103d88af4d9a4f729d3bb00c12bff489 (diff)
Merge "local db support offline mode"
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile5
-rw-r--r--docker/get_db_schema.py61
2 files changed, 66 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 7b3d99ed..499624f8 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -40,3 +40,8 @@ RUN \
pip install -e .
WORKDIR ${REPOS_DIR}/dovetail
+
+# get db schema from opnfv sites
+RUN mkdir -p ${REPOS_DIR}/dovetail/utils/local_db
+ADD get_db_schema.py ${REPOS_DIR}/dovetail/utils/local_db
+RUN cd ${REPOS_DIR}/dovetail/utils/local_db && python get_db_schema.py
diff --git a/docker/get_db_schema.py b/docker/get_db_schema.py
new file mode 100644
index 00000000..9a9d10d4
--- /dev/null
+++ b/docker/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://testresults.opnfv.org/test/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()