blob: 30501c8b1dfab73792f1630b84b6d49a664ebb56 [file] [log] [blame]
Tomasz Wrobel75573b02020-03-05 16:43:50 +01001import docker
2
3
4class CertClientManager:
5
6 def run_client_container(self, client_image, container_name, path_to_env, request_url, network):
7 client = docker.from_env()
8 environment = self.read_list_env_from_file(path_to_env)
9 environment.append("REQUEST_URL=" + request_url)
10 container = client.containers.run(image=client_image, name=container_name, detach=True, environment=environment,
11 network=network)
12 exitcode = container.wait()
13 return exitcode
14
15 def remove_client_container(self, container_name):
16 client = docker.from_env()
17 container = client.containers.get(container_name)
18 container.remove()
19
20 def read_list_env_from_file(self, path):
21 f = open(path, "r")
22 r_list = []
23 for line in f:
24 line = line.strip()
25 if line[0] != "#":
26 r_list.append(line)
27 return r_list