Improve help strings

The help strings where rather inconsistent in their usage
of '.' and capitalization. Now all strings end with a "." and
are capitalized.

This leads to output like:
--alarm_ids <ALARM IDS>
                        List of alarm id Required.

Note the missing period before "Required".

Change-Id: I5edf0d4584b7f01d941068818c9dd0d17043ffaa
This commit is contained in:
Andreas Jaeger
2014-01-31 17:23:43 +01:00
parent 16f67c1f2e
commit cdb8cfa855
2 changed files with 79 additions and 73 deletions

View File

@@ -56,11 +56,11 @@ class CeilometerShell(object):
default=bool(cliutils.env('CEILOMETERCLIENT_DEBUG') default=bool(cliutils.env('CEILOMETERCLIENT_DEBUG')
), ),
action='store_true', action='store_true',
help='Defaults to env[CEILOMETERCLIENT_DEBUG]') help='Defaults to env[CEILOMETERCLIENT_DEBUG].')
parser.add_argument('-v', '--verbose', parser.add_argument('-v', '--verbose',
default=False, action="store_true", default=False, action="store_true",
help="Print more verbose output") help="Print more verbose output.")
parser.add_argument('-k', '--insecure', parser.add_argument('-k', '--insecure',
default=False, default=False,
@@ -96,60 +96,60 @@ class CeilometerShell(object):
parser.add_argument('--timeout', parser.add_argument('--timeout',
default=600, default=600,
help='Number of seconds to wait for a response') help='Number of seconds to wait for a response.')
parser.add_argument('--os-username', parser.add_argument('--os-username',
default=cliutils.env('OS_USERNAME'), default=cliutils.env('OS_USERNAME'),
help='Defaults to env[OS_USERNAME]') help='Defaults to env[OS_USERNAME].')
parser.add_argument('--os_username', parser.add_argument('--os_username',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-password', parser.add_argument('--os-password',
default=cliutils.env('OS_PASSWORD'), default=cliutils.env('OS_PASSWORD'),
help='Defaults to env[OS_PASSWORD]') help='Defaults to env[OS_PASSWORD].')
parser.add_argument('--os_password', parser.add_argument('--os_password',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-tenant-id', parser.add_argument('--os-tenant-id',
default=cliutils.env('OS_TENANT_ID'), default=cliutils.env('OS_TENANT_ID'),
help='Defaults to env[OS_TENANT_ID]') help='Defaults to env[OS_TENANT_ID].')
parser.add_argument('--os_tenant_id', parser.add_argument('--os_tenant_id',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-tenant-name', parser.add_argument('--os-tenant-name',
default=cliutils.env('OS_TENANT_NAME'), default=cliutils.env('OS_TENANT_NAME'),
help='Defaults to env[OS_TENANT_NAME]') help='Defaults to env[OS_TENANT_NAME].')
parser.add_argument('--os_tenant_name', parser.add_argument('--os_tenant_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-auth-url', parser.add_argument('--os-auth-url',
default=cliutils.env('OS_AUTH_URL'), default=cliutils.env('OS_AUTH_URL'),
help='Defaults to env[OS_AUTH_URL]') help='Defaults to env[OS_AUTH_URL].')
parser.add_argument('--os_auth_url', parser.add_argument('--os_auth_url',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-region-name', parser.add_argument('--os-region-name',
default=cliutils.env('OS_REGION_NAME'), default=cliutils.env('OS_REGION_NAME'),
help='Defaults to env[OS_REGION_NAME]') help='Defaults to env[OS_REGION_NAME].')
parser.add_argument('--os_region_name', parser.add_argument('--os_region_name',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-auth-token', parser.add_argument('--os-auth-token',
default=cliutils.env('OS_AUTH_TOKEN'), default=cliutils.env('OS_AUTH_TOKEN'),
help='Defaults to env[OS_AUTH_TOKEN]') help='Defaults to env[OS_AUTH_TOKEN].')
parser.add_argument('--os_auth_token', parser.add_argument('--os_auth_token',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--ceilometer-url', parser.add_argument('--ceilometer-url',
default=cliutils.env('CEILOMETER_URL'), default=cliutils.env('CEILOMETER_URL'),
help='Defaults to env[CEILOMETER_URL]') help='Defaults to env[CEILOMETER_URL].')
parser.add_argument('--ceilometer_url', parser.add_argument('--ceilometer_url',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@@ -158,21 +158,21 @@ class CeilometerShell(object):
default=cliutils.env( default=cliutils.env(
'CEILOMETER_API_VERSION', default='2'), 'CEILOMETER_API_VERSION', default='2'),
help='Defaults to env[CEILOMETER_API_VERSION] ' help='Defaults to env[CEILOMETER_API_VERSION] '
'or 2') 'or 2.')
parser.add_argument('--ceilometer_api_version', parser.add_argument('--ceilometer_api_version',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-service-type', parser.add_argument('--os-service-type',
default=cliutils.env('OS_SERVICE_TYPE'), default=cliutils.env('OS_SERVICE_TYPE'),
help='Defaults to env[OS_SERVICE_TYPE]') help='Defaults to env[OS_SERVICE_TYPE].')
parser.add_argument('--os_service_type', parser.add_argument('--os_service_type',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
parser.add_argument('--os-endpoint-type', parser.add_argument('--os-endpoint-type',
default=cliutils.env('OS_ENDPOINT_TYPE'), default=cliutils.env('OS_ENDPOINT_TYPE'),
help='Defaults to env[OS_ENDPOINT_TYPE]') help='Defaults to env[OS_ENDPOINT_TYPE].')
parser.add_argument('--os_endpoint_type', parser.add_argument('--os_endpoint_type',
help=argparse.SUPPRESS) help=argparse.SUPPRESS)

View File

@@ -37,7 +37,7 @@ OPERATORS_STRING = dict(gt='>', ge='>=',
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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('-m', '--meter', metavar='<NAME>', required=True, @utils.arg('-m', '--meter', metavar='<NAME>', required=True,
help='Name of meter to show samples for.') help='Name of meter to show samples for.')
@utils.arg('-p', '--period', metavar='<PERIOD>', @utils.arg('-p', '--period', metavar='<PERIOD>',
@@ -69,7 +69,7 @@ def do_statistics(cc, args):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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('-m', '--meter', metavar='<NAME>', required=True, @utils.arg('-m', '--meter', metavar='<NAME>', required=True,
help='Name of meter to show samples for.') help='Name of meter to show samples for.')
@utils.arg('-l', '--limit', metavar='<NUMBER>', @utils.arg('-l', '--limit', metavar='<NUMBER>',
@@ -94,24 +94,24 @@ def do_sample_list(cc, args):
@utils.arg('--project-id', metavar='<PROJECT_ID>', @utils.arg('--project-id', metavar='<PROJECT_ID>',
help='Tenant to associate with sample ' help='Tenant to associate with sample '
'(only settable by admin users)') '(only settable by admin users).')
@utils.arg('--user-id', metavar='<USER_ID>', @utils.arg('--user-id', metavar='<USER_ID>',
help='User to associate with sample ' help='User to associate with sample '
'(only settable by admin users)') '(only settable by admin users).')
@utils.arg('-r', '--resource-id', metavar='<RESOURCE_ID>', required=True, @utils.arg('-r', '--resource-id', metavar='<RESOURCE_ID>', required=True,
help='ID of the resource.') help='ID of the resource.')
@utils.arg('-m', '--meter-name', metavar='<METER_NAME>', required=True, @utils.arg('-m', '--meter-name', metavar='<METER_NAME>', required=True,
help='the meter name') help='The meter name.')
@utils.arg('--meter-type', metavar='<METER_TYPE>', required=True, @utils.arg('--meter-type', metavar='<METER_TYPE>', required=True,
help='the meter type') help='The meter type.')
@utils.arg('--meter-unit', metavar='<METER_UNIT>', required=True, @utils.arg('--meter-unit', metavar='<METER_UNIT>', required=True,
help='the meter unit') help='The meter unit.')
@utils.arg('--sample-volume', metavar='<SAMPLE_VOLUME>', required=True, @utils.arg('--sample-volume', metavar='<SAMPLE_VOLUME>', required=True,
help='The sample volume') help='The sample volume.')
@utils.arg('--resource-metadata', metavar='<RESOURCE_METADATA>', @utils.arg('--resource-metadata', metavar='<RESOURCE_METADATA>',
help='resource metadata') help='Resource metadata.')
@utils.arg('--timestamp', metavar='<TIMESTAMP>', @utils.arg('--timestamp', metavar='<TIMESTAMP>',
help='the sample timestamp') help='The sample timestamp.')
def do_sample_create(cc, args={}): def do_sample_create(cc, args={}):
'''Create a sample.''' '''Create a sample.'''
arg_to_field_mapping = {'meter_name': 'counter_name', arg_to_field_mapping = {'meter_name': 'counter_name',
@@ -138,7 +138,7 @@ def do_sample_create(cc, args={}):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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.')
def do_meter_list(cc, args={}): def do_meter_list(cc, args={}):
'''List the user's meters.''' '''List the user's meters.'''
meters = cc.meters.list(q=options.cli_to_array(args.query)) meters = cc.meters.list(q=options.cli_to_array(args.query))
@@ -211,7 +211,7 @@ def alarm_change_detail_formatter(change):
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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.')
def do_alarm_list(cc, args={}): def do_alarm_list(cc, args={}):
'''List the user's alarms.''' '''List the user's alarms.'''
alarms = cc.alarms.list(q=options.cli_to_array(args.query)) alarms = cc.alarms.list(q=options.cli_to_array(args.query))
@@ -260,20 +260,20 @@ def do_alarm_show(cc, args={}):
def common_alarm_arguments(create=False): def common_alarm_arguments(create=False):
def _wrapper(func): def _wrapper(func):
@utils.arg('--name', metavar='<NAME>', required=create, @utils.arg('--name', metavar='<NAME>', required=create,
help='Name of the alarm (must be unique per tenant)') help='Name of the alarm (must be unique per tenant).')
@utils.arg('--project-id', metavar='<PROJECT_ID>', @utils.arg('--project-id', metavar='<PROJECT_ID>',
help='Tenant to associate with alarm ' help='Tenant to associate with alarm '
'(only settable by admin users)') '(only settable by admin users).')
@utils.arg('--user-id', metavar='<USER_ID>', @utils.arg('--user-id', metavar='<USER_ID>',
help='User to associate with alarm ' help='User to associate with alarm '
'(only settable by admin users)') '(only settable by admin users).')
@utils.arg('--description', metavar='<DESCRIPTION>', @utils.arg('--description', metavar='<DESCRIPTION>',
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=strutils.bool_from_string, @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',
metavar='<Webhook URL>', action='append', default=None, metavar='<Webhook URL>', action='append', default=None,
help=('URL to invoke when state transitions to alarm. ' help=('URL to invoke when state transitions to alarm. '
@@ -296,26 +296,27 @@ def common_alarm_arguments(create=False):
@common_alarm_arguments(create=True) @common_alarm_arguments(create=True)
@utils.arg('--period', type=int, metavar='<PERIOD>', @utils.arg('--period', type=int, metavar='<PERIOD>',
help='Length of each period (seconds) to evaluate over') help='Length of each period (seconds) to evaluate over.')
@utils.arg('--evaluation-periods', type=int, metavar='<COUNT>', @utils.arg('--evaluation-periods', type=int, metavar='<COUNT>',
help='Number of periods to evaluate over') help='Number of periods to evaluate over.')
@utils.arg('-m', '--meter-name', metavar='<METRIC>', required=True, @utils.arg('-m', '--meter-name', metavar='<METRIC>', required=True,
help='Metric to evaluate against') help='Metric to evaluate against.')
@utils.arg('--statistic', metavar='<STATISTIC>', @utils.arg('--statistic', metavar='<STATISTIC>',
help='Statistic to evaluate, one of: ' + str(STATISTICS)) help='Statistic to evaluate, one of: ' + str(STATISTICS) + '.')
@utils.arg('--comparison-operator', metavar='<OPERATOR>', @utils.arg('--comparison-operator', metavar='<OPERATOR>',
help='Operator to compare with, one of: ' + str(ALARM_OPERATORS)) help='Operator to compare with, one of: ' + str(ALARM_OPERATORS) +
'.')
@utils.arg('--threshold', type=float, metavar='<THRESHOLD>', required=True, @utils.arg('--threshold', type=float, metavar='<THRESHOLD>', required=True,
help='Threshold to evaluate against') help='Threshold to evaluate against.')
@utils.arg('--matching-metadata', dest='matching_metadata', @utils.arg('--matching-metadata', dest='matching_metadata',
metavar='<Matching Metadata>', action='append', default=None, metavar='<Matching Metadata>', action='append', default=None,
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=strutils.bool_from_string, 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.'))
def do_alarm_create(cc, args={}): def do_alarm_create(cc, args={}):
'''Create a new alarm (Deprecated).''' '''Create a new alarm (Deprecated).'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -327,31 +328,32 @@ def do_alarm_create(cc, args={}):
@common_alarm_arguments(create=True) @common_alarm_arguments(create=True)
@utils.arg('-m', '--meter-name', metavar='<METRIC>', required=True, @utils.arg('-m', '--meter-name', metavar='<METRIC>', required=True,
dest='threshold_rule/meter_name', dest='threshold_rule/meter_name',
help='Metric to evaluate against') help='Metric to evaluate against.')
@utils.arg('--period', type=int, metavar='<PERIOD>', @utils.arg('--period', type=int, metavar='<PERIOD>',
dest='threshold_rule/period', dest='threshold_rule/period',
help='Length of each period (seconds) to evaluate over') help='Length of each period (seconds) to evaluate over.')
@utils.arg('--evaluation-periods', type=int, metavar='<COUNT>', @utils.arg('--evaluation-periods', type=int, metavar='<COUNT>',
dest='threshold_rule/evaluation_periods', dest='threshold_rule/evaluation_periods',
help='Number of periods to evaluate over') help='Number of periods to evaluate over.')
@utils.arg('--statistic', metavar='<STATISTIC>', @utils.arg('--statistic', metavar='<STATISTIC>',
dest='threshold_rule/statistic', dest='threshold_rule/statistic',
help='Statistic to evaluate, one of: ' + str(STATISTICS)) help='Statistic to evaluate, one of: ' + str(STATISTICS) + '.')
@utils.arg('--comparison-operator', metavar='<OPERATOR>', @utils.arg('--comparison-operator', metavar='<OPERATOR>',
dest='threshold_rule/comparison_operator', dest='threshold_rule/comparison_operator',
help='Operator to compare with, one of: ' + str(ALARM_OPERATORS)) help='Operator to compare with, one of: ' + str(ALARM_OPERATORS) +
'.')
@utils.arg('--threshold', type=float, metavar='<THRESHOLD>', required=True, @utils.arg('--threshold', type=float, metavar='<THRESHOLD>', required=True,
dest='threshold_rule/threshold', dest='threshold_rule/threshold',
help='Threshold to evaluate against') help='Threshold to evaluate against.')
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
dest='threshold_rule/query', dest='threshold_rule/query',
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=strutils.bool_from_string, 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.'))
def do_alarm_threshold_create(cc, args={}): def do_alarm_threshold_create(cc, args={}):
'''Create a new alarm based on computed statistics.''' '''Create a new alarm based on computed statistics.'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -367,16 +369,16 @@ def do_alarm_threshold_create(cc, args={}):
@common_alarm_arguments(create=True) @common_alarm_arguments(create=True)
@utils.arg('--alarm_ids', action='append', metavar='<ALARM IDS>', @utils.arg('--alarm_ids', action='append', metavar='<ALARM IDS>',
required=True, dest='combination_rule/alarm_ids', required=True, dest='combination_rule/alarm_ids',
help='List of alarm id') help='List of alarm ids.')
@utils.arg('--operator', metavar='<OPERATOR>', @utils.arg('--operator', metavar='<OPERATOR>',
dest='combination_rule/operator', dest='combination_rule/operator',
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=strutils.bool_from_string, 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.'))
def do_alarm_combination_create(cc, args={}): def do_alarm_combination_create(cc, args={}):
'''Create a new alarm based on state of other alarms.''' '''Create a new alarm based on state of other alarms.'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -390,25 +392,26 @@ def do_alarm_combination_create(cc, args={}):
help='ID of the alarm to update.') help='ID of the alarm to update.')
@common_alarm_arguments() @common_alarm_arguments()
@utils.arg('--period', type=int, metavar='<PERIOD>', @utils.arg('--period', type=int, metavar='<PERIOD>',
help='Length of each period (seconds) to evaluate over') help='Length of each period (seconds) to evaluate over.')
@utils.arg('--evaluation-periods', type=int, metavar='<COUNT>', @utils.arg('--evaluation-periods', type=int, metavar='<COUNT>',
help='Number of periods to evaluate over') help='Number of periods to evaluate over.')
@utils.arg('-m', '--meter-name', metavar='<METRIC>', @utils.arg('-m', '--meter-name', metavar='<METRIC>',
help='Metric to evaluate against') help='Metric to evaluate against.')
@utils.arg('--statistic', metavar='<STATISTIC>', @utils.arg('--statistic', metavar='<STATISTIC>',
help='Statistic to evaluate, one of: ' + str(STATISTICS)) help='Statistic to evaluate, one of: ' + str(STATISTICS))
@utils.arg('--comparison-operator', metavar='<OPERATOR>', @utils.arg('--comparison-operator', metavar='<OPERATOR>',
help='Operator to compare with, one of: ' + str(ALARM_OPERATORS)) help='Operator to compare with, one of: ' + str(ALARM_OPERATORS) +
'.')
@utils.arg('--threshold', type=float, metavar='<THRESHOLD>', @utils.arg('--threshold', type=float, metavar='<THRESHOLD>',
help='Threshold to evaluate against') help='Threshold to evaluate against.')
@utils.arg('--matching-metadata', dest='matching_metadata', @utils.arg('--matching-metadata', dest='matching_metadata',
metavar='<Matching Metadata>', action='append', default=None, metavar='<Matching Metadata>', action='append', default=None,
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=strutils.bool_from_string, 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={}):
'''Update an existing alarm.''' '''Update an existing alarm.'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -426,29 +429,31 @@ def do_alarm_update(cc, args={}):
@common_alarm_arguments() @common_alarm_arguments()
@utils.arg('-m', '--meter-name', metavar='<METRIC>', @utils.arg('-m', '--meter-name', metavar='<METRIC>',
dest='threshold_rule/meter_name', dest='threshold_rule/meter_name',
help='Metric to evaluate against') help='Metric to evaluate against.')
@utils.arg('--period', type=int, metavar='<PERIOD>', @utils.arg('--period', type=int, metavar='<PERIOD>',
dest='threshold_rule/period', dest='threshold_rule/period',
help='Length of each period (seconds) to evaluate over') help='Length of each period (seconds) to evaluate over.')
@utils.arg('--evaluation-periods', type=int, metavar='<COUNT>', @utils.arg('--evaluation-periods', type=int, metavar='<COUNT>',
dest='threshold_rule/evaluation_periods', dest='threshold_rule/evaluation_periods',
help='Number of periods to evaluate over') help='Number of periods to evaluate over.')
@utils.arg('--statistic', metavar='<STATISTIC>', @utils.arg('--statistic', metavar='<STATISTIC>',
dest='threshold_rule/statistic', dest='threshold_rule/statistic',
help='Statistic to evaluate, one of: ' + str(STATISTICS)) help='Statistic to evaluate, one of: ' + str(STATISTICS) +
'.')
@utils.arg('--comparison-operator', metavar='<OPERATOR>', @utils.arg('--comparison-operator', metavar='<OPERATOR>',
dest='threshold_rule/comparison_operator', dest='threshold_rule/comparison_operator',
help='Operator to compare with, one of: ' + str(ALARM_OPERATORS)) help='Operator to compare with, one of: ' + str(ALARM_OPERATORS) +
'.')
@utils.arg('--threshold', type=float, metavar='<THRESHOLD>', @utils.arg('--threshold', type=float, metavar='<THRESHOLD>',
dest='threshold_rule/threshold', dest='threshold_rule/threshold',
help='Threshold to evaluate against') help='Threshold to evaluate against.')
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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=strutils.bool_from_string, 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={}):
'''Update an existing alarm based on computed statistics.''' '''Update an existing alarm based on computed statistics.'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -470,15 +475,15 @@ def do_alarm_threshold_update(cc, args={}):
@common_alarm_arguments() @common_alarm_arguments()
@utils.arg('--alarm_ids', action='append', metavar='<ALARM IDS>', @utils.arg('--alarm_ids', action='append', metavar='<ALARM IDS>',
dest='combination_rule/alarm_ids', dest='combination_rule/alarm_ids',
help='List of alarm id') help='List of alarm id.')
@utils.arg('--operator', metavar='<OPERATOR>', @utils.arg('--operator', metavar='<OPERATOR>',
dest='combination_rule/operator', dest='combination_rule/operator',
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=strutils.bool_from_string, 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={}):
'''Update an existing alarm based on state of other alarms.''' '''Update an existing alarm based on state of other alarms.'''
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items())) fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
@@ -505,7 +510,8 @@ def do_alarm_delete(cc, args={}):
@utils.arg('-a', '--alarm_id', metavar='<ALARM_ID>', required=True, @utils.arg('-a', '--alarm_id', metavar='<ALARM_ID>', required=True,
help='ID of the alarm state to set.') help='ID of the alarm state to set.')
@utils.arg('--state', metavar='<STATE>', required=True, @utils.arg('--state', metavar='<STATE>', required=True,
help='State of the alarm, one of: ' + str(ALARM_STATES)) help='State of the alarm, one of: ' + str(ALARM_STATES) +
'.')
def do_alarm_state_set(cc, args={}): def do_alarm_state_set(cc, args={}):
'''Set the state of an alarm.''' '''Set the state of an alarm.'''
try: try:
@@ -530,7 +536,7 @@ def do_alarm_state_get(cc, args={}):
help='ID of the alarm for which history is shown.') help='ID of the alarm for which history is shown.')
@utils.arg('-q', '--query', metavar='<QUERY>', @utils.arg('-q', '--query', metavar='<QUERY>',
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.')
def do_alarm_history(cc, args={}): def do_alarm_history(cc, args={}):
'''Display the change history of an alarm.''' '''Display the change history of an alarm.'''
kwargs = dict(alarm_id=args.alarm_id, kwargs = dict(alarm_id=args.alarm_id,
@@ -609,7 +615,7 @@ def do_event_type_list(cc, args={}):
@utils.arg('-e', '--event_type', metavar='<EVENT_TYPE>', @utils.arg('-e', '--event_type', metavar='<EVENT_TYPE>',
help='Type of the event for which traits will be shown', help='Type of the event for which traits will be shown.',
required=True) required=True)
def do_trait_description_list(cc, args={}): def do_trait_description_list(cc, args={}):
'''List trait info for an event type.''' '''List trait info for an event type.'''
@@ -620,10 +626,10 @@ def do_trait_description_list(cc, args={}):
@utils.arg('-e', '--event_type', metavar='<EVENT_TYPE>', @utils.arg('-e', '--event_type', metavar='<EVENT_TYPE>',
help='Type of the event for which traits will listed', help='Type of the event for which traits will listed.',
required=True) required=True)
@utils.arg('-t', '--trait_name', metavar='<TRAIT_NAME>', @utils.arg('-t', '--trait_name', metavar='<TRAIT_NAME>',
help='The name of the trait to list', help='The name of the trait to list.',
required=True) required=True)
def do_trait_list(cc, args={}): def do_trait_list(cc, args={}):
'''List trait all traits with name <trait_name> for Event Type '''List trait all traits with name <trait_name> for Event Type