Enable E121,E122,E123,E124,E125,E129 flake8 tests

Enable the tests and update flake8 comments to note that H904 is ignored
on purpose.

The patch fixes these warnings:
./manila/api/views/limits.py:68:5: E129 visually indented line with same
    indent as next logical line
./manila/share/drivers/netapp/cluster_mode.py:352:13: E122 continuation
    line missing indentation or outdented
./manila/scheduler/scheduler_options.py:98:13: E129 visually indented
    line with same indent as next logical line
./contrib/tempest/tempest/api/share/base.py:210:5: E129 visually
    indented line with same indent as next logical line
./contrib/tempest/tempest/api/share/test_rules.py:32:13: E129 visually
    indented line with same indent as next logical line
./contrib/tempest/tempest/api/share/test_rules.py:90:13: E129 visually
    indented line with same indent as next logical line
./manila/api/views/share_servers.py:28:9: E124 closing bracket does not
    match visual indentation
./manila/api/views/share_servers.py:34:9: E124 closing bracket does not
    match visual indentation
./manila/share/drivers/netapp/driver.py:336:5: E125 continuation line
    with same indent as next logical line

Also fixes other pep8 warnings in these files.

Partial-Fix: #1333290

Change-Id: Ida14ea8f4716e49f7379f929971fd5e462541527
This commit is contained in:
Andreas Jaeger 2014-08-20 10:11:40 +02:00
parent b5873b8561
commit e287c9e263
8 changed files with 61 additions and 47 deletions

View File

@ -207,7 +207,7 @@ class BaseSharesTest(test.BaseTestCase):
__, share_networks = sc.list_share_networks_with_detail()
for share_network in share_networks:
if (net_id == share_network["neutron_net_id"] and
subnet_id == share_network["neutron_subnet_id"]):
subnet_id == share_network["neutron_subnet_id"]):
share_network_id = share_network["id"]
break

View File

@ -29,7 +29,7 @@ class ShareIpRulesForNFSTest(base.BaseSharesTest):
def setUpClass(cls):
super(ShareIpRulesForNFSTest, cls).setUpClass()
if (cls.protocol not in CONF.share.enable_protocols or
cls.protocol not in CONF.share.enable_ip_rules_for_protocols):
cls.protocol not in CONF.share.enable_ip_rules_for_protocols):
msg = "IP rule tests for %s protocol are disabled" % cls.protocol
raise cls.skipException(msg)
__, cls.share = cls.create_share(cls.protocol)
@ -87,7 +87,8 @@ class ShareUserRulesForNFSTest(base.BaseSharesTest):
def setUpClass(cls):
super(ShareUserRulesForNFSTest, cls).setUpClass()
if (cls.protocol not in CONF.share.enable_protocols or
cls.protocol not in CONF.share.enable_user_rules_for_protocols):
cls.protocol not in
CONF.share.enable_user_rules_for_protocols):
msg = "USER rule tests for %s protocol are disabled" % cls.protocol
raise cls.skipException(msg)
__, cls.share = cls.create_share(cls.protocol)

View File

@ -65,7 +65,7 @@ class ViewBuilder(object):
# check for existing key
for limit in limits:
if (limit["uri"] == rate_limit["URI"] and
limit["regex"] == rate_limit["regex"]):
limit["regex"] == rate_limit["regex"]):
_rate_limit_key = limit
break

View File

@ -23,14 +23,16 @@ class ViewBuilder(common.ViewBuilder):
def build_share_server(self, share_server):
"""View of a share server."""
return {'share_server':
self._build_share_server_view(share_server, detailed=True)
return {
'share_server':
self._build_share_server_view(share_server, detailed=True)
}
def build_share_servers(self, share_servers):
return {'share_servers':
[self._build_share_server_view(share_server)
for share_server in share_servers]
return {
'share_servers':
[self._build_share_server_view(share_server)
for share_server in share_servers]
}
def build_share_server_details(self, details):

View File

@ -95,7 +95,7 @@ class SchedulerOptions(object):
last_modified = self._get_file_timestamp(filename)
if (not last_modified or not self.last_modified or
last_modified > self.last_modified):
last_modified > self.last_modified):
self.data = self._load_file(self._get_file_handle(filename))
self.last_modified = last_modified
if not self.data:

View File

@ -236,9 +236,15 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
def _get_node_data_port(self, node):
"""Get data port on the node."""
args = {'query': {'net-port-info': {'node': node,
'port-type': 'physical',
'role': 'data'}}}
args = {
'query': {
'net-port-info': {
'node': node,
'port-type': 'physical',
'role': 'data'
}
}
}
port_info = self._client.send_request('net-port-get-iter', args)
try:
port = port_info.get_child_by_name('attributes-list')\
@ -274,8 +280,7 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
aggrs = self._client.send_request('aggr-get-iter')\
.get_child_by_name('attributes-list').get_children()
except AttributeError:
msg = _("Have not found aggregates match pattern %s")\
% pattern
msg = _("Have not found aggregates match pattern %s") % pattern
LOG.error(msg)
raise exception.NetAppException(msg)
aggr_list = [aggr for aggr in aggrs if re.match(
@ -309,10 +314,10 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
_("Failed to create vlan %(vlan)s on "
"port %(port)s. %(err_msg)") %
{'vlan': vlan, 'port': port, 'err_msg': e.message})
iface_name = self.configuration.netapp_lif_name_template % \
{'node': node, 'net_allocation_id': allocation_id}
iface_name = (self.configuration.netapp_lif_name_template %
{'node': node, 'net_allocation_id': allocation_id})
LOG.debug('Creating LIF %(lif)r for vserver %(vserver)s '
% {'lif': iface_name, 'vserver': vserver_name})
% {'lif': iface_name, 'vserver': vserver_name})
args = {'address': ip,
'administrative-status': 'up',
'data-protocols': [
@ -369,8 +374,8 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
def _vserver_create_if_not_exists(self, network_info):
"""Creates vserver if not exists with given parameters."""
vserver_name = self.configuration.netapp_vserver_name_template % \
network_info['server_id']
vserver_name = (self.configuration.netapp_vserver_name_template %
network_info['server_id'])
vserver_client = NetAppApiClient(
self.api_version, vserver=vserver_name,
configuration=self.configuration)
@ -460,7 +465,7 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
def _configure_dns(self, data, vserver_client):
args = {
'domains': {
'string': data['domain']
'string': data['domain']
},
'name-servers': {
'ip-address': data['dns_ip']
@ -559,9 +564,9 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
}
}
ifaces = vserver_client.send_request('net-interface-get-iter',
args)
if not ifaces.get_child_content('num_records') or \
ifaces.get_child_content('num_records') == '0':
args)
if (not ifaces.get_child_content('num_records') or
ifaces.get_child_content('num_records') == '0'):
self._create_net_iface(ip, netmask, vlan, node, port, vserver_name,
allocation_id)
@ -755,11 +760,11 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
"""Raises ShareSnapshotIsBusy if snapshot is busy."""
args = {'volume': share_name}
snapshots = vserver_client.send_request('snapshot-list-info',
args)
for snap in snapshots.get_child_by_name('snapshots')\
.get_children():
if snap.get_child_by_name('name').get_content() == snapshot_name\
and snap.get_child_by_name('busy').get_content() == 'true':
args)
for snap in snapshots.get_child_by_name('snapshots').get_children():
if (snap.get_child_by_name('name').get_content() == snapshot_name
and (snap.get_child_by_name('busy').get_content()
== 'true')):
return True
def _share_unmount(self, share, vserver_client):
@ -793,8 +798,7 @@ class NetAppClusteredShareDriver(driver.ShareDriver):
def _delete_vserver(self, vserver_name, vserver_client,
security_services=None):
"""
Delete vserver.
"""Delete vserver.
Checks if vserver exists and does not have active shares.
Offlines and destroys root volumes.

View File

@ -83,8 +83,7 @@ class NetAppApiClient(object):
class NetAppShareDriver(driver.ShareDriver):
"""
NetApp specific ONTAP 7-mode driver.
"""NetApp specific ONTAP 7-mode driver.
Supports NFS and CIFS protocols.
Uses Ontap devices as backend to create shares
@ -225,11 +224,12 @@ class NetAppShareDriver(driver.ShareDriver):
return helper.deny_access(context, share, access)
def _check_vfiler_exists(self):
vfiler_status = self._client.send_request('vfiler-get-status',
{'vfiler': self.configuration.netapp_nas_vfiler})
vfiler_status = self._client.send_request(
'vfiler-get-status',
{'vfiler': self.configuration.netapp_nas_vfiler})
if vfiler_status.get_child_content('status') != 'running':
msg = _("Vfiler %s is not running") \
% self.configuration.netapp_nas_vfiler
msg = (_("Vfiler %s is not running")
% self.configuration.netapp_nas_vfiler)
LOG.error(msg)
raise exception.NetAppException(msg)
@ -238,8 +238,10 @@ class NetAppShareDriver(driver.ShareDriver):
licenses = self._client.send_request('license-v2-list-info')
except naapi.NaApiError:
licenses = self._client.send_request('license-list-info')
self._licenses = [l.get_child_content('package').lower() for l in
licenses.get_child_by_name('licenses').get_children()]
self._licenses = [l.get_child_content('package').lower()
for l in
licenses.get_child_by_name('licenses').get_children()
]
LOG.info(_("Available licenses: %s") % ', '.join(self._licenses))
return self._licenses
@ -290,8 +292,8 @@ class NetAppShareDriver(driver.ShareDriver):
.get_children()
if not aggr_list_elements:
msg = _("No aggregate assigned to vfiler %s")\
% self.configuration.netapp_nas_vfiler
msg = (_("No aggregate assigned to vfiler %s")
% self.configuration.netapp_nas_vfiler)
LOG.error(msg)
raise exception.NetAppException(msg)
@ -332,14 +334,14 @@ class NetAppShareDriver(driver.ShareDriver):
snapshots = snapshots.get_child_by_name('snapshots')
if snapshots:
for snap in snapshots.get_children():
if snap.get_child_content('name') == snapshot_name \
and snap.get_child_content('busy') == 'true':
if (snap.get_child_content('name') == snapshot_name
and snap.get_child_content('busy') == 'true'):
return True
def _get_valid_share_name(self, share_id):
"""Get share name according to share name template."""
return self.configuration.netapp_nas_volume_name_template %\
{'share_id': share_id.replace('-', '_')}
return (self.configuration.netapp_nas_volume_name_template %
{'share_id': share_id.replace('-', '_')})
def _get_valid_snapshot_name(self, snapshot_id):
"""Get snapshot name according to snapshot name template."""
@ -455,7 +457,7 @@ class NetAppNFSHelper(NetAppNASHelperBase):
LOG.debug('Appending nfs rules %r' % rules)
self._client.send_request('nfs-exportfs-append-rules-2',
args)
args)
def create_share(self, share_name, export_ip):
"""Creates NFS share."""

View File

@ -44,6 +44,11 @@ commands = bash tools/lintstack.sh
# TODO: These are not intentionally disabled, reenable when fixed:
# H405: multi line docstring summary not separated with an empty line
# H501: Do not use locals() for string formatting
ignore = E12,H302,H303,H404,H405,H501,H904,F401,F403,F841
#
# Following checks are ignored on purpose:
#
# H904 wrap long lines in parentheses instead of a backslash
# reason: removed in hacking (https://review.openstack.org/#/c/101701/)
ignore = E126,E127,E128,H302,H303,H404,H405,H501,H904,F401,F403,F841
builtins = _
exclude = .venv,.tox,dist,doc,openstack,*egg