summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ceilometerclient/client.py3
-rw-r--r--ceilometerclient/common/base.py16
-rw-r--r--ceilometerclient/common/utils.py3
-rw-r--r--ceilometerclient/tests/v2/test_alarms.py4
-rw-r--r--ceilometerclient/tests/v2/test_query_alarms.py2
-rw-r--r--ceilometerclient/tests/v2/test_query_samples.py2
-rw-r--r--ceilometerclient/tests/v2/test_shell.py67
-rw-r--r--ceilometerclient/v1/shell.py4
-rw-r--r--ceilometerclient/v2/alarms.py3
-rw-r--r--ceilometerclient/v2/options.py38
-rw-r--r--ceilometerclient/v2/shell.py72
-rw-r--r--requirements.txt4
-rw-r--r--tox.ini4
13 files changed, 113 insertions, 109 deletions
diff --git a/ceilometerclient/client.py b/ceilometerclient/client.py
index 9ee3742..c0a8be5 100644
--- a/ceilometerclient/client.py
+++ b/ceilometerclient/client.py
@@ -245,8 +245,7 @@ def _adjust_params(kwargs):
def get_client(version, **kwargs):
- """Get an authenticated client, based on the credentials
- in the keyword args.
+ """Get an authenticated client, based on the credentials in the kwargs.
:param api_version: the API version to use ('1' or '2')
:param kwargs: keyword args containing credentials, either:
diff --git a/ceilometerclient/common/base.py b/ceilometerclient/common/base.py
index 5e3fee7..7e8f80f 100644
--- a/ceilometerclient/common/base.py
+++ b/ceilometerclient/common/base.py
@@ -31,7 +31,9 @@ except NameError:
def getid(obj):
- """Abstracts the common pattern of allowing both an object or an
+ """Extracts object ID.
+
+ Abstracts the common pattern of allowing both an object or an
object's ID (UUID) as a parameter when dealing with relationships.
"""
try:
@@ -41,8 +43,10 @@ def getid(obj):
class Manager(object):
- """Managers interact with a particular type of API
- (samples, meters, alarms, etc.) and provide CRUD operations for them.
+ """Managers interact with a particular type of API.
+
+ It works with samples, meters, alarms, etc. and provide CRUD operations for
+ them.
"""
resource_class = None
@@ -91,8 +95,10 @@ class Manager(object):
class Resource(base.Resource):
- """A resource represents a particular instance of an object (tenant, user,
- etc). This is pretty much just a bag for attributes.
+ """A resource represents a particular instance of an object.
+
+ Resource might be tenant, user, etc.
+ This is pretty much just a bag for attributes.
:param manager: Manager object
:param info: dictionary representing resource attributes
diff --git a/ceilometerclient/common/utils.py b/ceilometerclient/common/utils.py
index bc9507b..b5bbe79 100644
--- a/ceilometerclient/common/utils.py
+++ b/ceilometerclient/common/utils.py
@@ -157,8 +157,7 @@ def args_array_to_dict(kwargs, key_to_convert):
def args_array_to_list_of_dicts(kwargs, key_to_convert):
- """Converts ['a=1;b=2','c=3;d=4'] to [{a:1,b:2},{c:3,d:4}]
- """
+ """Converts ['a=1;b=2','c=3;d=4'] to [{a:1,b:2},{c:3,d:4}]."""
values_to_convert = kwargs.get(key_to_convert)
if values_to_convert:
try:
diff --git a/ceilometerclient/tests/v2/test_alarms.py b/ceilometerclient/tests/v2/test_alarms.py
index 7f0d8bf..4239d2f 100644
--- a/ceilometerclient/tests/v2/test_alarms.py
+++ b/ceilometerclient/tests/v2/test_alarms.py
@@ -1,8 +1,6 @@
#
# Copyright 2013 Red Hat, Inc
#
-# Author: Eoghan Glynn <eglynn@redhat.com>
-#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@@ -30,6 +28,7 @@ AN_ALARM = {u'alarm_actions': [u'http://site:8000/alarm'],
u'ok_actions': [u'http://site:8000/ok'],
u'description': u'An alarm',
u'type': u'threshold',
+ u'severity': 'low',
u'threshold_rule': {
u'meter_name': u'storage.objects',
u'query': [{u'field': u'key_name',
@@ -109,6 +108,7 @@ AN_LEGACY_ALARM = {u'alarm_actions': [u'http://site:8000/alarm'],
u'period': 240.0,
u'alarm_id': u'alarm-id',
u'state': u'ok',
+ u'severity': u'low',
u'insufficient_data_actions': [u'http://site:8000/nodata'],
u'statistic': u'avg',
u'threshold': 200.0,
diff --git a/ceilometerclient/tests/v2/test_query_alarms.py b/ceilometerclient/tests/v2/test_query_alarms.py
index 7e7a108..7897ad1 100644
--- a/ceilometerclient/tests/v2/test_query_alarms.py
+++ b/ceilometerclient/tests/v2/test_query_alarms.py
@@ -1,7 +1,5 @@
# Copyright Ericsson AB 2014. All rights reserved
#
-# Author: Balazs Gibizer <balazs.gibizer@ericsson.com>
-#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
diff --git a/ceilometerclient/tests/v2/test_query_samples.py b/ceilometerclient/tests/v2/test_query_samples.py
index 7f6e7d9..e747717 100644
--- a/ceilometerclient/tests/v2/test_query_samples.py
+++ b/ceilometerclient/tests/v2/test_query_samples.py
@@ -1,7 +1,5 @@
# Copyright Ericsson AB 2014. All rights reserved
#
-# Author: Balazs Gibizer <balazs.gibizer@ericsson.com>
-#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
diff --git a/ceilometerclient/tests/v2/test_shell.py b/ceilometerclient/tests/v2/test_shell.py
index d14c8e5..65c8bb1 100644
--- a/ceilometerclient/tests/v2/test_shell.py
+++ b/ceilometerclient/tests/v2/test_shell.py
@@ -173,6 +173,7 @@ class ShellAlarmCommandTest(utils.BaseTestCase):
"timezone": ""}],
"alarm_id": ALARM_ID,
"state": "insufficient data",
+ "severity": "low",
"insufficient_data_actions": [],
"repeat_actions": True,
"user_id": "528d9b68fa774689834b5c04b4564f8a",
@@ -514,6 +515,7 @@ class ShellQueryAlarmsCommandTest(utils.BaseTestCase):
"project_id": "c96c887c216949acbdfbd8b494863567",
"repeat_actions": False,
"state": "ok",
+ "severity": "critical",
"state_timestamp": "2014-02-20T10:37:15.589860",
"threshold_rule": None,
"timestamp": "2014-02-20T10:37:15.589856",
@@ -544,21 +546,25 @@ class ShellQueryAlarmsCommandTest(utils.BaseTestCase):
ceilometer_shell.do_query_alarms(self.cc, self.args)
self.assertEqual('''\
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+--------------------------------+
-| Alarm ID | Name | State | Enabled \
-| Continuous | Alarm condition \
- | Time constraints |
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+--------------------------------+
-| 768ff714-8cfb-4db9-9753-d484cb33a1cc | SwiftObjectAlarm | ok | True \
-| False | combinated states (OR) of 739e99cb-c2ec-4718-b900-332502355f3\
-8, 153462d0-a9b8-4b5b-8175-9e4b05e9b856 | test at 0 23 * * * for 10800s |
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+--------------------------------+
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+-------------------------------\
+-+
+| Alarm ID | Name | State | Severity \
+| Enabled | Continuous | Alarm condition \
+ | Time constraints \
+ |
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+--------------------------------+
+| 768ff714-8cfb-4db9-9753-d484cb33a1cc | SwiftObjectAlarm | ok | critical \
+| True | False | combinated states (OR) of \
+739e99cb-c2ec-4718-b900-332502355f38, 153462d0-a9b8-4b5b-8175-9e4b05e9b856 |\
+ test at 0 23 * * * for 10800s |
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+------------------------------\
+--+
''', sys.stdout.getvalue())
@mock.patch('sys.stdout', new=six.StringIO())
@@ -577,21 +583,22 @@ class ShellQueryAlarmsCommandTest(utils.BaseTestCase):
ceilometer_shell.do_query_alarms(self.cc, self.args)
self.assertEqual('''\
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+------------------+
-| Alarm ID | Name | State | Enabled \
-| Continuous | Alarm condition \
- | Time constraints |
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+------------------+
-| 768ff714-8cfb-4db9-9753-d484cb33a1cc | SwiftObjectAlarm | ok | True \
-| False | combinated states (OR) of 739e99cb-c2ec-4718-b900-332502355f3\
-8, 153462d0-a9b8-4b5b-8175-9e4b05e9b856 | None |
-+--------------------------------------+------------------+-------+---------\
-+------------+--------------------------------------------------------------\
-----------------------------------------+------------------+
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+------------------+
+| Alarm ID | Name | State | Severity \
+| Enabled | Continuous | Alarm condition \
+ | Time constraints |
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+------------------+
+| 768ff714-8cfb-4db9-9753-d484cb33a1cc | SwiftObjectAlarm | ok | critical \
+| True | False | combinated states (OR) of \
+739e99cb-c2ec-4718-b900-332502355f38, 153462d0-a9b8-4b5b-8175-9e4b05e9b856 \
+| None |
++--------------------------------------+------------------+-------+----------+\
+---------+------------+-------------------------------------------------------\
+-----------------------------------------------+------------------+
''', sys.stdout.getvalue())
diff --git a/ceilometerclient/v1/shell.py b/ceilometerclient/v1/shell.py
index efb807f..395f2bc 100644
--- a/ceilometerclient/v1/shell.py
+++ b/ceilometerclient/v1/shell.py
@@ -108,7 +108,7 @@ def do_user_list(cc, args={}):
help='ISO date in UTC which limits resouces by '
'last update time <= this value')
def do_resource_list(cc, args={}):
- '''List the resources.'''
+ """List the resources."""
kwargs = {'source': args.source,
'user_id': args.user_id,
'project_id': args.project_id,
@@ -126,7 +126,7 @@ def do_resource_list(cc, args={}):
@utils.arg('-s', '--source', metavar='<SOURCE>',
help='ID of the resource to show projects for.')
def do_project_list(cc, args={}):
- '''List the projects.'''
+ """List the projects."""
kwargs = {'source': args.source}
projects = cc.projects.list(**kwargs)
diff --git a/ceilometerclient/v2/alarms.py b/ceilometerclient/v2/alarms.py
index 694b5c0..238fe41 100644
--- a/ceilometerclient/v2/alarms.py
+++ b/ceilometerclient/v2/alarms.py
@@ -1,8 +1,6 @@
#
# Copyright 2013 Red Hat, Inc
#
-# Author: Eoghan Glynn <eglynn@redhat.com>
-#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@@ -28,6 +26,7 @@ UPDATABLE_ATTRIBUTES = [
'description',
'type',
'state',
+ 'severity',
'enabled',
'alarm_actions',
'ok_actions',
diff --git a/ceilometerclient/v2/options.py b/ceilometerclient/v2/options.py
index e16013c..bf80ce5 100644
--- a/ceilometerclient/v2/options.py
+++ b/ceilometerclient/v2/options.py
@@ -29,18 +29,19 @@ DATA_TYPE_RE = re.compile(r'^(string|integer|float|datetime|boolean)(::)(.+)$')
def build_url(path, q, params=None):
- '''This converts from a list of dicts and a list of params to
- what the rest api needs, so from:
- "[{field=this,op=le,value=34},
- {field=that,op=eq,value=foo,type=string}],
- ['foo=bar','sna=fu']"
+ """Convert list of dicts and a list of params to query url format.
+
+ This will convert the following:
+ "[{field=this,op=le,value=34},
+ {field=that,op=eq,value=foo,type=string}],
+ ['foo=bar','sna=fu']"
to:
- "?q.field=this&q.field=that&
- q.op=le&q.op=eq&
- q.type=&q.type=string&
- q.value=34&q.value=foo&
- foo=bar&sna=fu"
- '''
+ "?q.field=this&q.field=that&
+ q.op=le&q.op=eq&
+ q.type=&q.type=string&
+ q.value=34&q.value=foo&
+ foo=bar&sna=fu"
+ """
if q:
query_params = {'q.field': [],
'q.value': [],
@@ -67,13 +68,13 @@ def build_url(path, q, params=None):
def cli_to_array(cli_query):
- """This converts from the cli list of queries to what is required
- by the python api.
- so from:
- "this<=34;that=string::foo"
+ """Convert CLI list of queries to the Python API format.
+
+ This will convert the following:
+ "this<=34;that=string::foo"
to
- "[{field=this,op=le,value=34,type=''},
- {field=that,op=eq,value=foo,type=string}]"
+ "[{field=this,op=le,value=34,type=''},
+ {field=that,op=eq,value=foo,type=string}]"
"""
@@ -81,8 +82,7 @@ def cli_to_array(cli_query):
return None
def split_by_op(query):
- """Split a single query string to field, operator, value.
- """
+ """Split a single query string to field, operator, value."""
def _value_error(message):
raise ValueError('invalid query %(query)s: missing %(message)s' %
diff --git a/ceilometerclient/v2/shell.py b/ceilometerclient/v2/shell.py
index ada708b..d57c733 100644
--- a/ceilometerclient/v2/shell.py
+++ b/ceilometerclient/v2/shell.py
@@ -31,6 +31,7 @@ from ceilometerclient.v2 import options
ALARM_STATES = ['ok', 'alarm', 'insufficient data']
+ALARM_SEVERITY = ['low', 'moderate', 'critical']
ALARM_OPERATORS = ['lt', 'le', 'eq', 'ne', 'ge', 'gt']
ALARM_COMBINATION_OPERATORS = ['and', 'or']
STATISTICS = ['max', 'min', 'avg', 'sum', 'count']
@@ -80,7 +81,7 @@ def obsoleted_by(new_dest):
'Available aggregates are: '
'%s.' % ", ".join(AGGREGATES.keys())))
def do_statistics(cc, args):
- '''List the statistics for a meter.'''
+ """List the statistics for a meter."""
aggregates = []
for a in args.aggregate:
aggregates.append(dict(zip(('func', 'param'), a.split("<-"))))
@@ -128,7 +129,7 @@ def do_statistics(cc, args):
@utils.arg('-l', '--limit', metavar='<NUMBER>',
help='Maximum number of samples to return.')
def do_sample_list(cc, args):
- '''List the samples for a meter.'''
+ """List the samples for a meter."""
fields = {'meter_name': args.meter,
'q': options.cli_to_array(args.query),
'limit': args.limit}
@@ -167,7 +168,7 @@ def do_sample_list(cc, args):
@utils.arg('--timestamp', metavar='<TIMESTAMP>',
help='The sample timestamp.')
def do_sample_create(cc, args={}):
- '''Create a sample.'''
+ """Create a sample."""
arg_to_field_mapping = {'meter_name': 'counter_name',
'meter_unit': 'counter_unit',
'meter_type': 'counter_type',
@@ -194,7 +195,7 @@ def do_sample_create(cc, args={}):
help='key[op]data_type::value; list. data_type is optional, '
'but if supplied must be string, integer, float, or boolean.')
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))
field_labels = ['Name', 'Type', 'Unit', 'Resource ID', 'User ID',
'Project ID']
@@ -207,10 +208,10 @@ def do_meter_list(cc, args={}):
def _display_alarm_list(alarms, sortby=None):
# omit action initially to keep output width sane
# (can switch over to vertical formatting when available from CLIFF)
- field_labels = ['Alarm ID', 'Name', 'State', 'Enabled', 'Continuous',
- 'Alarm condition', 'Time constraints']
- fields = ['alarm_id', 'name', 'state', 'enabled', 'repeat_actions',
- 'rule', 'time_constraints']
+ field_labels = ['Alarm ID', 'Name', 'State', 'Severity', 'Enabled',
+ 'Continuous', 'Alarm condition', 'Time constraints']
+ fields = ['alarm_id', 'name', 'state', 'severity', 'enabled',
+ 'repeat_actions', 'rule', 'time_constraints']
utils.print_list(
alarms, fields, field_labels,
formatters={'rule': alarm_rule_formatter,
@@ -305,7 +306,7 @@ def alarm_change_detail_formatter(change):
help='key[op]data_type::value; list. data_type is optional, '
'but if supplied must be string, integer, float, or boolean.')
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))
_display_alarm_list(alarms, sortby=0)
@@ -331,9 +332,9 @@ def time_constraints_formatter_full(alarm):
def _display_alarm(alarm):
fields = ['name', 'description', 'type',
- 'state', 'enabled', 'alarm_id', 'user_id', 'project_id',
- 'alarm_actions', 'ok_actions', 'insufficient_data_actions',
- 'repeat_actions']
+ 'state', 'severity', 'enabled', 'alarm_id', 'user_id',
+ 'project_id', 'alarm_actions', 'ok_actions',
+ 'insufficient_data_actions', 'repeat_actions']
data = dict([(f, getattr(alarm, f, '')) for f in fields])
data.update(alarm.rule)
if alarm.type == 'threshold':
@@ -349,7 +350,7 @@ def _display_alarm(alarm):
@utils.arg('alarm_id', metavar='<ALARM_ID>', nargs='?',
action=NotEmptyAction, help='ID of the alarm to show.')
def do_alarm_show(cc, args={}):
- '''Show an alarm.'''
+ """Show an alarm."""
alarm = cc.alarms.get(args.alarm_id)
if alarm is None:
raise exc.CommandError('Alarm not found: %s' % args.alarm_id)
@@ -371,6 +372,9 @@ 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('--severity', metavar='<SEVERITY>',
+ help='Severity of the alarm, one of: '
+ + str(ALARM_SEVERITY))
@utils.arg('--enabled', type=strutils.bool_from_string,
metavar='{True|False}',
help='True if alarm evaluation/actioning is enabled.')
@@ -430,7 +434,7 @@ def common_alarm_arguments(create=False):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
def do_alarm_create(cc, args={}):
- '''Create a new alarm (Deprecated). Use alarm-threshold-create instead.'''
+ """Create a new alarm (Deprecated). Use alarm-threshold-create instead."""
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
fields = utils.args_array_to_list_of_dicts(fields, "time_constraints")
fields = utils.args_array_to_dict(fields, "matching_metadata")
@@ -468,7 +472,7 @@ def do_alarm_create(cc, args={}):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
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 = utils.args_array_to_list_of_dicts(fields, 'time_constraints')
fields = utils.key_with_slash_to_nested_dict(fields)
@@ -494,7 +498,7 @@ def do_alarm_threshold_create(cc, args={}):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
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 = utils.args_array_to_list_of_dicts(fields, 'time_constraints')
fields = utils.key_with_slash_to_nested_dict(fields)
@@ -535,7 +539,7 @@ def do_alarm_combination_create(cc, args={}):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
def do_alarm_update(cc, args={}):
- '''Update an existing alarm (Deprecated).'''
+ """Update an existing alarm (Deprecated)."""
fields = dict(filter(lambda x: not (x[1] is None), vars(args).items()))
fields = utils.args_array_to_list_of_dicts(fields, "time_constraints")
fields = utils.args_array_to_dict(fields, "matching_metadata")
@@ -586,7 +590,7 @@ def do_alarm_update(cc, args={}):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
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 = utils.args_array_to_list_of_dicts(fields, 'time_constraints')
fields = utils.key_with_slash_to_nested_dict(fields)
@@ -624,7 +628,7 @@ def do_alarm_threshold_update(cc, args={}):
help=('True if actions should be repeatedly notified '
'while alarm remains in target state.'))
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 = utils.args_array_to_list_of_dicts(fields, 'time_constraints')
fields = utils.key_with_slash_to_nested_dict(fields)
@@ -643,7 +647,7 @@ def do_alarm_combination_update(cc, args={}):
@utils.arg('alarm_id', metavar='<ALARM_ID>', nargs='?',
action=NotEmptyAction, help='ID of the alarm to delete.')
def do_alarm_delete(cc, args={}):
- '''Delete an alarm.'''
+ """Delete an alarm."""
try:
cc.alarms.delete(args.alarm_id)
except exc.HTTPNotFound:
@@ -659,7 +663,7 @@ def do_alarm_delete(cc, args={}):
help='State of the alarm, one of: ' + str(ALARM_STATES) +
'.')
def do_alarm_state_set(cc, args={}):
- '''Set the state of an alarm.'''
+ """Set the state of an alarm."""
try:
state = cc.alarms.set_state(args.alarm_id, args.state)
except exc.HTTPNotFound:
@@ -673,7 +677,7 @@ def do_alarm_state_set(cc, args={}):
@utils.arg('alarm_id', metavar='<ALARM_ID>', nargs='?',
action=NotEmptyAction, help='ID of the alarm state to show.')
def do_alarm_state_get(cc, args={}):
- '''Get the state of an alarm.'''
+ """Get the state of an alarm."""
try:
state = cc.alarms.get_state(args.alarm_id)
except exc.HTTPNotFound:
@@ -690,7 +694,7 @@ def do_alarm_state_get(cc, args={}):
help='key[op]data_type::value; list. data_type is optional, '
'but if supplied must be string, integer, float, or boolean.')
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,
q=options.cli_to_array(args.query))
try:
@@ -712,7 +716,7 @@ def do_alarm_history(cc, args={}):
help='key[op]data_type::value; list. data_type is optional, '
'but if supplied must be string, integer, float, or boolean.')
def do_resource_list(cc, args={}):
- '''List the resources.'''
+ """List the resources."""
resources = cc.resources.list(q=options.cli_to_array(args.query))
field_labels = ['Resource ID', 'Source', 'User ID', 'Project ID']
@@ -724,7 +728,7 @@ def do_resource_list(cc, args={}):
@utils.arg('resource_id', metavar='<RESOURCE_ID>',
action=NotEmptyAction, help='ID of the resource to show.')
def do_resource_show(cc, args={}):
- '''Show the resource.'''
+ """Show the resource."""
try:
resource = cc.resources.get(args.resource_id)
except exc.HTTPNotFound:
@@ -741,7 +745,7 @@ def do_resource_show(cc, args={}):
'but if supplied must be string, integer, float'
'or datetime.')
def do_event_list(cc, args={}):
- '''List events.'''
+ """List events."""
events = cc.events.list(q=options.cli_to_array(args.query))
field_labels = ['Message ID', 'Event Type', 'Generated', 'Traits']
fields = ['message_id', 'event_type', 'generated', 'traits']
@@ -756,7 +760,7 @@ def do_event_list(cc, args={}):
@utils.arg('message_id', metavar='<message_id>', action=NotEmptyAction,
help='The ID of the event. Should be a UUID.')
def do_event_show(cc, args={}):
- '''Show a particular event.'''
+ """Show a particular event."""
event = cc.events.get(args.message_id)
fields = ['event_type', 'generated', 'traits']
data = dict([(f, getattr(event, f, '')) for f in fields])
@@ -764,7 +768,7 @@ def do_event_show(cc, args={}):
def do_event_type_list(cc, args={}):
- '''List event types.'''
+ """List event types."""
event_types = cc.event_types.list()
utils.print_list(event_types, ['event_type'], ['Event Type'])
@@ -773,7 +777,7 @@ def do_event_type_list(cc, args={}):
help='Type of the event for which traits will be shown.',
required=True, action=NotEmptyAction)
def do_trait_description_list(cc, args={}):
- '''List trait info for an event type.'''
+ """List trait info for an event type."""
trait_descriptions = cc.trait_descriptions.list(args.event_type)
field_labels = ['Trait Name', 'Data Type']
fields = ['name', 'type']
@@ -787,9 +791,7 @@ def do_trait_description_list(cc, args={}):
help='The name of the trait to list.',
required=True, action=NotEmptyAction)
def do_trait_list(cc, args={}):
- '''List trait all traits with name <trait_name> for Event Type
- <event_type>.
- '''
+ """List all traits with name <trait_name> for Event Type <event_type>."""
traits = cc.traits.list(args.event_type, args.trait_name)
field_labels = ['Trait Name', 'Value', 'Data Type']
fields = ['name', 'value', 'type']
@@ -806,7 +808,7 @@ def do_trait_list(cc, args={}):
@utils.arg('-l', '--limit', metavar='<LIMIT>',
help='Maximum number of samples to return.')
def do_query_samples(cc, args):
- '''Query samples.'''
+ """Query samples."""
fields = {'filter': args.filter,
'orderby': args.orderby,
'limit': args.limit}
@@ -833,7 +835,7 @@ def do_query_samples(cc, args):
@utils.arg('-l', '--limit', metavar='<LIMIT>',
help='Maximum number of alarms to return.')
def do_query_alarms(cc, args):
- '''Query Alarms.'''
+ """Query Alarms."""
fields = {'filter': args.filter,
'orderby': args.orderby,
'limit': args.limit}
@@ -855,7 +857,7 @@ def do_query_alarms(cc, args):
@utils.arg('-l', '--limit', metavar='<LIMIT>',
help='Maximum number of alarm history items to return.')
def do_query_alarm_history(cc, args):
- '''Query Alarm History.'''
+ """Query Alarm History."""
fields = {'filter': args.filter,
'orderby': args.orderby,
'limit': args.limit}
diff --git a/requirements.txt b/requirements.txt
index ee4225a..1059fee 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,10 +4,10 @@
pbr>=0.6,!=0.7,<1.0
argparse
iso8601>=0.1.9
-oslo.i18n>=1.0.0 # Apache-2.0
+oslo.i18n>=1.3.0 # Apache-2.0
oslo.utils>=1.2.0 # Apache-2.0
PrettyTable>=0.7,<0.8
-python-keystoneclient>=0.11.1
+python-keystoneclient>=1.0.0
requests>=2.2.0,!=2.4.0
six>=1.7.0
stevedore>=1.1.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 5013166..ed2658f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -29,9 +29,5 @@ commands=
python setup.py build_sphinx
[flake8]
-# H405 multi line docstring summary not separated with an empty line
-# H904 Wrap long lines in parentheses instead of a backslash
-# H105 Don't use author tags
-ignore = H405,H904,H105
show-source = True
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools