Using common method 'bool_from_string' from oslo strutils
Using common method 'bool_from_string' from oslo strutils to replace utils.string_to_bool. partially implements blueprint common-client-library-2 Change-Id: I101eb89174ac229aa1025bc4aea8b1c0c5594705
This commit is contained in:
@@ -133,10 +133,6 @@ def find_resource(manager, name_or_id):
|
|||||||
raise exc.CommandError(msg)
|
raise exc.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
def string_to_bool(arg):
|
|
||||||
return arg.strip().lower() in ('t', 'true', 'yes', '1')
|
|
||||||
|
|
||||||
|
|
||||||
def env(*vars, **kwargs):
|
def env(*vars, **kwargs):
|
||||||
"""Search for the first defined of possibly many env vars
|
"""Search for the first defined of possibly many env vars
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import six
|
|||||||
|
|
||||||
from ceilometerclient.common import utils
|
from ceilometerclient.common import utils
|
||||||
from ceilometerclient import exc
|
from ceilometerclient import exc
|
||||||
|
from ceilometerclient.openstack.common import strutils
|
||||||
from ceilometerclient.v2 import options
|
from ceilometerclient.v2 import options
|
||||||
|
|
||||||
|
|
||||||
@@ -257,7 +258,7 @@ def common_alarm_arguments(create=False):
|
|||||||
help='Free text description of the alarm')
|
help='Free text description of the alarm')
|
||||||
@utils.arg('--state', metavar='<STATE>',
|
@utils.arg('--state', metavar='<STATE>',
|
||||||
help='State of the alarm, one of: ' + str(ALARM_STATES))
|
help='State of the alarm, one of: ' + str(ALARM_STATES))
|
||||||
@utils.arg('--enabled', type=utils.string_to_bool,
|
@utils.arg('--enabled', type=strutils.bool_from_string,
|
||||||
metavar='{True|False}',
|
metavar='{True|False}',
|
||||||
help='True if alarm evaluation/actioning is enabled')
|
help='True if alarm evaluation/actioning is enabled')
|
||||||
@utils.arg('--alarm-action', dest='alarm_actions',
|
@utils.arg('--alarm-action', dest='alarm_actions',
|
||||||
@@ -298,7 +299,7 @@ def common_alarm_arguments(create=False):
|
|||||||
help=('A meter should match this resource metadata (key=value) '
|
help=('A meter should match this resource metadata (key=value) '
|
||||||
'additionally to the meter_name'))
|
'additionally to the meter_name'))
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
default=False,
|
default=False,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
@@ -333,7 +334,7 @@ def do_alarm_create(cc, args={}):
|
|||||||
help='key[op]data_type::value; list. data_type is optional, '
|
help='key[op]data_type::value; list. data_type is optional, '
|
||||||
'but if supplied must be string, integer, float, or boolean')
|
'but if supplied must be string, integer, float, or boolean')
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
default=False,
|
default=False,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
@@ -358,7 +359,7 @@ def do_alarm_threshold_create(cc, args={}):
|
|||||||
help='Operator to compare with, one of: ' + str(
|
help='Operator to compare with, one of: ' + str(
|
||||||
ALARM_COMBINATION_OPERATORS))
|
ALARM_COMBINATION_OPERATORS))
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
default=False,
|
default=False,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
@@ -391,7 +392,7 @@ def do_alarm_combination_create(cc, args={}):
|
|||||||
help=('A meter should match this resource metadata (key=value) '
|
help=('A meter should match this resource metadata (key=value) '
|
||||||
'additionally to the meter_name'))
|
'additionally to the meter_name'))
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
def do_alarm_update(cc, args={}):
|
def do_alarm_update(cc, args={}):
|
||||||
@@ -431,7 +432,7 @@ def do_alarm_update(cc, args={}):
|
|||||||
help='key[op]data_type::value; list. data_type is optional, '
|
help='key[op]data_type::value; list. data_type is optional, '
|
||||||
'but if supplied must be string, integer, float, or boolean')
|
'but if supplied must be string, integer, float, or boolean')
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
def do_alarm_threshold_update(cc, args={}):
|
def do_alarm_threshold_update(cc, args={}):
|
||||||
@@ -461,7 +462,7 @@ def do_alarm_threshold_update(cc, args={}):
|
|||||||
help='Operator to compare with, one of: ' + str(
|
help='Operator to compare with, one of: ' + str(
|
||||||
ALARM_COMBINATION_OPERATORS))
|
ALARM_COMBINATION_OPERATORS))
|
||||||
@utils.arg('--repeat-actions', dest='repeat_actions',
|
@utils.arg('--repeat-actions', dest='repeat_actions',
|
||||||
metavar='{True|False}', type=utils.string_to_bool,
|
metavar='{True|False}', type=strutils.bool_from_string,
|
||||||
help=('True if actions should be repeatedly notified '
|
help=('True if actions should be repeatedly notified '
|
||||||
'while alarm remains in target state'))
|
'while alarm remains in target state'))
|
||||||
def do_alarm_combination_update(cc, args={}):
|
def do_alarm_combination_update(cc, args={}):
|
||||||
|
|||||||
Reference in New Issue
Block a user