Improve ceilometer alarm enabled input parameter validation

strict the input parameter of enabled in the command :
ceilometer alarm-threshold-update <alarm-id> --enabled {True|False}

This commit will improve the enabled value validation, if the input
value is invalid such as "abde" "enabled", error info will be returned.

Closes-Bug: #1531042
Change-Id: Ic553bc9ffa05a84575fc5626416c79fc84687bbe
This commit is contained in:
april
2016-01-05 18:01:14 +08:00
parent 6097b0ce2e
commit 7992c24da4

View File

@@ -464,7 +464,8 @@ def common_alarm_arguments(create=False):
@utils.arg('--severity', metavar='<SEVERITY>',
help='Severity of the alarm, one of: '
+ str(ALARM_SEVERITY))
@utils.arg('--enabled', type=strutils.bool_from_string,
@utils.arg('--enabled',
type=lambda v: strutils.bool_from_string(v, True),
metavar='{True|False}',
help='True if alarm evaluation/actioning is enabled.')
@utils.arg('--alarm-action', dest='alarm_actions',