Enable gating on F811

Avoid name clashes of local variables with
imported modules.

Change-Id: I1c5508902f89ad5dd9d160a4d163cd91bec41333
This commit is contained in:
Dirk Mueller 2013-08-27 22:43:38 +02:00
parent c37b7db38a
commit cf6db82503
6 changed files with 29 additions and 33 deletions

View File

@ -26,7 +26,7 @@ from cinder import exception
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils from cinder.openstack.common import uuidutils
from cinder import utils from cinder import utils
from cinder import volume from cinder import volume as cinder_volume
from cinder.volume import volume_types from cinder.volume import volume_types
@ -212,7 +212,7 @@ class VolumeController(wsgi.Controller):
_visible_admin_metadata_keys = ['readonly', 'attached_mode'] _visible_admin_metadata_keys = ['readonly', 'attached_mode']
def __init__(self, ext_mgr): def __init__(self, ext_mgr):
self.volume_api = volume.API() self.volume_api = cinder_volume.API()
self.ext_mgr = ext_mgr self.ext_mgr = ext_mgr
super(VolumeController, self).__init__() super(VolumeController, self).__init__()

View File

@ -28,7 +28,7 @@ from cinder import exception
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
from cinder.openstack.common import uuidutils from cinder.openstack.common import uuidutils
from cinder import utils from cinder import utils
from cinder import volume from cinder import volume as cinder_volume
from cinder.volume import volume_types from cinder.volume import volume_types
@ -155,7 +155,7 @@ class VolumeController(wsgi.Controller):
_visible_admin_metadata_keys = ['readonly', 'attached_mode'] _visible_admin_metadata_keys = ['readonly', 'attached_mode']
def __init__(self, ext_mgr): def __init__(self, ext_mgr):
self.volume_api = volume.API() self.volume_api = cinder_volume.API()
self.ext_mgr = ext_mgr self.ext_mgr = ext_mgr
super(VolumeController, self).__init__() super(VolumeController, self).__init__()

View File

@ -22,7 +22,7 @@ import array
from cinder import context from cinder import context
from cinder import exception from cinder import exception
from cinder.keymgr import key from cinder.keymgr import key as keymgr_key
from cinder.tests.keymgr import mock_key_mgr from cinder.tests.keymgr import mock_key_mgr
from cinder.tests.keymgr import test_key_mgr from cinder.tests.keymgr import test_key_mgr
@ -54,9 +54,8 @@ class MockKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):
self.key_mgr.create_key, None) self.key_mgr.create_key, None)
def test_store_key(self): def test_store_key(self):
_key = key.SymmetricKey('AES', secret_key = array.array('B', ('0' * 64).decode('hex')).tolist()
array.array('B', _key = keymgr_key.SymmetricKey('AES', secret_key)
('0' * 64).decode('hex')).tolist())
key_id = self.key_mgr.store_key(self.ctxt, _key) key_id = self.key_mgr.store_key(self.ctxt, _key)
actual_key = self.key_mgr.get_key(self.ctxt, key_id) actual_key = self.key_mgr.get_key(self.ctxt, key_id)

View File

@ -98,8 +98,8 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
body = [x for x in root.iterchildren()] body = [x for x in root.iterchildren()]
request = body[0] request = body[0]
tag = request.tag tag = request.tag
api = etree.QName(tag).localname or tag localname = etree.QName(tag).localname or tag
if 'volume-get-iter' == api: if 'volume-get-iter' == localname:
body = """<results status="passed"><attributes-list> body = """<results status="passed"><attributes-list>
<volume-attributes> <volume-attributes>
<volume-id-attributes> <volume-id-attributes>
@ -208,7 +208,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
</volume-attributes> </volume-attributes>
</attributes-list> </attributes-list>
<num-records>4</num-records></results>""" <num-records>4</num-records></results>"""
elif 'aggr-options-list-info' == api: elif 'aggr-options-list-info' == localname:
body = """<results status="passed"> body = """<results status="passed">
<options> <options>
<aggr-option-info> <aggr-option-info>
@ -221,7 +221,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
</aggr-option-info> </aggr-option-info>
</options> </options>
</results>""" </results>"""
elif 'sis-get-iter' == api: elif 'sis-get-iter' == localname:
body = """<results status="passed"> body = """<results status="passed">
<attributes-list> <attributes-list>
<sis-status-info> <sis-status-info>
@ -233,7 +233,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
</sis-status-info> </sis-status-info>
</attributes-list> </attributes-list>
</results>""" </results>"""
elif 'storage-disk-get-iter' == api: elif 'storage-disk-get-iter' == localname:
body = """<results status="passed"> body = """<results status="passed">
<attributes-list> <attributes-list>
<storage-disk-info> <storage-disk-info>
@ -373,7 +373,6 @@ class SscUtilsTestCase(test.TestCase):
def test_cl_vols_ssc_all(self): def test_cl_vols_ssc_all(self):
"""Test cluster ssc for all vols.""" """Test cluster ssc for all vols."""
mox = self.mox
na_server = api.NaServer('127.0.0.1') na_server = api.NaServer('127.0.0.1')
vserver = 'openstack' vserver = 'openstack'
test_vols = set([copy.deepcopy(self.vol1), test_vols = set([copy.deepcopy(self.vol1),
@ -381,10 +380,10 @@ class SscUtilsTestCase(test.TestCase):
sis = {'vola': {'dedup': False, 'compression': False}, sis = {'vola': {'dedup': False, 'compression': False},
'volb': {'dedup': True, 'compression': False}} 'volb': {'dedup': True, 'compression': False}}
mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc') self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict') self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
mox.StubOutWithMock(ssc_utils, 'query_aggr_options') self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk') self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
ssc_utils.query_cluster_vols_for_ssc( ssc_utils.query_cluster_vols_for_ssc(
na_server, vserver, None).AndReturn(test_vols) na_server, vserver, None).AndReturn(test_vols)
ssc_utils.get_sis_vol_dict(na_server, vserver, None).AndReturn(sis) ssc_utils.get_sis_vol_dict(na_server, vserver, None).AndReturn(sis)
@ -398,12 +397,12 @@ class SscUtilsTestCase(test.TestCase):
na_server, IgnoreArg()).AndReturn(raid4) na_server, IgnoreArg()).AndReturn(raid4)
ssc_utils.query_aggr_storage_disk( ssc_utils.query_aggr_storage_disk(
na_server, IgnoreArg()).AndReturn('SAS') na_server, IgnoreArg()).AndReturn('SAS')
mox.ReplayAll() self.mox.ReplayAll()
res_vols = ssc_utils.get_cluster_vols_with_ssc( res_vols = ssc_utils.get_cluster_vols_with_ssc(
na_server, vserver, volume=None) na_server, vserver, volume=None)
mox.VerifyAll() self.mox.VerifyAll()
for vol in res_vols: for vol in res_vols:
if vol.id['name'] == 'volc': if vol.id['name'] == 'volc':
self.assertEqual(vol.sis['compression'], False) self.assertEqual(vol.sis['compression'], False)
@ -413,16 +412,15 @@ class SscUtilsTestCase(test.TestCase):
def test_cl_vols_ssc_single(self): def test_cl_vols_ssc_single(self):
"""Test cluster ssc for single vol.""" """Test cluster ssc for single vol."""
mox = self.mox
na_server = api.NaServer('127.0.0.1') na_server = api.NaServer('127.0.0.1')
vserver = 'openstack' vserver = 'openstack'
test_vols = set([copy.deepcopy(self.vol1)]) test_vols = set([copy.deepcopy(self.vol1)])
sis = {'vola': {'dedup': False, 'compression': False}} sis = {'vola': {'dedup': False, 'compression': False}}
mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc') self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict') self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
mox.StubOutWithMock(ssc_utils, 'query_aggr_options') self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk') self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
ssc_utils.query_cluster_vols_for_ssc( ssc_utils.query_cluster_vols_for_ssc(
na_server, vserver, 'vola').AndReturn(test_vols) na_server, vserver, 'vola').AndReturn(test_vols)
ssc_utils.get_sis_vol_dict( ssc_utils.get_sis_vol_dict(
@ -431,30 +429,29 @@ class SscUtilsTestCase(test.TestCase):
ssc_utils.query_aggr_options( ssc_utils.query_aggr_options(
na_server, 'aggr1').AndReturn(raiddp) na_server, 'aggr1').AndReturn(raiddp)
ssc_utils.query_aggr_storage_disk(na_server, 'aggr1').AndReturn('SSD') ssc_utils.query_aggr_storage_disk(na_server, 'aggr1').AndReturn('SSD')
mox.ReplayAll() self.mox.ReplayAll()
res_vols = ssc_utils.get_cluster_vols_with_ssc( res_vols = ssc_utils.get_cluster_vols_with_ssc(
na_server, vserver, volume='vola') na_server, vserver, volume='vola')
mox.VerifyAll() self.mox.VerifyAll()
self.assertEqual(len(res_vols), 1) self.assertEqual(len(res_vols), 1)
def test_get_cluster_ssc(self): def test_get_cluster_ssc(self):
"""Test get cluster ssc map.""" """Test get cluster ssc map."""
mox = self.mox
na_server = api.NaServer('127.0.0.1') na_server = api.NaServer('127.0.0.1')
vserver = 'openstack' vserver = 'openstack'
test_vols = set( test_vols = set(
[self.vol1, self.vol2, self.vol3, self.vol4, self.vol5]) [self.vol1, self.vol2, self.vol3, self.vol4, self.vol5])
mox.StubOutWithMock(ssc_utils, 'get_cluster_vols_with_ssc') self.mox.StubOutWithMock(ssc_utils, 'get_cluster_vols_with_ssc')
ssc_utils.get_cluster_vols_with_ssc( ssc_utils.get_cluster_vols_with_ssc(
na_server, vserver).AndReturn(test_vols) na_server, vserver).AndReturn(test_vols)
mox.ReplayAll() self.mox.ReplayAll()
res_map = ssc_utils.get_cluster_ssc(na_server, vserver) res_map = ssc_utils.get_cluster_ssc(na_server, vserver)
mox.VerifyAll() self.mox.VerifyAll()
self.assertEqual(len(res_map['mirrored']), 1) self.assertEqual(len(res_map['mirrored']), 1)
self.assertEqual(len(res_map['dedup']), 3) self.assertEqual(len(res_map['dedup']), 3)
self.assertEqual(len(res_map['compression']), 1) self.assertEqual(len(res_map['compression']), 1)

View File

@ -829,7 +829,7 @@ class OnFailureRescheduleTask(base.CinderTask):
] ]
def _is_reschedulable(self, cause): def _is_reschedulable(self, cause):
(exc_type, value, traceback) = cause.exc_info exc_type, value = cause.exc_info()[:2]
if not exc_type and cause.exc: if not exc_type and cause.exc:
exc_type = type(cause.exc) exc_type = type(cause.exc)
if not exc_type: if not exc_type:

View File

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