4 import sys, os, traceback
6 # Getting the Arguments. if argument are missing exit the script with exit 1
8 ms = sys.argv[1].lower()
9 action = sys.argv[2].lower()
10 script = os.path.basename(sys.argv[0])
12 print("Usage: %s <microservice> <action> for now only stop action is allowd" % \
13 (os.path.basename(sys.argv[0])))
16 ms=sys.argv[1].lower()
17 action=sys.argv[2].lower()
18 docker_host_ip=os.environ.get('DOCKER_HOST_IP', False)
20 if not docker_host_ip:
21 print('The DOCKER_HOST_IP env varibale is not defined, exiting!')
26 client = docker.DockerClient(base_url='tcp://%s:2376' % docker_host_ip)
28 for ms in client.containers.list():
29 if ms.name == sys.argv[1]:
33 print('Can\'t connect to docker API, Exiting!')
34 print(traceback.format_exc())
38 print('Stop the %s pod' % ms )
42 print ('Only stop commnad is allowed!, exiting!')