summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorSerena Feng <feng.xiaowei@zte.com.cn>2017-09-21 12:30:53 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-09-21 12:30:53 +0000
commit07e7865f1c3ca8c12bc6cd45befaa7bbacf489b6 (patch)
treefc27a42fcdb07478bec2c60d26b49d8fb781acb4 /utils
parent31056a7180802ecfcd3e8abb58e74911ef679642 (diff)
parent33a78118868411eb5671b213ff2f90df8de3ca9c (diff)
Merge "refactor one click deployment in testapi"
Diffstat (limited to 'utils')
-rw-r--r--utils/test/testapi/deployment/deploy.py40
-rw-r--r--utils/test/testapi/deployment/docker-compose.yml.template15
-rw-r--r--utils/test/testapi/opts/deploy.py55
3 files changed, 55 insertions, 55 deletions
diff --git a/utils/test/testapi/deployment/deploy.py b/utils/test/testapi/deployment/deploy.py
deleted file mode 100644
index 6433fa6b2..000000000
--- a/utils/test/testapi/deployment/deploy.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import argparse
-import os
-
-from jinja2 import Environment, FileSystemLoader
-
-env = Environment(loader=FileSystemLoader('./'))
-docker_compose_yml = './docker-compose.yml'
-docker_compose_template = './docker-compose.yml.template'
-
-
-def render_docker_compose(port, base_url):
- vars = {
- "expose_port": port,
- "base_url": base_url,
- }
- template = env.get_template(docker_compose_template)
- yml = template.render(vars=vars)
-
- with open(docker_compose_yml, 'w') as f:
- f.write(yml)
- f.close()
-
-
-def main(args):
- render_docker_compose(args.expose_port, args.base_url)
- os.system('docker-compose -f {} up -d'.format(docker_compose_yml))
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Backup MongoDBs')
- parser.add_argument('-p', '--expose-port',
- type=int,
- required=False,
- default=8000,
- help='testapi exposed port')
- parser.add_argument('-l', '--base-url',
- type=str,
- required=True,
- help='testapi exposed base-url')
- main(parser.parse_args())
diff --git a/utils/test/testapi/deployment/docker-compose.yml.template b/utils/test/testapi/deployment/docker-compose.yml.template
deleted file mode 100644
index cd684048e..000000000
--- a/utils/test/testapi/deployment/docker-compose.yml.template
+++ /dev/null
@@ -1,15 +0,0 @@
-version: '2'
-services:
- mongo:
- image: mongo:3.2.1
- container_name: opnfv-mongo
- testapi:
- image: opnfv/testapi:latest
- container_name: opnfv-testapi
- environment:
- - mongodb_url=mongodb://mongo:27017/
- - base_url={{ vars.base_url }}
- ports:
- - "{{ vars.expose_port }}:8000"
- links:
- - mongo
diff --git a/utils/test/testapi/opts/deploy.py b/utils/test/testapi/opts/deploy.py
new file mode 100644
index 000000000..f58690c5d
--- /dev/null
+++ b/utils/test/testapi/opts/deploy.py
@@ -0,0 +1,55 @@
+import argparse
+import os
+
+from jinja2 import Environment
+
+DOCKER_COMPOSE_FILE = './docker-compose.yml'
+DOCKER_COMPOSE_TEMPLATE = """
+version: '2'
+services:
+ mongo:
+ image: mongo:3.2.1
+ container_name: opnfv-mongo
+ testapi:
+ image: opnfv/testapi:latest
+ container_name: opnfv-testapi
+ environment:
+ - mongodb_url=mongodb://mongo:27017/
+ - base_url={{ vars.testapi_base_url }}
+ ports:
+ - "{{ vars.testapi_port }}:8000"
+ links:
+ - mongo
+"""
+
+
+def render_docker_compose(testapi_port, testapi_base_url):
+ vars = {
+ "testapi_port": testapi_port,
+ "testapi_base_url": testapi_base_url,
+ }
+
+ yml = Environment().from_string(DOCKER_COMPOSE_TEMPLATE).render(vars=vars)
+
+ with open(DOCKER_COMPOSE_FILE, 'w') as f:
+ f.write(yml)
+ f.close()
+
+
+def main(args):
+ render_docker_compose(args.testapi_port, args.testapi_base_url)
+ os.system('docker-compose -f {} up -d'.format(DOCKER_COMPOSE_FILE))
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Backup MongoDBs')
+ parser.add_argument('-tp', '--testapi-port',
+ type=int,
+ required=False,
+ default=8000,
+ help='testapi exposed port')
+ parser.add_argument('-tl', '--testapi-base-url',
+ type=str,
+ required=True,
+ help='testapi exposed base-url')
+ main(parser.parse_args())