Merge "Generalize the usage of _remove_null_params"

This commit is contained in:
Jenkins 2017-02-22 06:28:50 +00:00 committed by Gerrit Code Review
commit f51148d284
2 changed files with 6 additions and 5 deletions

View File

@ -422,6 +422,7 @@ class KillContainer(command.Command):
opts = {}
opts['id'] = parsed_args.container
opts['signal'] = parsed_args.signal
opts = _remove_null_parms(**opts)
try:
client.containers.kill(**opts)
print(_('Request to send kill signal to container %s has '

View File

@ -65,7 +65,7 @@ def _check_restart_policy(policy):
def _remove_null_parms(**kwargs):
new = {}
for (key, value) in kwargs.items():
if value:
if value is not None:
new[key] = value
return new
@ -348,6 +348,7 @@ def do_kill(cs, args):
opts = {}
opts['id'] = container
opts['signal'] = args.signal
opts = _remove_null_parms(**opts)
try:
cs.containers.kill(**opts)
print(
@ -461,10 +462,9 @@ def do_rename(cs, args):
def do_update(cs, args):
"""Updates one or more container attributes"""
opts = {}
if args.memory is not None:
opts['memory'] = args.memory
if args.cpu is not None:
opts['cpu'] = args.cpu
opts['memory'] = args.memory
opts['cpu'] = args.cpu
opts = _remove_null_parms(**opts)
if not opts:
raise exc.CommandError("You must update at least one property")
container = cs.containers.update(args.container, **opts)