Fix and enable gating on H403

Fix occurrences of
H403 - multi line docstring end on new line

Change-Id: I79a818095e9f64a18ded1686fb152b9d58f3c8b1
This commit is contained in:
Dirk Mueller 2013-06-18 21:22:44 +02:00
parent 317220858e
commit 53773aab99
29 changed files with 139 additions and 70 deletions

View File

@ -118,19 +118,22 @@ class ShellCommands(object):
def bpython(self):
"""Runs a bpython shell.
Falls back to Ipython/python shell if unavailable"""
Falls back to Ipython/python shell if unavailable
"""
self.run('bpython')
def ipython(self):
"""Runs an Ipython shell.
Falls back to Python shell if unavailable"""
Falls back to Python shell if unavailable
"""
self.run('ipython')
def python(self):
"""Runs a python shell.
Falls back to Python shell if unavailable"""
Falls back to Python shell if unavailable
"""
self.run('python')
@args('--shell', dest="shell",
@ -174,7 +177,8 @@ class ShellCommands(object):
@args('--path', required=True, help='Script path')
def script(self, path):
"""Runs the script from the specifed path with flags set properly.
arguments: path"""
arguments: path
"""
exec(compile(open(path).read(), path, 'exec'), locals(), globals())
@ -193,7 +197,8 @@ class HostCommands(object):
help='Availability Zone (default: %(default)s)')
def list(self, zone=None):
"""Show a list of all physical hosts. Filter by zone.
args: [zone]"""
args: [zone]
"""
print "%-25s\t%-15s" % (_('host'),
_('zone'))
ctxt = context.get_admin_context()
@ -246,7 +251,8 @@ class VolumeCommands(object):
help='Volume ID to be deleted')
def delete(self, volume_id):
"""Delete a volume, bypassing the check that it
must be available."""
must be available.
"""
ctxt = context.get_admin_context()
volume = db.volume_get(ctxt, param2id(volume_id))
host = volume['host']
@ -272,7 +278,8 @@ class VolumeCommands(object):
def reattach(self, volume_id):
"""Re-attach a volume that has previously been attached
to an instance. Typically called after a compute host
has been rebooted."""
has been rebooted.
"""
ctxt = context.get_admin_context()
volume = db.volume_get(ctxt, param2id(volume_id))
if not volume['instance_id']:
@ -504,7 +511,8 @@ class BackupCommands(object):
def list(self):
"""List all backups (including ones in progress) and the host
on which the backup operation is running."""
on which the backup operation is running.
"""
ctxt = context.get_admin_context()
backups = db.backup_get_all(ctxt)
@ -575,7 +583,8 @@ CATEGORIES = {
def methods_of(obj):
"""Get all callable methods of an object that don't start with underscore
returns a list of tuples of the form (method_name, method)"""
returns a list of tuples of the form (method_name, method)
"""
result = []
for i in dir(obj):
if callable(getattr(obj, i)) and not i.startswith('_'):

View File

@ -71,7 +71,8 @@ class BackupManager(manager.SchedulerDependentManager):
def init_host(self):
"""Do any initialization that needs to be run if this is a
standalone service."""
standalone service.
"""
ctxt = context.get_admin_context()
self.driver.do_setup(ctxt)

View File

@ -326,7 +326,8 @@ def snapshot_data_get_for_project(context, project_id, session=None):
def snapshot_get_active_by_window(context, begin, end=None, project_id=None):
"""Get all the snapshots inside the window.
Specifying a project_id will filter for a certain project."""
Specifying a project_id will filter for a certain project.
"""
return IMPL.snapshot_get_active_by_window(context, begin, end, project_id)
@ -397,7 +398,8 @@ def volume_type_destroy(context, id):
def volume_get_active_by_window(context, begin, end=None, project_id=None):
"""Get all the volumes inside the window.
Specifying a project_id will filter for a certain project."""
Specifying a project_id will filter for a certain project.
"""
return IMPL.volume_get_active_by_window(context, begin, end, project_id)
@ -418,7 +420,8 @@ def volume_type_extra_specs_update_or_create(context,
volume_type_id,
extra_specs):
"""Create or update volume type extra specs. This adds or modifies the
key/value pairs specified in the extra specs dict argument"""
key/value pairs specified in the extra specs dict argument
"""
IMPL.volume_type_extra_specs_update_or_create(context,
volume_type_id,
extra_specs)

View File

@ -331,7 +331,8 @@ class Service(object):
A service takes a manager and enables rpc by listening to queues based
on topic. It also periodically runs tasks on the manager and reports
it state to the database services table."""
it state to the database services table.
"""
def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_interval=None, periodic_fuzzy_delay=None,

View File

@ -696,7 +696,8 @@ def wire_HTTPConnection_to_WSGI(host, app):
"""
class HTTPConnectionDecorator(object):
"""Wraps the real HTTPConnection class so that when you instantiate
the class you might instead get a fake instance."""
the class you might instead get a fake instance.
"""
def __init__(self, wrapped):
self.wrapped = wrapped

View File

@ -695,7 +695,8 @@ def wire_HTTPConnection_to_WSGI(host, app):
"""
class HTTPConnectionDecorator(object):
"""Wraps the real HTTPConnection class so that when you instantiate
the class you might instead get a fake instance."""
the class you might instead get a fake instance.
"""
def __init__(self, wrapped):
self.wrapped = wrapped

View File

@ -62,7 +62,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
'Test requires Cinder installed (try setup.py develop')
def test_create_volume_non_admin(self):
"""Test creating an instance locally using run_instance, passing
a non-admin context. DB actions should work."""
a non-admin context. DB actions should work.
"""
self.was_admin = False
def fake_get(context, *args, **kwargs):
@ -88,7 +89,8 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
'Test requires Cinder installed (try setup.py develop')
def test_schedule_happy_day(self):
"""Make sure there's nothing glaringly wrong with _schedule()
by doing a happy day pass through."""
by doing a happy day pass through.
"""
self.next_weight = 1.0

View File

@ -164,7 +164,8 @@ class SchedulerTestCase(test.TestCase):
class SchedulerDriverBaseTestCase(SchedulerTestCase):
"""Test cases for base scheduler driver class methods
that can't will fail if the driver is changed"""
that can't will fail if the driver is changed.
"""
def test_unimplemented_schedule(self):
fake_args = (1, 2, 3)

View File

@ -103,7 +103,8 @@ class BackupTestCase(test.TestCase):
def test_init_host(self):
"""Make sure stuck volumes and backups are reset to correct
states when backup_manager.init_host() is called"""
states when backup_manager.init_host() is called
"""
vol1_id = self._create_volume_db_entry(status='backing-up')
vol2_id = self._create_volume_db_entry(status='restoring-backup')
backup1_id = self._create_backup_db_entry(status='creating')
@ -127,7 +128,8 @@ class BackupTestCase(test.TestCase):
def test_create_backup_with_bad_volume_status(self):
"""Test error handling when creating a backup from a volume
with a bad status"""
with a bad status
"""
vol_id = self._create_volume_db_entry(status='available', size=1)
backup_id = self._create_backup_db_entry(volume_id=vol_id)
self.assertRaises(exception.InvalidVolume,
@ -137,7 +139,8 @@ class BackupTestCase(test.TestCase):
def test_create_backup_with_bad_backup_status(self):
"""Test error handling when creating a backup with a backup
with a bad status"""
with a bad status
"""
vol_id = self._create_volume_db_entry(size=1)
backup_id = self._create_backup_db_entry(status='available',
volume_id=vol_id)
@ -187,7 +190,8 @@ class BackupTestCase(test.TestCase):
def test_restore_backup_with_bad_volume_status(self):
"""Test error handling when restoring a backup to a volume
with a bad status"""
with a bad status
"""
vol_id = self._create_volume_db_entry(status='available', size=1)
backup_id = self._create_backup_db_entry(volume_id=vol_id)
self.assertRaises(exception.InvalidVolume,
@ -200,7 +204,8 @@ class BackupTestCase(test.TestCase):
def test_restore_backup_with_bad_backup_status(self):
"""Test error handling when restoring a backup with a backup
with a bad status"""
with a bad status
"""
vol_id = self._create_volume_db_entry(status='restoring-backup',
size=1)
backup_id = self._create_backup_db_entry(status='available',
@ -240,7 +245,8 @@ class BackupTestCase(test.TestCase):
def test_restore_backup_with_bad_service(self):
"""Test error handling when attempting a restore of a backup
with a different service to that used to create the backup"""
with a different service to that used to create the backup
"""
vol_id = self._create_volume_db_entry(status='restoring-backup',
size=1)
backup_id = self._create_backup_db_entry(status='restoring',
@ -286,7 +292,8 @@ class BackupTestCase(test.TestCase):
def test_delete_backup_with_bad_backup_status(self):
"""Test error handling when deleting a backup with a backup
with a bad status"""
with a bad status
"""
vol_id = self._create_volume_db_entry(size=1)
backup_id = self._create_backup_db_entry(status='available',
volume_id=vol_id)
@ -312,7 +319,8 @@ class BackupTestCase(test.TestCase):
def test_delete_backup_with_bad_service(self):
"""Test error handling when attempting a delete of a backup
with a different service to that used to create the backup"""
with a different service to that used to create the backup
"""
vol_id = self._create_volume_db_entry(size=1)
backup_id = self._create_backup_db_entry(status='deleting',
volume_id=vol_id)
@ -327,7 +335,8 @@ class BackupTestCase(test.TestCase):
def test_delete_backup_with_no_service(self):
"""Test error handling when attempting a delete of a backup
with no service defined for that backup, relates to bug #1162908"""
with no service defined for that backup, relates to bug #1162908
"""
vol_id = self._create_volume_db_entry(size=1)
backup_id = self._create_backup_db_entry(status='deleting',
volume_id=vol_id)
@ -363,7 +372,8 @@ class BackupTestCase(test.TestCase):
def test_backup_get_all_by_project_with_deleted(self):
"""Test deleted backups don't show up in backup_get_all_by_project.
Unless context.read_deleted is 'yes'"""
Unless context.read_deleted is 'yes'
"""
backups = db.backup_get_all_by_project(self.ctxt, 'fake')
self.assertEqual(len(backups), 0)
@ -381,7 +391,8 @@ class BackupTestCase(test.TestCase):
def test_backup_get_all_by_host_with_deleted(self):
"""Test deleted backups don't show up in backup_get_all_by_project.
Unless context.read_deleted is 'yes'"""
Unless context.read_deleted is 'yes'
"""
backups = db.backup_get_all_by_host(self.ctxt, 'testhost')
self.assertEqual(len(backups), 0)

View File

@ -96,7 +96,8 @@ def get_table(engine, name):
"""Returns an sqlalchemy table dynamically from db.
Needed because the models don't work for us in migrations
as models will be far out of sync with the current data."""
as models will be far out of sync with the current data.
"""
metadata = sqlalchemy.schema.MetaData()
metadata.bind = engine
return sqlalchemy.Table(name, metadata, autoload=True)

View File

@ -451,7 +451,8 @@ class ManagedRBDTestCase(DriverTestCase):
def _clone_volume_from_image(self, expected_status,
clone_works=True):
"""Try to clone a volume from an image, and check the status
afterwards"""
afterwards.
"""
def fake_clone_image(volume, image_location):
return True

View File

@ -675,7 +675,8 @@ class VolumeTestCase(test.TestCase):
def _create_volume_from_image(self, expected_status,
fakeout_copy_image_to_volume=False):
"""Call copy image to volume, Test the status of volume after calling
copying image to volume."""
copying image to volume.
"""
def fake_local_path(volume):
return dst_path
@ -719,12 +720,14 @@ class VolumeTestCase(test.TestCase):
def test_create_volume_from_image_status_available(self):
"""Verify that before copying image to volume, it is in available
state."""
state.
"""
self._create_volume_from_image('available')
def test_create_volume_from_image_exception(self):
"""Verify that create volume from image, the volume status is
'downloading'."""
'downloading'.
"""
dst_fd, dst_path = tempfile.mkstemp()
os.close(dst_fd)
@ -869,7 +872,8 @@ class VolumeTestCase(test.TestCase):
def test_create_volume_from_exact_sized_image(self):
"""Verify that an image which is exactly the same size as the
volume, will work correctly."""
volume, will work correctly.
"""
class _FakeImageService:
def __init__(self, db_driver=None, image_service=None):
pass

View File

@ -92,7 +92,8 @@ class VolumeTypeTestCase(test.TestCase):
def test_default_volume_type_missing_in_db(self):
"""Ensures proper exception raised if default volume type
is not in database."""
is not in database.
"""
session = db_api.get_session()
default_vol_type = volume_types.get_default_volume_type()
self.assertEqual(default_vol_type, {})

View File

@ -301,7 +301,8 @@ def last_completed_audit_period(unit=None):
returns: 2 tuple of datetimes (begin, end)
The begin timestamp of this audit period is the same as the
end of the previous."""
end of the previous.
"""
if not unit:
unit = CONF.volume_usage_audit_period

View File

@ -799,5 +799,6 @@ class HostAPI(base.Base):
def set_host_maintenance(self, context, host, mode):
"""Start/Stop host maintenance window. On start, it triggers
volume evacuation."""
volume evacuation.
"""
raise NotImplementedError()

View File

@ -56,7 +56,8 @@ class Configuration(object):
def __init__(self, volume_opts, config_group=None):
"""This takes care of grafting the implementation's config
values into the config group"""
values into the config group
"""
self.config_group = config_group
# set the local conf so that __call__'s know what to use

View File

@ -100,7 +100,8 @@ class VolumeDriver(object):
def create_volume(self, volume):
"""Creates a volume. Can optionally return a Dictionary of
changes to the volume object to be persisted."""
changes to the volume object to be persisted.
"""
raise NotImplementedError()
def create_volume_from_snapshot(self, volume, snapshot):
@ -132,7 +133,8 @@ class VolumeDriver(object):
def create_export(self, context, volume):
"""Exports the volume. Can optionally return a Dictionary of changes
to the volume object to be persisted."""
to the volume object to be persisted.
"""
raise NotImplementedError()
def remove_export(self, context, volume):
@ -157,7 +159,8 @@ class VolumeDriver(object):
def get_volume_stats(self, refresh=False):
"""Return the current state of the volume service. If 'refresh' is
True, run the update first."""
True, run the update first.
"""
return None
def do_setup(self, context):
@ -514,7 +517,8 @@ class ISCSIDriver(VolumeDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()

View File

@ -49,7 +49,8 @@ CONF.register_opts(volume_opts)
class GlusterfsDriver(nfs.RemoteFsDriver):
"""Gluster based cinder driver. Creates file on Gluster share for using it
as block device on hypervisor."""
as block device on hypervisor.
"""
def __init__(self, *args, **kwargs):
super(GlusterfsDriver, self).__init__(*args, **kwargs)
@ -122,7 +123,8 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
def create_export(self, ctx, volume):
"""Exports the volume. Can optionally return a Dictionary of changes
to the volume object to be persisted."""
to the volume object to be persisted.
"""
pass
def remove_export(self, ctx, volume):
@ -160,7 +162,8 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
def _ensure_shares_mounted(self):
"""Look for GlusterFS shares in the flags and try to mount them
locally."""
locally.
"""
self._mounted_shares = []
self._load_shares_config(self.configuration.glusterfs_shares_config)
@ -255,7 +258,8 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
def get_volume_stats(self, refresh=False):
"""Get volume stats.
If 'refresh' is True, update the stats first."""
If 'refresh' is True, update the stats first.
"""
if refresh or not self._stats:
self._update_volume_stats()

View File

@ -156,7 +156,8 @@ class LVMVolumeDriver(driver.VolumeDriver):
def create_volume(self, volume):
"""Creates a logical volume. Can optionally return a Dictionary of
changes to the volume object to be persisted."""
changes to the volume object to be persisted.
"""
self._create_volume(volume['name'], self._sizestr(volume['size']))
def create_volume_from_snapshot(self, volume, snapshot):
@ -550,7 +551,8 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()
@ -643,7 +645,8 @@ class ThinLVMVolumeDriver(LVMISCSIDriver):
def create_volume(self, volume):
"""Creates a logical volume. Can optionally return a Dictionary of
changes to the volume object to be persisted."""
changes to the volume object to be persisted.
"""
sizestr = self._sizestr(volume['size'])
vg_name = ("%s/%s-pool" % (self.configuration.volume_group,
self.configuration.volume_group))
@ -674,7 +677,8 @@ class ThinLVMVolumeDriver(LVMISCSIDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()

View File

@ -366,7 +366,8 @@ class NaElement(object):
def add_new_child(self, name, content, convert=False):
"""Add child with tag name and context.
Convert replaces entity refs to chars."""
Convert replaces entity refs to chars.
"""
child = NaElement(name)
if convert:
content = NaElement._convert_entity_refs(content)

View File

@ -1109,7 +1109,8 @@ class NetAppISCSIDriver(driver.ISCSIDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()
@ -1959,7 +1960,8 @@ class NetAppDirectISCSIDriver(driver.ISCSIDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()

View File

@ -103,7 +103,8 @@ class NetAppNFSDriver(nfs.NfsDriver):
def _check_dfm_flags(self):
"""Raises error if any required configuration flag for OnCommand proxy
is missing."""
is missing.
"""
required_flags = ['netapp_wsdl_url',
'netapp_login',
'netapp_password',
@ -325,7 +326,8 @@ class NetAppCmodeNfsDriver (NetAppNFSDriver):
def _check_flags(self):
"""Raises error if any required configuration flag for NetApp Cloud
Webservices is missing."""
Webservices is missing.
"""
required_flags = ['netapp_wsdl_url',
'netapp_login',
'netapp_password',
@ -376,7 +378,8 @@ class NetAppDirectNfsDriver (NetAppNFSDriver):
def _check_flags(self):
"""Raises error if any required configuration flag for NetApp
filer is missing."""
filer is missing.
"""
required_flags = ['netapp_login',
'netapp_password',
'netapp_server_hostname',

View File

@ -298,7 +298,8 @@ class NexentaDriver(driver.ISCSIDriver): # pylint: disable=R0921
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh:
self._update_volume_status()

View File

@ -78,7 +78,8 @@ class RemoteFsDriver(driver.VolumeDriver):
def delete_snapshot(self, snapshot):
"""Do nothing for this driver, but allow manager to handle deletion
of snapshot in error state."""
of snapshot in error state.
"""
pass
def ensure_export(self, ctx, volume):
@ -91,7 +92,8 @@ class RemoteFsDriver(driver.VolumeDriver):
def _create_regular_file(self, path, size):
"""Creates regular file of given size. Takes a lot of time for large
files."""
files.
"""
block_size_mb = 1
block_count = size * units.GiB / (block_size_mb * units.MiB)
@ -115,7 +117,8 @@ class RemoteFsDriver(driver.VolumeDriver):
def _get_hash_str(self, base_str):
"""returns string that represents hash of base_str
(in a hex format)."""
(in a hex format).
"""
return hashlib.md5(base_str).hexdigest()
def copy_image_to_volume(self, context, volume, image_service, image_id):
@ -185,7 +188,8 @@ class RemoteFsDriver(driver.VolumeDriver):
class NfsDriver(RemoteFsDriver):
"""NFS based cinder driver. Creates file on NFS share for using it
as block device on hypervisor."""
as block device on hypervisor.
"""
def __init__(self, *args, **kwargs):
super(NfsDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(volume_opts)
@ -265,7 +269,8 @@ class NfsDriver(RemoteFsDriver):
def create_export(self, ctx, volume):
"""Exports the volume. Can optionally return a Dictionary of changes
to the volume object to be persisted."""
to the volume object to be persisted.
"""
pass
def remove_export(self, ctx, volume):
@ -433,7 +438,8 @@ class NfsDriver(RemoteFsDriver):
def get_volume_stats(self, refresh=False):
"""Get volume status.
If 'refresh' is True, run update the stats first."""
If 'refresh' is True, run update the stats first.
"""
if refresh or not self._stats:
self._update_volume_status()

View File

@ -225,7 +225,8 @@ class RBDDriver(driver.VolumeDriver):
def get_volume_stats(self, refresh=False):
"""Return the current state of the volume service. If 'refresh' is
True, run the update first."""
True, run the update first.
"""
if refresh:
self._update_volume_stats()
return self._stats

View File

@ -1336,7 +1336,8 @@ class StorwizeSVCDriver(san.SanISCSIDriver):
"""Get volume status.
If we haven't gotten stats yet or 'refresh' is True,
run update the stats first."""
run update the stats first.
"""
if not self._stats or refresh:
self._update_volume_status()

View File

@ -135,7 +135,8 @@ class VolumeManager(manager.SchedulerDependentManager):
def init_host(self):
"""Do any initialization that needs to be run if this is a
standalone service."""
standalone service.
"""
ctxt = context.get_admin_context()
self.driver.do_setup(ctxt)

View File

@ -43,7 +43,8 @@ def notify_usage_exists(context, volume_ref, current_period=False):
purposes.
Generates usage for last completed period, unless 'current_period'
is True."""
is True.
"""
begin, end = utils.last_completed_audit_period()
if current_period:
audit_start = end

View File

@ -43,6 +43,6 @@ commands =
commands = {posargs}
[flake8]
ignore = E711,E712,F401,F403,F811,F841,H302,H303,H304,H401,H402,H403,H404
ignore = E711,E712,F401,F403,F811,F841,H302,H303,H304,H401,H402,H404
builtins = _
exclude = .venv,.tox,dist,doc,openstack,*egg