diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py index 44b225777..5535f0474 100644 --- a/ceilometer/api/controllers/v2.py +++ b/ceilometer/api/controllers/v2.py @@ -129,8 +129,7 @@ class Query(_Base): def _sanitize_query(q): - ''' - Check the query to see if: + '''Check the query to see if: 1) the request is comming from admin - then allow full visibility 2) non-admin - make sure that the query includes the requester's project. diff --git a/ceilometer/compute/virt/inspector.py b/ceilometer/compute/virt/inspector.py index 7e9aca085..04e6c35f4 100644 --- a/ceilometer/compute/virt/inspector.py +++ b/ceilometer/compute/virt/inspector.py @@ -113,14 +113,11 @@ class InstanceNotFoundException(InspectorException): class Inspector(object): def inspect_instances(self): - """ - List the instances on the current host. - """ + """List the instances on the current host. """ raise NotImplementedError() def inspect_cpus(self, instance_name): - """ - Inspect the CPU statistics for an instance. + """Inspect the CPU statistics for an instance. :param instance_name: the name of the target instance :return: the number of CPUs and cumulative CPU time @@ -128,8 +125,7 @@ class Inspector(object): raise NotImplementedError() def inspect_vnics(self, instance_name): - """ - Inspect the vNIC statistics for an instance. + """Inspect the vNIC statistics for an instance. :param instance_name: the name of the target instance :return: for each vNIC, the number of bytes & packets @@ -138,8 +134,7 @@ class Inspector(object): raise NotImplementedError() def inspect_disks(self, instance_name): - """ - Inspect the disk statistics for an instance. + """Inspect the disk statistics for an instance. :param instance_name: the name of the target instance :return: for each disk, the number of bytes & operations diff --git a/ceilometer/image/notifications.py b/ceilometer/image/notifications.py index baa46cb94..ce1c6bc4f 100644 --- a/ceilometer/image/notifications.py +++ b/ceilometer/image/notifications.py @@ -35,10 +35,7 @@ cfg.CONF.register_opts(OPTS) class ImageBase(plugin.NotificationBase): - """ - Listen for image.send notifications in order to mediate with - the metering framework. - """ + """Base class for image counting. """ @staticmethod def get_exchange_topics(conf): diff --git a/ceilometer/objectstore/swift_middleware.py b/ceilometer/objectstore/swift_middleware.py index b7447ec92..5d0e6feab 100644 --- a/ceilometer/objectstore/swift_middleware.py +++ b/ceilometer/objectstore/swift_middleware.py @@ -66,9 +66,7 @@ from ceilometer import transformer class CeilometerMiddleware(object): - """ - Ceilometer middleware used for counting requests. - """ + """Ceilometer middleware used for counting requests.""" def __init__(self, app, conf): self.app = app diff --git a/ceilometer/storage/impl_hbase.py b/ceilometer/storage/impl_hbase.py index 1a76c68af..d16f9e6e8 100644 --- a/ceilometer/storage/impl_hbase.py +++ b/ceilometer/storage/impl_hbase.py @@ -88,9 +88,7 @@ class Connection(base.Connection): """ def __init__(self, conf): - ''' - Hbase Connection Initialization - ''' + """Hbase Connection Initialization""" opts = self._parse_connection_url(conf.database.connection) opts['table_prefix'] = conf.table_prefix diff --git a/ceilometer/storage/models.py b/ceilometer/storage/models.py index 48d49a3a4..8a287e8ce 100644 --- a/ceilometer/storage/models.py +++ b/ceilometer/storage/models.py @@ -49,7 +49,8 @@ class Event(Model): Metrics will be derived from one or more Events. """ def __init__(self, event_name, generated, traits): - """ + """Create a new event. + :param event_name: Name of the event. :param generated: UTC time for when the event occured. :param traits: list of Traits on this Event. @@ -89,7 +90,8 @@ class Resource(Model): def __init__(self, resource_id, project_id, source, user_id, metadata, meter): - """ + """Create a new resource. + :param resource_id: UUID of the resource :param project_id: UUID of project owning the resource :param source: the identifier for the user/project id definition @@ -115,7 +117,8 @@ class ResourceMeter(Model): """ def __init__(self, counter_name, counter_type, counter_unit): - """ + """Create a new resource meter. + :param counter_name: the name of the counter updating the resource :param counter_type: one of gauge, delta, cumulative :param counter_unit: official units name for the sample data @@ -133,7 +136,8 @@ class Meter(Model): def __init__(self, name, type, unit, resource_id, project_id, source, user_id): - """ + """Create a new meter. + :param name: name of the meter :param type: type of the meter (guage, counter) :param unit: unit of the meter @@ -164,7 +168,8 @@ class Sample(Model): message_id, message_signature, ): - """ + """Create a new sample. + :param source: the identifier for the user/project id definition :param counter_name: the name of the measurement being taken :param counter_type: the type of the measurement @@ -201,7 +206,8 @@ class Statistics(Model): min, max, avg, sum, count, period, period_start, period_end, duration, duration_start, duration_end): - """ + """Create a new statistics object. + :param min: The smallest volume found :param max: The largest volume found :param avg: The average of all volumes found diff --git a/ceilometer/tests/api.py b/ceilometer/tests/api.py index c8fd67fe2..0b12d2de3 100644 --- a/ceilometer/tests/api.py +++ b/ceilometer/tests/api.py @@ -72,8 +72,7 @@ class TestBase(db_test_base.TestBase): class FunctionalTest(db_test_base.TestBase): - """ - Used for functional tests of Pecan controllers where you need to + """Used for functional tests of Pecan controllers where you need to test your literal application and its integration with the framework. """ diff --git a/tests/api/v2/test_alarm.py b/tests/api/v2/test_alarm.py index 22c0b6582..251022d96 100644 --- a/tests/api/v2/test_alarm.py +++ b/tests/api/v2/test_alarm.py @@ -133,10 +133,8 @@ class TestAlarms(FunctionalTest): self.assertEquals(alarm.name, json['name']) def test_put_alarm_wrong_field(self): - ''' - Note: wsme will ignore unknown fields so will - just not appear in the Alarm. - ''' + # Note: wsme will ignore unknown fields so will just not appear in + # the Alarm. json = { 'name': 'renamed_alarm', 'this_can_not_be_correct': 'ha', diff --git a/tests/api/v2/test_post_samples.py b/tests/api/v2/test_post_samples.py index 1b48551c8..7be9a01cf 100644 --- a/tests/api/v2/test_post_samples.py +++ b/tests/api/v2/test_post_samples.py @@ -61,9 +61,7 @@ class TestPostSamples(FunctionalTest): self.assertEquals(s1, data.json) def test_wrong_project_id(self): - ''' - do not accept cross posting samples to different projects - ''' + """Do not accept cross posting samples to different projects.""" s1 = [{'counter_name': 'my_counter_name', 'counter_type': 'gauge', 'counter_unit': 'instance', @@ -87,11 +85,10 @@ class TestPostSamples(FunctionalTest): self.assertEquals(data.status_int, 400) def test_multiple_samples(self): - ''' - send multiple samples. + """Send multiple samples. The usecase here is to reduce the chatter and send the counters at a slower cadence. - ''' + """ samples = [] stamps = [] for x in range(6): @@ -127,9 +124,7 @@ class TestPostSamples(FunctionalTest): self.assertEquals(v, data.json[x][k]) def test_missing_mandatory_fields(self): - ''' - do not accept posting samples with missing mandatory fields - ''' + """Do not accept posting samples with missing mandatory fields.""" s1 = [{'counter_name': 'my_counter_name', 'counter_type': 'gauge', 'counter_unit': 'instance', @@ -152,9 +147,7 @@ class TestPostSamples(FunctionalTest): self.assertEquals(data.status_int, 400) def test_multiple_sources(self): - ''' - do not accept a single post of mixed sources - ''' + """Do not accept a single post of mixed sources.""" s1 = [{'counter_name': 'my_counter_name', 'counter_type': 'gauge', 'counter_unit': 'instance', @@ -179,11 +172,9 @@ class TestPostSamples(FunctionalTest): self.assertEquals(data.status_int, 400) def test_multiple_samples_some_null_sources(self): - ''' - do accept a single post with some null sources + """Do accept a single post with some null sources this is a convience feature so you only have to set - one of the sample's source field. - ''' + one of the sample's source field.""" s1 = [{'counter_name': 'my_counter_name', 'counter_type': 'gauge', 'counter_unit': 'instance', diff --git a/tests/objectstore/test_swift_middleware.py b/tests/objectstore/test_swift_middleware.py index a3138d348..ec3e2630c 100644 --- a/tests/objectstore/test_swift_middleware.py +++ b/tests/objectstore/test_swift_middleware.py @@ -156,9 +156,7 @@ class TestSwiftMiddleware(base.TestCase): self.assertEqual(data.volume, 1) def test_bogus_request(self): - """ - test even for arbitrary request method, this will still work - """ + """Test even for arbitrary request method, this will still work.""" app = swift_middleware.CeilometerMiddleware(FakeApp(body=['']), {}) req = Request.blank('/1.0/account/container/obj', environ={'REQUEST_METHOD': 'BOGUS'}) diff --git a/tox.ini b/tox.ini index f47e2990d..14596484b 100644 --- a/tox.ini +++ b/tox.ini @@ -40,7 +40,7 @@ deps = -r{toxinidir}/requirements.txt commands = {posargs} [flake8] -ignore = E125,F403,H301,H302,H304,H306,H401,H402,H403,H404 +ignore = E125,F403,H301,H302,H304,H306,H401,H402,H403 builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,nova_tests show-source = True