mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
transmit signal argument to docker's client.kill()
This commit is contained in:
parent
fa4c1d74ea
commit
ee7542ed44
@ -775,12 +775,16 @@ def stop(container, timeout=10):
|
||||
return status
|
||||
|
||||
|
||||
def kill(container):
|
||||
def kill(container, signal=None):
|
||||
'''
|
||||
Kill a running container
|
||||
|
||||
container
|
||||
container id
|
||||
signal
|
||||
signal to send
|
||||
|
||||
.. versionadded:: Beryllium
|
||||
|
||||
CLI Example:
|
||||
|
||||
@ -793,11 +797,18 @@ def kill(container):
|
||||
try:
|
||||
dcontainer = _get_container_infos(container)['Id']
|
||||
if is_running(dcontainer):
|
||||
client.kill(dcontainer)
|
||||
client.kill(dcontainer, signal=signal)
|
||||
if signal:
|
||||
# no need to check if container is running
|
||||
# because some signals might not stop the container.
|
||||
_valid(status,
|
||||
comment='Kill signal {0!r} successfully'
|
||||
' sent to the container {1!r}'.format(signal, container),
|
||||
id_=container)
|
||||
else:
|
||||
if not is_running(dcontainer):
|
||||
_valid(status,
|
||||
comment='Container {0} was killed'.format(
|
||||
container),
|
||||
comment='Container {0} was killed'.format(container),
|
||||
id_=container)
|
||||
else:
|
||||
_invalid(status,
|
||||
|
Loading…
Reference in New Issue
Block a user