summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorLeo Wang <grakiss.wanglei@huawei.com>2017-05-02 16:50:02 -0700
committerLeo Wang <grakiss.wanglei@huawei.com>2017-05-03 09:20:13 -0700
commit03ade964103d88af4d9a4f729d3bb00c12bff489 (patch)
treeb2397cd9c12bedbc9d45085046bf54b846aba56b /docker
parent3aeab49bb64c6c89da37f3d03f781aec85f39015 (diff)
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 <grakiss.wanglei@huawei.com>
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()