[d] Adding a target to doit to restart containers

This commit is contained in:
Blallo 2018-09-20 23:43:23 +02:00
parent 0e42a12610
commit c64ce844d1

24
dodo.py
View file

@ -104,6 +104,30 @@ def task_up():
} }
def restart(*containers):
'''This actually restart the container(s).'''
srv = subprocess.check_output((COMPOSE + ' config --services').split())
services = srv.decode('utf-8').strip().split()
for container in containers:
if container not in services:
raise ValueError("%s is not among the services %r" % (container, services))
subprocess.check_call((COMPOSE + 'restart %s' % container).split())
return True
def task_restart(*containers):
'''Restarts a container specified via commandline.'''
return {
'params': [{'name': 'services',
'short': 's',
'long': 'service',
'type': list,
'default': [],
'help': "the list of services to be restarted"}],
'actions': [(restart, containers)],
}
def task__cleanall(): def task__cleanall():
'''clean everything there is to clean''' '''clean everything there is to clean'''
return { return {