From: Dirk Mueller Date: Tue, 25 Jun 2013 14:24:08 +0000 (+0200) Subject: Fix and enable gating on H401 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a4817b30a423a68a8ca5f7251fce57f791012066;p=openstack-build%2Fcinder-build.git Fix and enable gating on H401 H401 docstring should not start with a space Change-Id: Iaf63af75b0534cae1bac3c931ef5f51f1644aec9 --- diff --git a/cinder/api/contrib/types_extra_specs.py b/cinder/api/contrib/types_extra_specs.py index c95e9f22b..0887c912f 100644 --- a/cinder/api/contrib/types_extra_specs.py +++ b/cinder/api/contrib/types_extra_specs.py @@ -51,7 +51,7 @@ class VolumeTypeExtraSpecTemplate(xmlutil.TemplateBuilder): class VolumeTypeExtraSpecsController(wsgi.Controller): - """ The volume type extra specs API controller for the OpenStack API """ + """The volume type extra specs API controller for the OpenStack API.""" def _get_extra_specs(self, context, type_id): extra_specs = db.volume_type_extra_specs_get(context, type_id) @@ -68,7 +68,7 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): @wsgi.serializers(xml=VolumeTypeExtraSpecsTemplate) def index(self, req, type_id): - """ Returns the list of extra specs for a given volume type """ + """Returns the list of extra specs for a given volume type.""" context = req.environ['cinder.context'] authorize(context) self._check_type(context, type_id) @@ -130,7 +130,7 @@ class VolumeTypeExtraSpecsController(wsgi.Controller): raise webob.exc.HTTPNotFound() def delete(self, req, type_id, id): - """ Deletes an existing extra spec """ + """Deletes an existing extra spec.""" context = req.environ['cinder.context'] self._check_type(context, type_id) authorize(context) diff --git a/cinder/api/contrib/volume_transfer.py b/cinder/api/contrib/volume_transfer.py index 970976b81..543ddbef0 100644 --- a/cinder/api/contrib/volume_transfer.py +++ b/cinder/api/contrib/volume_transfer.py @@ -97,7 +97,7 @@ class AcceptDeserializer(wsgi.MetadataXMLDeserializer): class VolumeTransferController(wsgi.Controller): - """ The Volume Transfer API controller for the Openstack API.""" + """The Volume Transfer API controller for the Openstack API.""" _view_builder_class = transfer_view.ViewBuilder diff --git a/cinder/api/v1/snapshot_metadata.py b/cinder/api/v1/snapshot_metadata.py index 6322204ff..32922c4b2 100644 --- a/cinder/api/v1/snapshot_metadata.py +++ b/cinder/api/v1/snapshot_metadata.py @@ -25,7 +25,7 @@ from webob import exc class Controller(object): - """ The volume metadata API controller for the OpenStack API """ + """The volume metadata API controller for the OpenStack API.""" def __init__(self): self.volume_api = volume.API() @@ -42,7 +42,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetadataTemplate) def index(self, req, snapshot_id): - """ Returns the list of metadata for a given snapshot""" + """Returns the list of metadata for a given snapshot.""" context = req.environ['cinder.context'] return {'metadata': self._get_metadata(context, snapshot_id)} @@ -131,7 +131,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetaItemTemplate) def show(self, req, snapshot_id, id): - """ Return a single metadata item """ + """Return a single metadata item.""" context = req.environ['cinder.context'] data = self._get_metadata(context, snapshot_id) @@ -142,7 +142,7 @@ class Controller(object): raise exc.HTTPNotFound(explanation=msg) def delete(self, req, snapshot_id, id): - """ Deletes an existing metadata """ + """Deletes an existing metadata.""" context = req.environ['cinder.context'] metadata = self._get_metadata(context, snapshot_id) diff --git a/cinder/api/v1/volume_metadata.py b/cinder/api/v1/volume_metadata.py index 4f6df75b6..7065dfa3f 100644 --- a/cinder/api/v1/volume_metadata.py +++ b/cinder/api/v1/volume_metadata.py @@ -25,7 +25,7 @@ from webob import exc class Controller(object): - """ The volume metadata API controller for the OpenStack API """ + """The volume metadata API controller for the OpenStack API.""" def __init__(self): self.volume_api = volume.API() @@ -42,7 +42,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetadataTemplate) def index(self, req, volume_id): - """ Returns the list of metadata for a given volume""" + """Returns the list of metadata for a given volume.""" context = req.environ['cinder.context'] return {'metadata': self._get_metadata(context, volume_id)} @@ -131,7 +131,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetaItemTemplate) def show(self, req, volume_id, id): - """ Return a single metadata item """ + """Return a single metadata item.""" context = req.environ['cinder.context'] data = self._get_metadata(context, volume_id) @@ -142,7 +142,7 @@ class Controller(object): raise exc.HTTPNotFound(explanation=msg) def delete(self, req, volume_id, id): - """ Deletes an existing metadata """ + """Deletes an existing metadata.""" context = req.environ['cinder.context'] metadata = self._get_metadata(context, volume_id) diff --git a/cinder/api/v2/snapshot_metadata.py b/cinder/api/v2/snapshot_metadata.py index 6322204ff..32922c4b2 100644 --- a/cinder/api/v2/snapshot_metadata.py +++ b/cinder/api/v2/snapshot_metadata.py @@ -25,7 +25,7 @@ from webob import exc class Controller(object): - """ The volume metadata API controller for the OpenStack API """ + """The volume metadata API controller for the OpenStack API.""" def __init__(self): self.volume_api = volume.API() @@ -42,7 +42,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetadataTemplate) def index(self, req, snapshot_id): - """ Returns the list of metadata for a given snapshot""" + """Returns the list of metadata for a given snapshot.""" context = req.environ['cinder.context'] return {'metadata': self._get_metadata(context, snapshot_id)} @@ -131,7 +131,7 @@ class Controller(object): @wsgi.serializers(xml=common.MetaItemTemplate) def show(self, req, snapshot_id, id): - """ Return a single metadata item """ + """Return a single metadata item.""" context = req.environ['cinder.context'] data = self._get_metadata(context, snapshot_id) @@ -142,7 +142,7 @@ class Controller(object): raise exc.HTTPNotFound(explanation=msg) def delete(self, req, snapshot_id, id): - """ Deletes an existing metadata """ + """Deletes an existing metadata.""" context = req.environ['cinder.context'] metadata = self._get_metadata(context, snapshot_id) diff --git a/cinder/tests/api/test_common.py b/cinder/tests/api/test_common.py index 6c5c7b413..778d3b3a1 100644 --- a/cinder/tests/api/test_common.py +++ b/cinder/tests/api/test_common.py @@ -38,7 +38,7 @@ class LimiterTest(test.TestCase): """ def setUp(self): - """ Run before each test. """ + """Run before each test.""" super(LimiterTest, self).setUp() self.tiny = range(1) self.small = range(10) @@ -46,7 +46,7 @@ class LimiterTest(test.TestCase): self.large = range(10000) def test_limiter_offset_zero(self): - """ Test offset key works with 0. """ + """Test offset key works with 0.""" req = webob.Request.blank('/?offset=0') self.assertEqual(common.limited(self.tiny, req), self.tiny) self.assertEqual(common.limited(self.small, req), self.small) @@ -54,7 +54,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_offset_medium(self): - """ Test offset key works with a medium sized number. """ + """Test offset key works with a medium sized number.""" req = webob.Request.blank('/?offset=10') self.assertEqual(common.limited(self.tiny, req), []) self.assertEqual(common.limited(self.small, req), self.small[10:]) @@ -62,7 +62,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[10:1010]) def test_limiter_offset_over_max(self): - """ Test offset key works with a number over 1000 (max_limit). """ + """Test offset key works with a number over 1000 (max_limit).""" req = webob.Request.blank('/?offset=1001') self.assertEqual(common.limited(self.tiny, req), []) self.assertEqual(common.limited(self.small, req), []) @@ -71,19 +71,19 @@ class LimiterTest(test.TestCase): common.limited(self.large, req), self.large[1001:2001]) def test_limiter_offset_blank(self): - """ Test offset key works with a blank offset. """ + """Test offset key works with a blank offset.""" req = webob.Request.blank('/?offset=') self.assertRaises( webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_offset_bad(self): - """ Test offset key works with a BAD offset. """ + """Test offset key works with a BAD offset.""" req = webob.Request.blank(u'/?offset=\u0020aa') self.assertRaises( webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_nothing(self): - """ Test request with no offset or limit """ + """Test request with no offset or limit.""" req = webob.Request.blank('/') self.assertEqual(common.limited(self.tiny, req), self.tiny) self.assertEqual(common.limited(self.small, req), self.small) @@ -91,7 +91,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_zero(self): - """ Test limit of zero. """ + """Test limit of zero.""" req = webob.Request.blank('/?limit=0') self.assertEqual(common.limited(self.tiny, req), self.tiny) self.assertEqual(common.limited(self.small, req), self.small) @@ -99,13 +99,13 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_bad(self): - """ Test with a bad limit. """ + """Test with a bad limit.""" req = webob.Request.blank(u'/?limit=hello') self.assertRaises( webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_limit_medium(self): - """ Test limit of 10. """ + """Test limit of 10.""" req = webob.Request.blank('/?limit=10') self.assertEqual(common.limited(self.tiny, req), self.tiny) self.assertEqual(common.limited(self.small, req), self.small) @@ -113,7 +113,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[:10]) def test_limiter_limit_over_max(self): - """ Test limit of 3000. """ + """Test limit of 3000.""" req = webob.Request.blank('/?limit=3000') self.assertEqual(common.limited(self.tiny, req), self.tiny) self.assertEqual(common.limited(self.small, req), self.small) @@ -121,7 +121,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(self.large, req), self.large[:1000]) def test_limiter_limit_and_offset(self): - """ Test request with both limit and offset. """ + """Test request with both limit and offset.""" items = range(2000) req = webob.Request.blank('/?offset=1&limit=3') self.assertEqual(common.limited(items, req), items[1:4]) @@ -133,7 +133,7 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(items, req), []) def test_limiter_custom_max_limit(self): - """ Test a max_limit other than 1000. """ + """Test a max_limit other than 1000.""" items = range(2000) req = webob.Request.blank('/?offset=1&limit=3') self.assertEqual( @@ -148,13 +148,13 @@ class LimiterTest(test.TestCase): self.assertEqual(common.limited(items, req, max_limit=2000), []) def test_limiter_negative_limit(self): - """ Test a negative limit. """ + """Test a negative limit.""" req = webob.Request.blank('/?limit=-3000') self.assertRaises( webob.exc.HTTPBadRequest, common.limited, self.tiny, req) def test_limiter_negative_offset(self): - """ Test a negative offset. """ + """Test a negative offset.""" req = webob.Request.blank('/?offset=-30') self.assertRaises( webob.exc.HTTPBadRequest, common.limited, self.tiny, req) @@ -168,36 +168,36 @@ class PaginationParamsTest(test.TestCase): """ def test_nonnumerical_limit(self): - """ Test nonnumerical limit param. """ + """Test nonnumerical limit param.""" req = webob.Request.blank('/?limit=hello') self.assertRaises( webob.exc.HTTPBadRequest, common.get_pagination_params, req) def test_no_params(self): - """ Test no params. """ + """Test no params.""" req = webob.Request.blank('/') self.assertEqual(common.get_pagination_params(req), {}) def test_valid_marker(self): - """ Test valid marker param. """ + """Test valid marker param.""" req = webob.Request.blank( '/?marker=263abb28-1de6-412f-b00b-f0ee0c4333c2') self.assertEqual(common.get_pagination_params(req), {'marker': '263abb28-1de6-412f-b00b-f0ee0c4333c2'}) def test_valid_limit(self): - """ Test valid limit param. """ + """Test valid limit param.""" req = webob.Request.blank('/?limit=10') self.assertEqual(common.get_pagination_params(req), {'limit': 10}) def test_invalid_limit(self): - """ Test invalid limit param. """ + """Test invalid limit param.""" req = webob.Request.blank('/?limit=-2') self.assertRaises( webob.exc.HTTPBadRequest, common.get_pagination_params, req) def test_valid_limit_and_marker(self): - """ Test valid limit and marker parameters. """ + """Test valid limit and marker parameters.""" marker = '263abb28-1de6-412f-b00b-f0ee0c4333c2' req = webob.Request.blank('/?limit=20&marker=%s' % marker) self.assertEqual(common.get_pagination_params(req), diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 6959c52d1..a2cdfe7bf 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -1304,7 +1304,7 @@ class DriverTestCase(test.TestCase): return 1 def _attach_volume(self): - """Attach volumes to an instance. """ + """Attach volumes to an instance.""" return [] def _detach_volume(self, volume_id_list): @@ -1341,7 +1341,7 @@ class ISCSITestCase(DriverTestCase): driver_name = "cinder.volume.drivers.lvm.LVMISCSIDriver" def _attach_volume(self): - """Attach volumes to an instance. """ + """Attach volumes to an instance.""" volume_id_list = [] for index in xrange(3): vol = {} diff --git a/cinder/utils.py b/cinder/utils.py index 2109635b8..276e80d29 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -699,7 +699,7 @@ def check_isinstance(obj, cls): def is_valid_boolstr(val): - """Check if the provided string is a valid bool string or not. """ + """Check if the provided string is a valid bool string or not.""" val = str(val).lower() return (val == 'true' or val == 'false' or val == 'yes' or val == 'no' or @@ -724,9 +724,10 @@ def is_valid_ipv4(address): def monkey_patch(): - """ If the CONF.monkey_patch set as True, + """If the CONF.monkey_patch set as True, this function patches a decorator for all functions in specified modules. + You can set decorators for each modules using CONF.monkey_patch_modules. The format is "Module path:Decorator function". diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 5033a56a7..8249ab203 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -163,11 +163,11 @@ class VolumeDriver(object): raise NotImplementedError() def attach_volume(self, context, volume_id, instance_uuid, mountpoint): - """ Callback for volume attached to instance.""" + """Callback for volume attached to instance.""" pass def detach_volume(self, context, volume_id): - """ Callback for volume detached.""" + """Callback for volume detached.""" pass def get_volume_stats(self, refresh=False): diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 4c0ab2de4..f08183885 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -221,7 +221,7 @@ class HP3PARCommon(object): return capacity def _cli_run(self, verb, cli_args): - """ Runs a CLI command over SSH, without doing any result parsing. """ + """Runs a CLI command over SSH, without doing any result parsing.""" cli_arg_strings = [] if cli_args: for k, v in cli_args.items(): @@ -827,7 +827,7 @@ exit return showhost.split(',')[1] def terminate_connection(self, volume, hostname, wwn_iqn): - """ Driver entry point to unattach a volume from an instance.""" + """Driver entry point to unattach a volume from an instance.""" try: # does 3par know this host by a different name? if hostname in self.hosts_naming_dict: diff --git a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index eed9da5ec..5bec277bd 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -102,7 +102,7 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver): @utils.synchronized('3par', external=True) def create_cloned_volume(self, volume, src_vref): - """ Clone an existing volume. """ + """Clone an existing volume.""" self.common.client_login() new_vol = self.common.create_cloned_volume(volume, src_vref) self.common.client_logout() diff --git a/cinder/volume/drivers/scality.py b/cinder/volume/drivers/scality.py index 0cad54ba0..e3224f4ae 100644 --- a/cinder/volume/drivers/scality.py +++ b/cinder/volume/drivers/scality.py @@ -209,11 +209,11 @@ class ScalityDriver(driver.VolumeDriver): pass def attach_volume(self, context, volume_id, instance_uuid, mountpoint): - """ Callback for volume attached to instance.""" + """Callback for volume attached to instance.""" pass def detach_volume(self, context, volume_id): - """ Callback for volume detached.""" + """Callback for volume detached.""" pass def get_volume_stats(self, refresh=False): diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 2430495a5..1db7304c4 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -609,7 +609,7 @@ class VolumeManager(manager.SchedulerDependentManager): self.driver.ensure_export(context, volume_ref) def _copy_image_to_volume(self, context, volume, image_service, image_id): - """Downloads Glance image to the specified volume. """ + """Downloads Glance image to the specified volume.""" volume_id = volume['id'] try: self.driver.copy_image_to_volume(context, volume, @@ -721,7 +721,7 @@ class VolumeManager(manager.SchedulerDependentManager): self.update_service_capabilities(volume_stats) def publish_service_capabilities(self, context): - """ Collect driver status and then publish """ + """Collect driver status and then publish.""" self._report_driver_status(context) self._publish_service_capabilities(context) diff --git a/cinder/volume/utils.py b/cinder/volume/utils.py index f24b47bd9..e865c8718 100644 --- a/cinder/volume/utils.py +++ b/cinder/volume/utils.py @@ -39,11 +39,11 @@ def get_host_from_queue(queuename): def notify_usage_exists(context, volume_ref, current_period=False): - """ Generates 'exists' notification for a volume for usage auditing - purposes. + """Generates 'exists' notification for a volume for usage auditing + purposes. - Generates usage for last completed period, unless 'current_period' - is True. + Generates usage for last completed period, unless 'current_period' + is True. """ begin, end = utils.last_completed_audit_period() if current_period: diff --git a/tox.ini b/tox.ini index 9b9328cd1..c55515da9 100644 --- a/tox.ini +++ b/tox.ini @@ -43,6 +43,6 @@ commands = commands = {posargs} [flake8] -ignore = E711,E712,F401,F403,F811,F841,H302,H303,H304,H401,H402,H404 +ignore = E711,E712,F401,F403,F811,F841,H302,H303,H304,H402,H404 builtins = _ exclude = .venv,.tox,dist,doc,openstack,*egg,build