]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Enable gating on F811
authorDirk Mueller <dirk@dmllr.de>
Tue, 27 Aug 2013 20:43:38 +0000 (22:43 +0200)
committerDirk Mueller <dirk@dmllr.de>
Mon, 2 Sep 2013 16:08:02 +0000 (18:08 +0200)
Avoid name clashes of local variables with
imported modules.

Change-Id: I1c5508902f89ad5dd9d160a4d163cd91bec41333

cinder/api/v1/volumes.py
cinder/api/v2/volumes.py
cinder/tests/keymgr/test_mock_key_mgr.py
cinder/tests/test_netapp_ssc.py
cinder/volume/flows/create_volume/__init__.py
tox.ini

index 969655b47045802050d4f6e0a8bf1ef0763fc5ea..df92892b07e736c705e1fb23bd53589d35f52ed8 100644 (file)
@@ -26,7 +26,7 @@ from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import uuidutils
 from cinder import utils
-from cinder import volume
+from cinder import volume as cinder_volume
 from cinder.volume import volume_types
 
 
@@ -212,7 +212,7 @@ class VolumeController(wsgi.Controller):
     _visible_admin_metadata_keys = ['readonly', 'attached_mode']
 
     def __init__(self, ext_mgr):
-        self.volume_api = volume.API()
+        self.volume_api = cinder_volume.API()
         self.ext_mgr = ext_mgr
         super(VolumeController, self).__init__()
 
index 6ef87b0a4aeee13cc8a0ae33538ed560437e2763..29b8d59bb343e5f283a7a677dd35ed792551134f 100644 (file)
@@ -28,7 +28,7 @@ from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import uuidutils
 from cinder import utils
-from cinder import volume
+from cinder import volume as cinder_volume
 from cinder.volume import volume_types
 
 
@@ -155,7 +155,7 @@ class VolumeController(wsgi.Controller):
     _visible_admin_metadata_keys = ['readonly', 'attached_mode']
 
     def __init__(self, ext_mgr):
-        self.volume_api = volume.API()
+        self.volume_api = cinder_volume.API()
         self.ext_mgr = ext_mgr
         super(VolumeController, self).__init__()
 
index a542620932c14ec23a2c94b1cda4be43a9b244b2..0cfdc0519c8ab772a55a84adf39c821750f1ccc4 100644 (file)
@@ -22,7 +22,7 @@ import array
 
 from cinder import context
 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 test_key_mgr
 
@@ -54,9 +54,8 @@ class MockKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):
                           self.key_mgr.create_key, None)
 
     def test_store_key(self):
-        _key = key.SymmetricKey('AES',
-                                array.array('B',
-                                            ('0' * 64).decode('hex')).tolist())
+        secret_key = array.array('B', ('0' * 64).decode('hex')).tolist()
+        _key = keymgr_key.SymmetricKey('AES', secret_key)
         key_id = self.key_mgr.store_key(self.ctxt, _key)
 
         actual_key = self.key_mgr.get_key(self.ctxt, key_id)
index 12d6553b6c402dba56f5d38564dc2ad209dacb37..860f7b2525d86f99eacfafe01e653db27b55c961 100644 (file)
@@ -98,8 +98,8 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
         body = [x for x in root.iterchildren()]
         request = body[0]
         tag = request.tag
-        api = etree.QName(tag).localname or tag
-        if 'volume-get-iter' == api:
+        localname = etree.QName(tag).localname or tag
+        if 'volume-get-iter' == localname:
             body = """<results status="passed"><attributes-list>
                 <volume-attributes>
                 <volume-id-attributes>
@@ -208,7 +208,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
                 </volume-attributes>
                 </attributes-list>
                 <num-records>4</num-records></results>"""
-        elif 'aggr-options-list-info' == api:
+        elif 'aggr-options-list-info' == localname:
                 body = """<results status="passed">
                              <options>
                              <aggr-option-info>
@@ -221,7 +221,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
                              </aggr-option-info>
                              </options>
                              </results>"""
-        elif 'sis-get-iter' == api:
+        elif 'sis-get-iter' == localname:
                 body = """<results status="passed">
                              <attributes-list>
                              <sis-status-info>
@@ -233,7 +233,7 @@ class FakeDirectCMODEServerHandler(FakeHTTPRequestHandler):
                              </sis-status-info>
                              </attributes-list>
                              </results>"""
-        elif 'storage-disk-get-iter' == api:
+        elif 'storage-disk-get-iter' == localname:
             body = """<results status="passed">
                              <attributes-list>
                              <storage-disk-info>
@@ -373,7 +373,6 @@ class SscUtilsTestCase(test.TestCase):
 
     def test_cl_vols_ssc_all(self):
         """Test cluster ssc for all vols."""
-        mox = self.mox
         na_server = api.NaServer('127.0.0.1')
         vserver = 'openstack'
         test_vols = set([copy.deepcopy(self.vol1),
@@ -381,10 +380,10 @@ class SscUtilsTestCase(test.TestCase):
         sis = {'vola': {'dedup': False, 'compression': False},
                'volb': {'dedup': True, 'compression': False}}
 
-        mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
-        mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
-        mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
-        mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
+        self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
+        self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
+        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
+        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
         ssc_utils.query_cluster_vols_for_ssc(
             na_server, vserver, None).AndReturn(test_vols)
         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)
         ssc_utils.query_aggr_storage_disk(
             na_server, IgnoreArg()).AndReturn('SAS')
-        mox.ReplayAll()
+        self.mox.ReplayAll()
 
         res_vols = ssc_utils.get_cluster_vols_with_ssc(
             na_server, vserver, volume=None)
 
-        mox.VerifyAll()
+        self.mox.VerifyAll()
         for vol in res_vols:
             if vol.id['name'] == 'volc':
                 self.assertEqual(vol.sis['compression'], False)
@@ -413,16 +412,15 @@ class SscUtilsTestCase(test.TestCase):
 
     def test_cl_vols_ssc_single(self):
         """Test cluster ssc for single vol."""
-        mox = self.mox
         na_server = api.NaServer('127.0.0.1')
         vserver = 'openstack'
         test_vols = set([copy.deepcopy(self.vol1)])
         sis = {'vola': {'dedup': False, 'compression': False}}
 
-        mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
-        mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
-        mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
-        mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
+        self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
+        self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
+        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
+        self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
         ssc_utils.query_cluster_vols_for_ssc(
             na_server, vserver, 'vola').AndReturn(test_vols)
         ssc_utils.get_sis_vol_dict(
@@ -431,30 +429,29 @@ class SscUtilsTestCase(test.TestCase):
         ssc_utils.query_aggr_options(
             na_server, 'aggr1').AndReturn(raiddp)
         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(
             na_server, vserver, volume='vola')
 
-        mox.VerifyAll()
+        self.mox.VerifyAll()
         self.assertEqual(len(res_vols), 1)
 
     def test_get_cluster_ssc(self):
         """Test get cluster ssc map."""
-        mox = self.mox
         na_server = api.NaServer('127.0.0.1')
         vserver = 'openstack'
         test_vols = set(
             [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(
             na_server, vserver).AndReturn(test_vols)
-        mox.ReplayAll()
+        self.mox.ReplayAll()
 
         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['dedup']), 3)
         self.assertEqual(len(res_map['compression']), 1)
index f9227f329d3ea060f835038e2e677a1a3d619892..f07743565eaea834f0226d52498800d594ef015c 100644 (file)
@@ -829,7 +829,7 @@ class OnFailureRescheduleTask(base.CinderTask):
         ]
 
     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:
             exc_type = type(cause.exc)
         if not exc_type:
diff --git a/tox.ini b/tox.ini
index 29cbcc513c9ff9c1e0984f2d9ed062a87e932544..0ed6211bb03348c5c23b5ba80f6ae7d156617f5c 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -44,6 +44,6 @@ commands =
 commands = {posargs}
 
 [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 = _
 exclude = .git,.venv,.tox,dist,doc,common,*egg,build