crane/cprocess.py

32 lines
1.1 KiB
Python
Raw Normal View History

2022-10-18 14:14:53 -05:00
# TODO add file for containers that need to be started
2023-03-21 12:16:01 -05:00
2022-10-21 12:48:19 -05:00
def build_cont_list(obj, hypercare_containers):
2022-10-17 17:18:17 -05:00
cont_list = []
for i, c in enumerate(obj):
if c["State"].lower() != "running":
2023-01-09 23:27:11 -06:00
continue
if c["Names"][0].lstrip("/") in hypercare_containers:
cont_list.append(c)
2022-10-18 14:14:53 -05:00
return cont_list
2022-10-21 12:48:19 -05:00
def build_full_cont_list(obj, hypercare_containers):
cont_full_list = []
for i, c in enumerate(obj):
if c["Names"][0].lstrip("/") in hypercare_containers:
cont_full_list.append(c)
return cont_full_list
def process_cont_list(full_cont_list, start_cont_fn, req_obj, host, port, jwt, endpoint):
if full_cont_list:
for container in full_cont_list:
start_cont_fn(req_obj, host, port, jwt, endpoint, container["Id"])
2022-11-01 16:05:57 -05:00
return container["Names"][0].lstrip("/")
2022-10-21 12:48:19 -05:00
def process_cont_status(obj):
if not obj:
return -1 # Can't find the containter
for c in enumerate(obj):
if 'running' in c[1]["State"].lower():
return 0
if c[1]["State"] != 'running':
return 1