-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment.py
executable file
·55 lines (46 loc) · 1.8 KB
/
deployment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# coding: utf-8
# In[41]:
import os, requests,json, time, copy
import logging
from subprocess import check_output
from sys import argv
from scripts.wait_for_healthy import wait_for
from scripts.create_subscriptions import create_subscriptions
class Deployment():
def options(self, parameter, orion_host,orion_port):
if (parameter == 'create'):
print("Starting containers...")
check_output("docker-compose up -d --build", shell=True)
wait_for("orion")
create_subscriptions(orion_host,orion_port)
wait_for("draco-1")
print("Ready")
elif (parameter == 'restart'):
print("Restarting containers...")
check_output("docker-compose up -d --build", shell=True)
wait_for("orion")
wait_for("draco-1")
print("Ready")
elif (parameter == 'stop'):
print("Stopping containers...")
check_output("docker-compose down", shell=True)
print("Finish")
print("Command to restart: ./deployment.sh restart")
elif (parameter == 'destroy'):
print("All the data will be deleted...")
check_output("docker-compose down -v", shell=True)
print("Finish")
else:
print("Incorrect usage of parameters")
print("usage: python ./deployment.py [create|restart|stop|destroy] orion_host orion_port")
if __name__ == "__main__":
init=Deployment()
if(len(argv)==4):
parameter = argv[1]
orion_host = argv[2]
orion_port = argv[3]
init.options(parameter,orion_host,orion_port)
else:
print("Incorrect number of parameters")
print("usage: python ./deployment.py [create|restart|stop|destroy] orion_host orion_port")