allow an empty string to unset options
For command `alarm update`, options like `--alarm-actions` cannot be unset. Update utils to allow user to pass in an empty string in command line to unset these values. Change-Id: Ib6c712d8ad1a69b16dfef83362c576e80223f5a2
This commit is contained in:
@@ -131,7 +131,14 @@ def dict_from_parsed_args(parsed_args, attrs):
|
|||||||
else:
|
else:
|
||||||
value = getattr(parsed_args, attr)
|
value = getattr(parsed_args, attr)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
d[attr] = value
|
if value == [""]:
|
||||||
|
# NOTE(jake): As options like --alarm-actions is an array,
|
||||||
|
# their value can be array with empty string if user set option
|
||||||
|
# to ''. In this case we set it to None here so that a None
|
||||||
|
# value gets sent to API.
|
||||||
|
d[attr] = None
|
||||||
|
else:
|
||||||
|
d[attr] = value
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user