[d] Adding a target to doit to restart containers
This commit is contained in:
parent
0e42a12610
commit
c64ce844d1
1 changed files with 24 additions and 0 deletions
24
dodo.py
24
dodo.py
|
@ -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():
|
||||
'''clean everything there is to clean'''
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue