Generalize the usage of _remove_null_params
Make sure the parameter is None before removing it. This is for avoiding incorrect removal of xxx=False, xxx=[], etc. Related-Bug: #1658613 Change-Id: I08d868edbeb95fe545cdb5d1ceaea4f05f8a338b
This commit is contained in:
parent
0ec418dbe6
commit
b858466964
@ -403,6 +403,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 '
|
||||
|
@ -64,7 +64,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
|
||||
|
||||
@ -334,6 +334,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(
|
||||
@ -440,10 +441,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)
|
||||
|
Loading…
Reference in New Issue
Block a user