summaryrefslogtreecommitdiff
path: root/ceilometerclient
diff options
context:
space:
mode:
authorllg8212 <lilinguo@huawei.com>2014-01-22 11:22:24 +0800
committerllg8212 <lilinguo@huawei.com>2014-01-22 11:30:34 +0800
commit08eca91c65733edbfa4b76eadebbedaac1cb1573 (patch)
treecd2e82608b52d53d2e55e0ed28d19cb11231f2e4 /ceilometerclient
parent5ad00a7c91f7857c4b3b37d4c2038d9519b48cf8 (diff)
downloadpython-ceilometerclient-08eca91c65733edbfa4b76eadebbedaac1cb1573.tar.gz
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
Diffstat (limited to 'ceilometerclient')
-rw-r--r--ceilometerclient/common/utils.py4
-rw-r--r--ceilometerclient/v2/shell.py15
2 files changed, 8 insertions, 11 deletions
diff --git a/ceilometerclient/common/utils.py b/ceilometerclient/common/utils.py
index 4f532e5..3d7b0cd 100644
--- a/ceilometerclient/common/utils.py
+++ b/ceilometerclient/common/utils.py
@@ -133,10 +133,6 @@ def find_resource(manager, name_or_id):
raise exc.CommandError(msg)
-def string_to_bool(arg):
- return arg.strip().lower() in ('t', 'true', 'yes', '1')
-
-
def env(*vars, **kwargs):
"""Search for the first defined of possibly many env vars
diff --git a/ceilometerclient/v2/shell.py b/ceilometerclient/v2/shell.py
index 6d861aa..858c3d1 100644
--- a/ceilometerclient/v2/shell.py
+++ b/ceilometerclient/v2/shell.py
@@ -22,6 +22,7 @@ import six
from ceilometerclient.common import utils
from ceilometerclient import exc
+from ceilometerclient.openstack.common import strutils
from ceilometerclient.v2 import options
@@ -257,7 +258,7 @@ def common_alarm_arguments(create=False):
help='Free text description of the alarm')
@utils.arg('--state', metavar='<STATE>',
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}',
help='True if alarm evaluation/actioning is enabled')
@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) '
'additionally to the meter_name'))
@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,
help=('True if actions should be repeatedly notified '
'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, '
'but if supplied must be string, integer, float, or boolean')
@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,
help=('True if actions should be repeatedly notified '
'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(
ALARM_COMBINATION_OPERATORS))
@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,
help=('True if actions should be repeatedly notified '
'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) '
'additionally to the meter_name'))
@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 '
'while alarm remains in target state'))
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, '
'but if supplied must be string, integer, float, or boolean')
@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 '
'while alarm remains in target state'))
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(
ALARM_COMBINATION_OPERATORS))
@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 '
'while alarm remains in target state'))
def do_alarm_combination_update(cc, args={}):