]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Enable flake8 F841 checking
authorAlexander Bochkarev <abochkarev@mirantis.com>
Thu, 20 Feb 2014 11:26:04 +0000 (15:26 +0400)
committerAlexander Bochkarev <abochkarev@mirantis.com>
Tue, 1 Apr 2014 07:38:35 +0000 (11:38 +0400)
This check looks to see whether a local variable
is unused. This change fixed all violators of said check.

Change-Id: Iba4ab2b2a172d0c8b90ba29be33ebb129fce5e6b

51 files changed:
cinder/db/sqlalchemy/api.py
cinder/db/sqlalchemy/migrate_repo/versions/003_glance_metadata.py
cinder/db/sqlalchemy/migrate_repo/versions/009_add_snapshot_metadata_table.py
cinder/db/sqlalchemy/migrate_repo/versions/010_add_transfers_table.py
cinder/db/sqlalchemy/migrate_repo/versions/020_add_volume_admin_metadata_table.py
cinder/scheduler/manager.py
cinder/test.py
cinder/tests/api/contrib/test_admin_actions.py
cinder/tests/api/openstack/test_wsgi.py
cinder/tests/api/v1/test_limits.py
cinder/tests/api/v1/test_volumes.py
cinder/tests/compute/test_nova.py
cinder/tests/scheduler/test_scheduler_options.py
cinder/tests/test_backup.py
cinder/tests/test_backup_ceph.py
cinder/tests/test_backup_tsm.py
cinder/tests/test_db_api.py
cinder/tests/test_emc_smis.py
cinder/tests/test_glusterfs.py
cinder/tests/test_gpfs.py
cinder/tests/test_hp3par.py
cinder/tests/test_netapp.py
cinder/tests/test_netapp_nfs.py
cinder/tests/test_qos_specs.py
cinder/tests/test_rbd.py
cinder/tests/test_vmware_vmdk.py
cinder/tests/test_volume.py
cinder/tests/test_volume_glance_metadata.py
cinder/tests/test_volume_rpcapi.py
cinder/tests/test_volume_types.py
cinder/tests/test_wsgi.py
cinder/tests/test_xenapi_sm.py
cinder/tests/test_zadara.py
cinder/tests/zonemanager/test_brcd_fc_san_lookup_service.py
cinder/utils.py
cinder/volume/drivers/emc/emc_smis_fc.py
cinder/volume/drivers/emc/emc_smis_iscsi.py
cinder/volume/drivers/hds/hds.py
cinder/volume/drivers/huawei/huawei_utils.py
cinder/volume/drivers/huawei/ssh_common.py
cinder/volume/drivers/lvm.py
cinder/volume/drivers/netapp/nfs.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp/hp_3par_fc.py
cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py
cinder/volume/drivers/san/hp/hp_msa_common.py
cinder/volume/drivers/san/san.py
cinder/volume/drivers/xenapi/lib.py
cinder/volume/drivers/xenapi/sm.py
cinder/volume/manager.py
tox.ini

index e73b7324b0fba3008047ee7f8fe70472cc5819c6..16a0402b4117ddf5595f3a1f7ace93cc894bf6e9 100644 (file)
@@ -1759,7 +1759,7 @@ def snapshot_metadata_update(context, snapshot_id, metadata, delete):
             try:
                 meta_ref = _snapshot_metadata_get_item(context, snapshot_id,
                                                        meta_key, session)
-            except exception.SnapshotMetadataNotFound as e:
+            except exception.SnapshotMetadataNotFound:
                 meta_ref = models.SnapshotMetadata()
                 item.update({"key": meta_key, "snapshot_id": snapshot_id})
 
@@ -2054,7 +2054,7 @@ def volume_type_extra_specs_update_or_create(context, volume_type_id,
             try:
                 spec_ref = _volume_type_extra_specs_get_item(
                     context, volume_type_id, key, session)
-            except exception.VolumeTypeExtraSpecsNotFound as e:
+            except exception.VolumeTypeExtraSpecsNotFound:
                 spec_ref = models.VolumeTypeExtraSpecs()
             spec_ref.update({"key": key, "value": value,
                              "volume_type_id": volume_type_id,
@@ -2328,7 +2328,7 @@ def qos_specs_update(context, qos_specs_id, specs):
             try:
                 spec_ref = _qos_specs_get_item(
                     context, qos_specs_id, key, session)
-            except exception.QoSSpecsKeyNotFound as e:
+            except exception.QoSSpecsKeyNotFound:
                 spec_ref = models.QualityOfServiceSpecs()
             id = None
             if spec_ref.get('id', None):
@@ -2794,7 +2794,6 @@ def transfer_accept(context, transfer_id, user_id, project_id):
         volume_id = transfer_ref['volume_id']
         volume_ref = _volume_get(context, volume_id, session=session)
         if volume_ref['status'] != 'awaiting-transfer':
-            volume_status = volume_ref['status']
             msg = _('Transfer %(transfer_id)s: Volume id %(volume_id)s in '
                     'unexpected state %(status)s, expected '
                     'awaiting-transfer') % {'transfer_id': transfer_id,
index 1974c8cbf1833d12b95c481c4016722d0e9731df..7aae5d66256c21fb266462ab0a7d69efde9d5580 100644 (file)
@@ -27,16 +27,14 @@ def upgrade(migrate_engine):
     # Just for the ForeignKey and column creation to succeed, these are not the
     # actual definitions of tables .
     #
-    volumes = Table('volumes',
-                    meta,
-                    Column('id', Integer(),
-                           primary_key=True, nullable=False),
-                    mysql_engine='InnoDB')
-    snapshots = Table('snapshots',
-                      meta,
-                      Column('id', Integer(),
-                             primary_key=True, nullable=False),
-                      mysql_engine='InnoDB')
+    Table('volumes',
+          meta,
+          Column('id', Integer(), primary_key=True, nullable=False),
+          mysql_engine='InnoDB')
+    Table('snapshots',
+          meta,
+          Column('id', Integer(), primary_key=True, nullable=False),
+          mysql_engine='InnoDB')
     # Create new table
     volume_glance_metadata = Table(
         'volume_glance_metadata',
index 4c7f453e15934f716899e63b9b36d195da5a39dc..69a2fe7150c1a6512f5370e986abee5bef5d67bb 100644 (file)
@@ -22,7 +22,7 @@ def upgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
 
-    snapshots = Table('snapshots', meta, autoload=True)
+    Table('snapshots', meta, autoload=True)
 
     # New table
     snapshot_metadata = Table(
index dddd9cc4c3a9437fa3842ae05639b01a560ab978..8b1b1b8ee825a403e262c1cee00d378b269fa9d7 100644 (file)
@@ -22,7 +22,7 @@ def upgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
 
-    volumes = Table('volumes', meta, autoload=True)
+    Table('volumes', meta, autoload=True)
 
     # New table
     transfers = Table(
index f66f09ddee7c393c6ead6b19a3430d1edc612f92..701ff8a5b36f2dd2e6201ceb6863263d873a1bb2 100644 (file)
@@ -22,7 +22,7 @@ def upgrade(migrate_engine):
     meta = MetaData()
     meta.bind = migrate_engine
 
-    _volumes = Table('volumes', meta, autoload=True)
+    Table('volumes', meta, autoload=True)
 
     # New table
     volume_admin_metadata = Table(
index fed6b08dea073387b1351da244d9900cbc2ec12f..fd63761d1cd83895d874c54275240a568633b505 100644 (file)
@@ -199,10 +199,10 @@ class SchedulerManager(manager.Manager):
 
         volume_ref = db.volume_get(context, volume_id)
         try:
-            tgt_host = self.driver.host_passes_filters(context,
-                                                       volume_ref['host'],
-                                                       request_spec,
-                                                       filter_properties)
+            self.driver.host_passes_filters(context,
+                                            volume_ref['host'],
+                                            request_spec,
+                                            filter_properties)
         except exception.NoValidHost as ex:
             _manage_existing_set_error(self, context, ex, request_spec)
         except Exception as ex:
index 7ba8e4942f447f5b6123ea417650769ee5a7f410..2f6b887dfe78cc5413375a2cb64883b64721ef66 100644 (file)
@@ -137,7 +137,6 @@ class TestCase(testtools.TestCase):
         self.addCleanup(rpc.clear_extra_exmods)
         self.addCleanup(rpc.cleanup)
 
-        fs = '%(levelname)s [%(name)s] %(message)s'
         self.messaging_conf = messaging_conffixture.ConfFixture(CONF)
         self.messaging_conf.transport_driver = 'fake'
         self.messaging_conf.response_timeout = 15
index 0952088a49a85384662e6ae4a65f51aef1df606a..0d9e4d1cedb05a547f8214bd27b4f859a6c780a1 100644 (file)
@@ -40,7 +40,6 @@ def app():
 
 
 class AdminActionsTest(test.TestCase):
-
     def setUp(self):
         super(AdminActionsTest, self).setUp()
 
@@ -679,10 +678,10 @@ class AdminActionsTest(test.TestCase):
         expected_status = 400
         expected_id = None
         ctx = context.RequestContext('admin', 'fake', True)
-        volume = self._migrate_volume_comp_exec(ctx, volume1, volume2, False,
-                                                expected_status, expected_id)
-        volume = self._migrate_volume_comp_exec(ctx, volume2, volume1, False,
-                                                expected_status, expected_id)
+        self._migrate_volume_comp_exec(ctx, volume1, volume2, False,
+                                       expected_status, expected_id)
+        self._migrate_volume_comp_exec(ctx, volume2, volume1, False,
+                                       expected_status, expected_id)
 
     def test_migrate_volume_comp_bad_mig_status(self):
         admin_ctx = context.get_admin_context()
@@ -695,8 +694,8 @@ class AdminActionsTest(test.TestCase):
         expected_status = 400
         expected_id = None
         ctx = context.RequestContext('admin', 'fake', True)
-        volume = self._migrate_volume_comp_exec(ctx, volume1, volume2, False,
-                                                expected_status, expected_id)
+        self._migrate_volume_comp_exec(ctx, volume1, volume2, False,
+                                       expected_status, expected_id)
 
     def test_migrate_volume_comp_no_action(self):
         admin_ctx = context.get_admin_context()
index fe7a4404e0b1b222c68a658d492f6be86a219edc..af8658c3122ec2ce9b912ea81e58366a76ac72b4 100644 (file)
@@ -664,12 +664,12 @@ class ResourceTest(test.TestCase):
 
         def extension1(req):
             called.append('pre1')
-            resp_obj = yield
+            yield
             called.append('post1')
 
         def extension2(req):
             called.append('pre2')
-            resp_obj = yield
+            yield
             called.append('post2')
 
         extensions = [extension1, extension2]
@@ -769,11 +769,11 @@ class ResourceTest(test.TestCase):
         called = []
 
         def extension1(req):
-            resp_obj = yield
+            yield
             called.append(1)
 
         def extension2(req):
-            resp_obj = yield
+            yield
             called.append(2)
 
         ext1 = extension1(None)
@@ -798,11 +798,11 @@ class ResourceTest(test.TestCase):
         called = []
 
         def extension1(req):
-            resp_obj = yield
+            yield
             called.append(1)
 
         def extension2(req):
-            resp_obj = yield
+            yield
             called.append(2)
             yield 'foo'
 
@@ -927,19 +927,19 @@ class ValidBodyTest(test.TestCase):
         self.assertTrue(self.controller.is_valid_body(body, 'foo'))
 
     def test_is_valid_body_none(self):
-        resource = wsgi.Resource(controller=None)
+        wsgi.Resource(controller=None)
         self.assertFalse(self.controller.is_valid_body(None, 'foo'))
 
     def test_is_valid_body_empty(self):
-        resource = wsgi.Resource(controller=None)
+        wsgi.Resource(controller=None)
         self.assertFalse(self.controller.is_valid_body({}, 'foo'))
 
     def test_is_valid_body_no_entity(self):
-        resource = wsgi.Resource(controller=None)
+        wsgi.Resource(controller=None)
         body = {'bar': {}}
         self.assertFalse(self.controller.is_valid_body(body, 'foo'))
 
     def test_is_valid_body_malformed_entity(self):
-        resource = wsgi.Resource(controller=None)
+        wsgi.Resource(controller=None)
         body = {'foo': 'bar'}
         self.assertFalse(self.controller.is_valid_body(body, 'foo'))
index 60458cf5f53be24205e656b0eb81203d7c71d918..63bf2b14a160346417b4aa71049d1d30f9efc65e 100644 (file)
@@ -597,7 +597,6 @@ class WsgiLimiterTest(BaseLimitTestSuite):
 
     def test_invalid_methods(self):
         """Only POSTs should work."""
-        requests = []
         for method in ["GET", "PUT", "DELETE", "HEAD", "OPTIONS"]:
             request = webob.Request.blank("/", method=method)
             response = request.get_response(self.app)
index 1dcf653ecf932b21bb416b2c3c1be7ad54892bdf..69911c4cfdd23a90e146065d089d24ed27b22f19 100644 (file)
@@ -127,7 +127,7 @@ class VolumeApiTest(test.TestCase):
         vol.update(dict(volume_type=CONF.default_volume_type))
         body.update(dict(volume=vol))
         res_dict = self.controller.create(req, body)
-        volume_id = res_dict['volume']['id']
+        self.assertIn('id', res_dict['volume'])
         self.assertEqual(len(res_dict), 1)
         self.assertEqual(res_dict['volume']['volume_type'],
                          db_vol_type['name'])
@@ -136,7 +136,7 @@ class VolumeApiTest(test.TestCase):
         vol.update(dict(volume_type=db_vol_type['id']))
         body.update(dict(volume=vol))
         res_dict = self.controller.create(req, body)
-        volume_id = res_dict['volume']['id']
+        self.assertIn('id', res_dict['volume'])
         self.assertEqual(len(res_dict), 1)
         self.assertEqual(res_dict['volume']['volume_type'],
                          db_vol_type['name'])
index 9f8239a750a54f6d000b6b8009fed7d5c4976222..0aff99d7e975845c58d28bd5922ccc3826add46b 100644 (file)
@@ -42,7 +42,6 @@ class NovaApiTestCase(test.TestCase):
         self.mox.StubOutWithMock(nova, 'novaclient')
 
     def test_update_server_volume(self):
-        volume_id = 'volume_id1'
         nova.novaclient(self.ctx).AndReturn(self.novaclient)
         self.mox.StubOutWithMock(self.novaclient.volumes,
                                  'update_server_volume')
index c1073973ef7eb401e5b962e8652dc914701ad6c5..c6e34395bda01c39f624be91696983656f3ba9cd 100644 (file)
@@ -72,7 +72,6 @@ class SchedulerOptionsTestCase(test.TestCase):
         file_old = None
         file_now = datetime.datetime(2012, 1, 1, 1, 1, 1)
 
-        data = dict(a=1, b=2, c=3)
         jdata = ""
 
         fake = FakeSchedulerOptions(last_checked, now, file_old, file_now,
index 94a2d29c50e42571c15306503902850455f29d17..6c8ad0fa80e1a612ea7735b83bbc8e3f8fd85863 100644 (file)
@@ -370,7 +370,7 @@ class BackupTestCase(test.TestCase):
         backups = db.backup_get_all_by_project(self.ctxt, 'project1')
         self.assertEqual(len(backups), 0)
 
-        b1 = self._create_backup_db_entry()
+        self._create_backup_db_entry()
         b2 = self._create_backup_db_entry(project_id='project1')
         backups = db.backup_get_all_by_project(self.ctxt, 'project1')
         self.assertEqual(len(backups), 1)
@@ -505,7 +505,7 @@ class BackupTestCase(test.TestCase):
                                      (backup_driver.__module__,
                                       backup_driver.__class__.__name__,
                                       'verify'))
-        with mock.patch(_mock_backup_verify_class) as _mock_record_verify:
+        with mock.patch(_mock_backup_verify_class):
             self.backup_mgr.import_record(self.ctxt,
                                           imported_record,
                                           export['backup_service'],
index 6298e69c98ba9d84bfcfad6ea15a5850cdbb9cc7..3cb0a5a495ece72af2f3cdea32dd02d06fdaed45 100644 (file)
@@ -459,7 +459,6 @@ class BackupCephTestCase(test.TestCase):
     def test_backup_vol_length_0(self):
         volume_id = str(uuid.uuid4())
         self._create_volume_db_entry(volume_id, 0)
-        volume = db.volume_get(self.ctxt, volume_id)
 
         backup_id = str(uuid.uuid4())
         self._create_backup_db_entry(backup_id, volume_id, 1)
index 6d0040f1e94f28a0cde9103bb013b79ad767d279..7c2b45b30124a466c6643bc7c59ffedcb6de7a19 100644 (file)
@@ -126,8 +126,6 @@ class TSMBackupSimulator:
 
     def _cmd_to_dict(self, arg_list):
         """Convert command for kwargs (assumes a properly formed command)."""
-        path = arg_list[-1]
-        other = arg_list[-2]
         ret = {'cmd': arg_list[0],
                'type': arg_list[1],
                'path': arg_list[-1]}
index 0e9d49cb5607c42336294c5bc3f205d0147856dc..f9cde3079d6792631417d4641e5e34324f74eca9 100644 (file)
@@ -151,7 +151,6 @@ class DBAPIServiceTestCase(BaseTest):
 
     def test_service_get(self):
         service1 = self._create_service({})
-        service2 = self._create_service({'host': 'some_other_fake_host'})
         real_service1 = db.service_get(self.ctxt, service1['id'])
         self._assertEqualObjects(service1, real_service1)
 
@@ -161,7 +160,6 @@ class DBAPIServiceTestCase(BaseTest):
 
     def test_service_get_by_host_and_topic(self):
         service1 = self._create_service({'host': 'host1', 'topic': 'topic1'})
-        service2 = self._create_service({'host': 'host2', 'topic': 'topic2'})
 
         real_service1 = db.service_get_by_host_and_topic(self.ctxt,
                                                          host='host1',
@@ -663,8 +661,8 @@ class DBAPIVolumeTestCase(BaseTest):
         self._assertEqualsVolumeOrderResult([], filters=filters)
 
     def test_volume_get_iscsi_target_num(self):
-        target = db.iscsi_target_create_safe(self.ctxt, {'volume_id': 42,
-                                                         'target_num': 43})
+        db.iscsi_target_create_safe(self.ctxt, {'volume_id': 42,
+                                                'target_num': 43})
         self.assertEqual(43, db.volume_get_iscsi_target_num(self.ctxt, 42))
 
     def test_volume_get_iscsi_target_num_nonexistent(self):
@@ -726,9 +724,9 @@ class DBAPISnapshotTestCase(BaseTest):
         db.volume_create(self.ctxt, {'id': 1,
                                      'project_id': 'project1',
                                      'size': 42})
-        snapshot = db.snapshot_create(self.ctxt, {'id': 1, 'volume_id': 1,
-                                                  'project_id': 'project1',
-                                                  'volume_size': 42})
+        db.snapshot_create(self.ctxt, {'id': 1, 'volume_id': 1,
+                                       'project_id': 'project1',
+                                       'volume_size': 42})
         actual = db.snapshot_data_get_for_project(self.ctxt, 'project1')
         self.assertEqual(actual, (1, 42))
 
@@ -1002,7 +1000,7 @@ class DBAPIReservationTestCase(BaseTest):
     def test_reservation_expire(self):
         self.values['expire'] = datetime.datetime.utcnow() + \
             datetime.timedelta(days=1)
-        reservations = _quota_reserve(self.ctxt, 'project1')
+        _quota_reserve(self.ctxt, 'project1')
         db.reservation_expire(self.ctxt)
 
         expected = {'project_id': 'project1',
@@ -1048,8 +1046,8 @@ class DBAPIQuotaClassTestCase(BaseTest):
                           'nonexistent')
 
     def test_quota_class_get_all_by_name(self):
-        sample1 = db.quota_class_create(self.ctxt, 'test2', 'res1', 43)
-        sample2 = db.quota_class_create(self.ctxt, 'test2', 'res2', 44)
+        db.quota_class_create(self.ctxt, 'test2', 'res1', 43)
+        db.quota_class_create(self.ctxt, 'test2', 'res2', 44)
         self.assertEqual({'class_name': 'test_qc', 'test_resource': 42},
                          db.quota_class_get_all_by_name(self.ctxt, 'test_qc'))
         self.assertEqual({'class_name': 'test2', 'res1': 43, 'res2': 44},
@@ -1061,8 +1059,8 @@ class DBAPIQuotaClassTestCase(BaseTest):
         self.assertEqual(43, updated['hard_limit'])
 
     def test_quota_class_destroy_all_by_name(self):
-        sample1 = db.quota_class_create(self.ctxt, 'test2', 'res1', 43)
-        sample2 = db.quota_class_create(self.ctxt, 'test2', 'res2', 44)
+        db.quota_class_create(self.ctxt, 'test2', 'res1', 43)
+        db.quota_class_create(self.ctxt, 'test2', 'res2', 44)
         db.quota_class_destroy_all_by_name(self.ctxt, 'test2')
         self.assertEqual({'class_name': 'test2'},
                          db.quota_class_get_all_by_name(self.ctxt, 'test2'))
@@ -1155,7 +1153,7 @@ class DBAPIQuotaTestCase(BaseTest):
                           'nonexitent_resource')
 
     def test_quota_usage_get(self):
-        reservations = _quota_reserve(self.ctxt, 'p1')
+        _quota_reserve(self.ctxt, 'p1')
         quota_usage = db.quota_usage_get(self.ctxt, 'p1', 'gigabytes')
         expected = {'resource': 'gigabytes', 'project_id': 'p1',
                     'in_use': 0, 'reserved': 2, 'total': 2}
@@ -1163,7 +1161,7 @@ class DBAPIQuotaTestCase(BaseTest):
             self.assertEqual(value, quota_usage[key], key)
 
     def test_quota_usage_get_all_by_project(self):
-        reservations = _quota_reserve(self.ctxt, 'p1')
+        _quota_reserve(self.ctxt, 'p1')
         expected = {'project_id': 'p1',
                     'volumes': {'in_use': 0, 'reserved': 1},
                     'gigabytes': {'in_use': 0, 'reserved': 2}}
index 9bbde8acc700c714b23e8bd89206a8e3ba26d2ff..20a1767b69d751623b801f835699b687a53d0fa5 100644 (file)
@@ -25,7 +25,6 @@ import mock
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder import test
-from cinder import units
 from cinder.volume.drivers.emc.emc_smis_common import EMCSMISCommon
 from cinder.volume.drivers.emc.emc_smis_fc import EMCSMISFCDriver
 from cinder.volume.drivers.emc.emc_smis_iscsi import EMCSMISISCSIDriver
@@ -998,9 +997,8 @@ class EMCSMISISCSIDriverTestCase(test.TestCase):
     def test_map_unmap(self):
         self.driver.create_volume(self.data.test_volume)
         self.data.test_volume['EMCCurrentOwningStorageProcessor'] = 'SP_A'
-        connection_info = self.driver.initialize_connection(
-            self.data.test_volume,
-            self.data.connector)
+        self.driver.initialize_connection(self.data.test_volume,
+                                          self.data.connector)
         self.driver.terminate_connection(self.data.test_volume,
                                          self.data.connector)
         self.driver.delete_volume(self.data.test_volume)
@@ -1229,16 +1227,15 @@ class EMCSMISFCDriverTestCase(test.TestCase):
 
         vol_instance = self.driver.common._find_lun(self.data.test_volume)
 
-        expected = [
-            mock.call._get_ecom_connection(),
-            mock.call.find_device_number(self.data.test_volume),
-            mock.call._find_lun(self.data.test_volume),
-            mock.call.self._find_controller_configuration_service(
-                self.data.storage_system),
-            mock.call._remove_members(conf_service, vol_instance),
-            mock.call.get_target_wwns(
-                self.data.storage_system,
-                self.data.connector)]
+        mock.call._get_ecom_connection(),
+        mock.call.find_device_number(self.data.test_volume),
+        mock.call._find_lun(self.data.test_volume),
+        mock.call.self._find_controller_configuration_service(
+            self.data.storage_system),
+        mock.call._remove_members(conf_service, vol_instance),
+        mock.call.get_target_wwns(
+            self.data.storage_system,
+            self.data.connector)
 
         output = {
             'driver_volume_type': 'fibre_channel',
@@ -1356,29 +1353,6 @@ class EMCSMISFCDriverTestCase(test.TestCase):
         volume_with_vt['volume_type_id'] = 1
         self.driver.create_volume(volume_with_vt)
 
-        configservice = {'CreationClassName':
-                         'Clar_StorageConfigurationService',
-                         'SystemName': 'CLARiiON+APM00123456789'}
-
-        pool = {'InstanceID': 'CLARiiON+APM00123456789+U+gold',
-                'CreationClassName': 'Clar_UnifiedStoragePool'}
-
-        volumesize = int(volume_with_vt['size']) * units.GiB
-
-        storage_type = {'storagetype:provisioning': 'thick',
-                        'storagetype:pool': 'gold'}
-
-        expected = [
-            mock.call._get_storage_type(volume_with_vt),
-            mock.call._find_pool('gold'),
-            mock.call.get_provisioning(storage_type),
-            mock.call.InvokeMethod('CreateOrModifyElementFromStoragePool',
-                                   configservice, volume_with_vt['name'],
-                                   pool,
-                                   self.driver.common._getnum(2, '16'),
-                                   self.driver.common._getnum(volumesize,
-                                                              '64'))]
-
     def _cleanup(self):
         bExists = os.path.exists(self.config_file_path)
         if bExists:
index 94dbd8b1b363d9a0dc153819853d09959548fd29..fc294d5dd561c854407cccdcb5f948ad75cc6b20 100644 (file)
@@ -762,7 +762,6 @@ class GlusterFsDriverTestCase(test.TestCase):
         mox.StubOutWithMock(drv, '_execute')
 
         vol_filename = 'volume-%s' % self.VOLUME_UUID
-        snap_filename = '%s.%s' % (vol_filename, self.SNAP_UUID)
 
         hashed = drv._get_hash_str(self.TEST_EXPORT1)
         vol_path = '%s/%s/%s' % (self.TEST_MNT_POINT_BASE,
@@ -777,12 +776,6 @@ class GlusterFsDriverTestCase(test.TestCase):
 
         drv._create_qcow2_snap_file(snap_ref, vol_filename, snap_path)
 
-        qemu_img_info_output = ("""image: volume-%s
-        file format: raw
-        virtual size: 1.0G (1073741824 bytes)
-        disk size: 152K
-        """ % self.VOLUME_UUID, '')
-
         drv._read_info_file(info_path, empty_if_missing=True).\
             AndReturn(info_dict)
 
@@ -825,7 +818,6 @@ class GlusterFsDriverTestCase(test.TestCase):
                                            self.VOLUME_UUID)
         volume_filename = 'volume-%s' % self.VOLUME_UUID
 
-        snap_path = '%s.%s' % (volume_path, self.SNAP_UUID)
         snap_path_2 = '%s.%s' % (volume_path, self.SNAP_UUID_2)
         snap_file = '%s.%s' % (volume_filename, self.SNAP_UUID)
         snap_file_2 = '%s.%s' % (volume_filename, self.SNAP_UUID_2)
@@ -861,13 +853,6 @@ class GlusterFsDriverTestCase(test.TestCase):
                     'volume': self._simple_volume(),
                     'id': self.SNAP_UUID_2}
 
-        snap_path_2_chain = [{self.SNAP_UUID_2: snap_file_2},
-                             {self.SNAP_UUID: snap_file},
-                             {'active': snap_file_2}]
-
-        snap_path_chain = [{self.SNAP_UUID: snap_file},
-                           {'active': snap_file}]
-
         drv._read_info_file(info_path, empty_if_missing=True).\
             AndReturn(info_file_dict)
 
@@ -914,20 +899,11 @@ class GlusterFsDriverTestCase(test.TestCase):
                                     hashed,
                                     volume_file)
 
-        info_path = '%s%s' % (volume_path, '.info')
         snap_path = '%s.%s' % (volume_path, self.SNAP_UUID)
         snap_file = 'volume-%s.%s' % (self.VOLUME_UUID, self.SNAP_UUID)
         snap_path_2 = '%s.%s' % (volume_path, self.SNAP_UUID_2)
         snap_file_2 = 'volume-%s.%s' % (self.VOLUME_UUID, self.SNAP_UUID_2)
 
-        qemu_img_info_output_snap_2 = """image: volume-%s.%s
-        file format: qcow2
-        virtual size: 1.0G (1073741824 bytes)
-        disk size: 173K
-        backing file: %s
-        """ % (self.VOLUME_UUID, self.SNAP_UUID_2,
-               'volume-%s.%s' % (self.VOLUME_UUID, self.SNAP_UUID_2))
-
         qemu_img_info_output_snap_1 = """image: volume-%s.%s
         file format: qcow2
         virtual size: 1.0G (1073741824 bytes)
@@ -936,12 +912,6 @@ class GlusterFsDriverTestCase(test.TestCase):
         """ % (self.VOLUME_UUID, self.SNAP_UUID,
                'volume-%s.%s' % (self.VOLUME_UUID, self.SNAP_UUID))
 
-        qemu_img_info_output = """image: volume-%s
-        file format: qcow2
-        virtual size: 1.0G (1073741824 bytes)
-        disk size: 175K
-        """ % self.VOLUME_UUID
-
         mox.StubOutWithMock(drv, '_execute')
         mox.StubOutWithMock(drv, '_read_info_file')
         mox.StubOutWithMock(drv, '_write_info_file')
@@ -1337,7 +1307,6 @@ class GlusterFsDriverTestCase(test.TestCase):
         info_path = '%s.info' % volume_path
 
         snap_path = '%s.%s' % (volume_path, self.SNAP_UUID)
-        snap_path_2 = '%s.%s' % (volume_path, self.SNAP_UUID_2)
         snap_file = '%s.%s' % (volume_file, self.SNAP_UUID)
         snap_file_2 = '%s.%s' % (volume_file, self.SNAP_UUID_2)
 
index b5d0d978bb4335fa3db777b9f3145e3e083f8e40..2afd678e53fb0d0d610ece1c936da100f2564b6d 100644 (file)
@@ -139,7 +139,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_fs_from_path_ok(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('Filesystem           1K-blocks      '
                                   'Used Available Use%% Mounted on\n'
                                   '%s             10485760    531968   9953792'
@@ -150,7 +149,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_fs_from_path_fail_path(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('Filesystem           1K-blocks      '
                                   'Used Available Use% Mounted on\n'
                                   'test             10485760    531968   '
@@ -160,7 +158,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_fs_from_path_fail_raise(self, mock_exec):
-        ctxt = self.context
         mock_exec.side_effect = processutils.ProcessExecutionError(
             stdout='test', stderr='test')
         self.assertRaises(exception.VolumeBackendAPIException,
@@ -168,7 +165,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_gpfs_cluster_id_ok(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('mmlsconfig::HEADER:version:reserved:'
                                   'reserved:configParameter:value:nodeList:\n'
                                   'mmlsconfig::0:1:::clusterId:%s::'
@@ -178,7 +174,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_gpfs_cluster_id_fail_id(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('mmlsconfig::HEADER.:version:reserved:'
                                   'reserved:configParameter:value:nodeList:\n'
                                   'mmlsconfig::0:1:::clusterId:test::', '')
@@ -187,7 +182,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_get_gpfs_cluster_id_fail_raise(self, mock_exec):
-        ctxt = self.context
         mock_exec.side_effect = processutils.ProcessExecutionError(
             stdout='test', stderr='test')
         self.assertRaises(exception.VolumeBackendAPIException,
@@ -231,7 +225,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_verify_gpfs_pool_ok(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('Storage pools in file system at \'/gpfs0\':'
                                   '\n'
                                   'Name                    Id   BlkSize Data '
@@ -247,7 +240,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_verify_gpfs_pool_fail_pool(self, mock_exec):
-        ctxt = self.context
         mock_exec.return_value = ('Storage pools in file system at \'/gpfs0\':'
                                   '\n'
                                   'Name                    Id   BlkSize Data '
@@ -263,7 +255,6 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.utils.execute')
     def test_verify_gpfs_pool_fail_raise(self, mock_exec):
-        ctxt = self.context
         mock_exec.side_effect = processutils.ProcessExecutionError(
             stdout='test', stderr='test')
         self.assertFalse(self.driver._verify_gpfs_pool('/dev/gpfs'))
@@ -990,10 +981,8 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver._is_gpfs_path')
     def test_is_cloneable_ok(self, mock_is_gpfs_path):
-        org_value_share_mode = self.driver.configuration.gpfs_images_share_mode
         self.flags(volume_driver=self.driver_name,
                    gpfs_images_share_mode='test')
-        org_value_dir = CONF.gpfs_images_dir
         CONF.gpfs_images_dir = self.images_dir
         mock_is_gpfs_path.return_value = None
         self.assertEqual((True, None, os.path.join(CONF.gpfs_images_dir,
@@ -1002,9 +991,7 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver._is_gpfs_path')
     def test_is_cloneable_fail_config(self, mock_is_gpfs_path):
-        org_value_share_mode = self.driver.configuration.gpfs_images_share_mode
         self.flags(volume_driver=self.driver_name, gpfs_images_share_mode='')
-        org_value_dir = CONF.gpfs_images_dir
         CONF.gpfs_images_dir = ''
         mock_is_gpfs_path.return_value = None
         self.assertNotEqual((True, None, os.path.join(CONF.gpfs_images_dir,
@@ -1013,10 +1000,8 @@ class GPFSDriverTestCase(test.TestCase):
 
     @patch('cinder.volume.drivers.ibm.gpfs.GPFSDriver._is_gpfs_path')
     def test_is_cloneable_fail_path(self, mock_is_gpfs_path):
-        org_value_share_mode = self.driver.configuration.gpfs_images_share_mode
         self.flags(volume_driver=self.driver_name,
                    gpfs_images_share_mode='test')
-        org_value_dir = CONF.gpfs_images_dir
         CONF.gpfs_images_dir = self.images_dir
         mock_is_gpfs_path.side_effect = (
             processutils.ProcessExecutionError(stdout='test', stderr='test'))
@@ -1421,7 +1406,7 @@ class GPFSDriverTestCase(test.TestCase):
         old_type_ref = volume_types.create(ctxt, 'old', key_specs_old)
         new_type_ref = volume_types.create(ctxt, 'new', key_specs_new)
 
-        old_type = volume_types.get_volume_type(ctxt, old_type_ref['id'])
+        volume_types.get_volume_type(ctxt, old_type_ref['id'])
         new_type = volume_types.get_volume_type(ctxt, new_type_ref['id'])
 
         diff, equal = volume_types.volume_types_diff(ctxt,
index d8f38273a7b39a991272451ff66e6f83a2c6d64e..119f6c4040bcea9261ca9a330e3f988f1db8fbd0 100644 (file)
@@ -362,7 +362,7 @@ class HP3PARBaseDriver(object):
                 'serialNumber': 'different'},
         }
 
-        mock_client = self.setup_driver(mock_conf=conf)
+        self.setup_driver(mock_conf=conf)
 
         volume = {'name': HP3PARBaseDriver.VOLUME_NAME,
                   'id': HP3PARBaseDriver.CLONE_ID,
@@ -393,7 +393,7 @@ class HP3PARBaseDriver(object):
             lambda x: {'OpenStackCPG': {'domain': 'OpenStack'}}.get(x, {})
         }
 
-        mock_client = self.setup_driver(mock_conf=conf)
+        self.setup_driver(mock_conf=conf)
 
         volume = {'name': HP3PARBaseDriver.VOLUME_NAME,
                   'id': HP3PARBaseDriver.CLONE_ID,
@@ -650,7 +650,7 @@ class HP3PARBaseDriver(object):
             'getVolume.return_value': {}
         }
 
-        mock_client = self.setup_driver(mock_conf=conf)
+        self.setup_driver(mock_conf=conf)
 
         volume = self.volume.copy()
         volume['size'] = self.volume['size'] + 10
@@ -821,7 +821,7 @@ class HP3PARBaseDriver(object):
             'growVolume.side_effect': extend_ex
         }
 
-        mock_client = self.setup_driver(mock_conf=conf)
+        self.setup_driver(mock_conf=conf)
         grow_size = 3
         old_size = self.volume['size']
         new_size = old_size + grow_size
index 6a8c655374af4005aa51a649a569a1efac2f6386..74c9f9be73d93bcb6e6abbcf67da388b50d445f7 100644 (file)
@@ -668,7 +668,7 @@ class NetAppDriverNegativeTestCase(test.TestCase):
         configuration = create_configuration()
         configuration.netapp_storage_family = 'xyz_abc'
         try:
-            driver = common.NetAppDriver(configuration=configuration)
+            common.NetAppDriver(configuration=configuration)
             raise AssertionError('Wrong storage family is getting accepted.')
         except exception.InvalidInput:
             pass
@@ -678,7 +678,7 @@ class NetAppDriverNegativeTestCase(test.TestCase):
         configuration.netapp_storage_family = 'ontap'
         configuration.netapp_storage_protocol = 'ontap'
         try:
-            driver = common.NetAppDriver(configuration=configuration)
+            common.NetAppDriver(configuration=configuration)
             raise AssertionError('Wrong storage protocol is getting accepted.')
         except exception.InvalidInput:
             pass
@@ -690,7 +690,7 @@ class NetAppDriverNegativeTestCase(test.TestCase):
         configuration.netapp_storage_family = 'test_family'
         configuration.netapp_storage_protocol = 'iscsi'
         try:
-            driver = common.NetAppDriver(configuration=configuration)
+            common.NetAppDriver(configuration=configuration)
             raise AssertionError('Non NetApp driver is getting instantiated.')
         except exception.InvalidInput:
             pass
index bf520b78383d1f2496c9f1eb4ef09c37cb03f3fd..f5de6b1ef851aa0316d9f6d359fa6450785f6f78 100644 (file)
@@ -818,7 +818,6 @@ class NetappDirectCmodeNfsDriverOnlyTestCase(test.TestCase):
         extra_specs = {}
         mock_volume_extra_specs.return_value = extra_specs
         fake_share = 'localhost:myshare'
-        fake_qos_policy = 'qos_policy_1'
         with mock.patch.object(drv, '_ensure_shares_mounted'):
             with mock.patch.object(drv, '_find_shares',
                                    return_value=['localhost:myshare']):
index b147e235d3b9efffaec238f6b07ca891d8bac1b0..bf8d7a416b1405547d1048a1498bdbedad07bccb 100644 (file)
@@ -376,7 +376,7 @@ class QoSSpecsTestCase(test.TestCase):
                  'key2': 'value2',
                  'key3': 'value3',
                  'consumer': 'back-end'}
-        id = self._create_qos_specs(one_time_value, input)
+        self._create_qos_specs(one_time_value, input)
         specs = qos_specs.get_qos_specs_by_name(self.ctxt,
                                                 one_time_value)
         self.assertEqual(specs['specs']['key1'], one_time_value)
index c9baa64a6102d4a21ebf1eadf21121e63f254790..a527fa6b4dbde79f4272bdd2dd2d6815d4348e54 100644 (file)
@@ -943,8 +943,7 @@ class ManagedRBDTestCase(DriverTestCase):
         with mock.patch.object(self.volume.driver, 'clone_image') as \
                 mock_clone_image:
             mock_clone_image.side_effect = exception.CinderException
-            with mock.patch.object(self.volume.driver, 'create_volume') as \
-                    mock_create:
+            with mock.patch.object(self.volume.driver, 'create_volume'):
                 with mock.patch.object(create_volume.CreateVolumeFromSpecTask,
                                        '_copy_image_to_volume') as mock_copy:
                     self._create_volume_from_image('error', raw=True,
index f27aa206166dcfdfdb0b7e2089cb361cb23fdd60..b8cb47825022cec17d3d2cb075f8ca61168a1c55 100644 (file)
@@ -308,7 +308,7 @@ class VMwareEsxVmdkDriverTestCase(test.TestCase):
         self._driver.volumeops = self._volumeops
 
         backing = FakeMor('VirtualMachine', 'my_vm')
-        task = FakeMor('Task', 'my_task')
+        FakeMor('Task', 'my_task')
 
         m.StubOutWithMock(self._volumeops, 'get_backing')
         m.StubOutWithMock(self._volumeops, 'delete_backing')
@@ -1468,7 +1468,6 @@ class VMwareVcVmdkDriverTestCase(VMwareEsxVmdkDriverTestCase):
         m.StubOutWithMock(self._driver, '_get_folder_ds_summary')
         folder = FakeMor('Folder', 'my_fol')
         summary = FakeDatastoreSummary(1, 1, datastore1)
-        size = 1
         self._driver._get_folder_ds_summary(volume, resource_pool,
                                             [datastore1]).AndReturn((folder,
                                                                      summary))
index 99752f6596daa3bfd4cfeb48c42a977d1f2ccea7..e8246eddffa2b36351b4215a95c40e52651005ae 100644 (file)
@@ -818,7 +818,6 @@ class VolumeTestCase(BaseVolumeTestCase):
                                             source_volid=src_vol_id,
                                             **self.volume_params)
         dst_vol_id = dst_vol['id']
-        admin_ctxt = context.get_admin_context()
 
         orig_elevated = self.context.elevated
 
@@ -868,7 +867,6 @@ class VolumeTestCase(BaseVolumeTestCase):
                                             source_volid=src_vol_id,
                                             **self.volume_params)
         dst_vol_id = dst_vol['id']
-        admin_ctxt = context.get_admin_context()
 
         orig_elevated = self.context.elevated
 
@@ -2595,7 +2593,7 @@ class GetActiveByWindowTestCase(BaseVolumeTestCase):
 
     def test_snapshot_get_active_by_window(self):
         # Find all all snapshots valid within a timeframe window.
-        vol = db.volume_create(self.context, {'id': 1})
+        db.volume_create(self.context, {'id': 1})
         for i in range(5):
             self.db_attrs[i]['volume_id'] = 1
 
index a3578730c224206d0a1a7a87428d01e98aba9fb1..dec95ac6d363d0d37f54c739aa9b63291298ae64 100644 (file)
@@ -41,16 +41,10 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
         ctxt = context.get_admin_context()
         db.volume_create(ctxt, {'id': 1})
         db.volume_create(ctxt, {'id': 2})
-        vol_metadata = db.volume_glance_metadata_create(ctxt, 1, 'key1',
-                                                        'value1')
-        vol_metadata = db.volume_glance_metadata_create(ctxt, 2, 'key1',
-                                                        'value1')
-        vol_metadata = db.volume_glance_metadata_create(ctxt, 2,
-                                                        'key2',
-                                                        'value2')
-        vol_metadata = db.volume_glance_metadata_create(ctxt, 2,
-                                                        'key3',
-                                                        123)
+        db.volume_glance_metadata_create(ctxt, 1, 'key1', 'value1')
+        db.volume_glance_metadata_create(ctxt, 2, 'key1', 'value1')
+        db.volume_glance_metadata_create(ctxt, 2, 'key2', 'value2')
+        db.volume_glance_metadata_create(ctxt, 2, 'key3', 123)
 
         expected_metadata_1 = {'volume_id': '1',
                                'key': 'key1',
@@ -110,8 +104,7 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
         ctxt = context.get_admin_context()
         db.volume_create(ctxt, {'id': 1})
         db.volume_glance_metadata_delete_by_volume(ctxt, 1)
-        vol_metadata = db.volume_glance_metadata_create(ctxt, 1, 'key1',
-                                                        'value1')
+        db.volume_glance_metadata_create(ctxt, 1, 'key1', 'value1')
         db.volume_glance_metadata_delete_by_volume(ctxt, 1)
         self.assertRaises(exception.GlanceMetadataNotFound,
                           db.volume_glance_metadata_get, ctxt, 1)
@@ -120,8 +113,7 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
         ctxt = context.get_admin_context()
         db.volume_create(ctxt, {'id': 1})
         db.snapshot_create(ctxt, {'id': 100, 'volume_id': 1})
-        vol_meta = db.volume_glance_metadata_create(ctxt, 1, 'key1',
-                                                    'value1')
+        db.volume_glance_metadata_create(ctxt, 1, 'key1', 'value1')
         db.volume_glance_metadata_copy_to_snapshot(ctxt, 100, 1)
 
         expected_meta = {'snapshot_id': '100',
@@ -136,8 +128,7 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
         ctxt = context.get_admin_context()
         db.volume_create(ctxt, {'id': 1})
         db.volume_create(ctxt, {'id': 100, 'source_volid': 1})
-        vol_meta = db.volume_glance_metadata_create(ctxt, 1, 'key1',
-                                                    'value1')
+        db.volume_glance_metadata_create(ctxt, 1, 'key1', 'value1')
         db.volume_glance_metadata_copy_from_volume_to_volume(ctxt, 1, 100)
 
         expected_meta = {'key': 'key1',
index 8afc8527791fb750dd7c40209acd5ac5bfc3085b..51078b65aa82598c9537879cac4abaa83f6a906d 100644 (file)
@@ -110,8 +110,6 @@ class VolumeRpcAPITestCase(test.TestCase):
         self.fake_args = None
         self.fake_kwargs = None
 
-        real_prepare = rpcapi.client.prepare
-
         def _fake_prepare_method(*args, **kwds):
             for kwd in kwds:
                 self.assertEqual(kwds[kwd], target[kwd])
index 02ca94b91a8e64b4872db66f42cf84c0d0c597a6..8b464cd1f28e2febe56aaafb48be62d0f34c7cc2 100644 (file)
@@ -84,9 +84,7 @@ class VolumeTypeTestCase(test.TestCase):
 
     def test_get_default_volume_type(self):
         """Ensures default volume type can be retrieved."""
-        type_ref = volume_types.create(self.ctxt,
-                                       conf_fixture.def_vol_type,
-                                       {})
+        volume_types.create(self.ctxt, conf_fixture.def_vol_type, {})
         default_vol_type = volume_types.get_default_volume_type()
         self.assertEqual(default_vol_type.get('name'),
                          conf_fixture.def_vol_type)
@@ -95,7 +93,6 @@ class VolumeTypeTestCase(test.TestCase):
         """Ensures proper exception raised if default volume type
         is not in database.
         """
-        session = db_api.get_session()
         default_vol_type = volume_types.get_default_volume_type()
         self.assertEqual(default_vol_type, {})
 
index c637117233f52f3cb4c62898f8f64be9da2ee4bd..269ffc8e344554654377cc07f130b4a682bf134d 100644 (file)
@@ -253,8 +253,6 @@ class ExceptionTest(test.TestCase):
         class ExceptionWithNoneCode(Exception):
             code = None
 
-        msg = 'Internal Server Error'
-
         @webob.dec.wsgify
         def fail(req):
             raise ExceptionWithNoneCode()
index 51c7cf11dd8f7feaa04906df3cca745a38443ace..8b6d00c6c35e8ae92b7bcd6276154875f15c1c84 100644 (file)
@@ -121,8 +121,7 @@ class DriverTestCase(test.TestCase):
         ops.delete_volume('server', 'path', 'sr_uuid', 'vdi_uuid')
 
         mock.ReplayAll()
-        result = drv.delete_volume(dict(
-            provider_location='sr_uuid/vdi_uuid'))
+        drv.delete_volume(dict(provider_location='sr_uuid/vdi_uuid'))
         mock.VerifyAll()
 
     def test_create_export_does_not_raise_exception(self):
index 2dd23930275075f6d347f8c2115d448770d9c97c..618889846849df4c7b682935c83295cf9cf24458 100644 (file)
@@ -571,9 +571,9 @@ class ZadaraVPSADriverTestCase(test.TestCase):
         connector3 = dict(initiator='test_iqn.3')
 
         self.driver.create_volume(volume)
-        props1 = self.driver.initialize_connection(volume, connector1)
-        props2 = self.driver.initialize_connection(volume, connector2)
-        props3 = self.driver.initialize_connection(volume, connector3)
+        self.driver.initialize_connection(volume, connector1)
+        self.driver.initialize_connection(volume, connector2)
+        self.driver.initialize_connection(volume, connector3)
 
         self.driver.terminate_connection(volume, connector1)
         self.driver.terminate_connection(volume, connector3)
@@ -583,11 +583,7 @@ class ZadaraVPSADriverTestCase(test.TestCase):
     def test_wrong_attach_params(self):
         """Test different wrong attach scenarios."""
         volume1 = {'name': 'test_volume_01', 'size': 1, 'id': 101}
-        volume2 = {'name': 'test_volume_02', 'size': 1, 'id': 102}
-        volume3 = {'name': 'test_volume_03', 'size': 1, 'id': 103}
         connector1 = dict(initiator='test_iqn.1')
-        connector2 = dict(initiator='test_iqn.2')
-        connector3 = dict(initiator='test_iqn.3')
 
         self.assertRaises(exception.VolumeNotFound,
                           self.driver.initialize_connection,
@@ -605,8 +601,8 @@ class ZadaraVPSADriverTestCase(test.TestCase):
 
         self.driver.create_volume(volume1)
         self.driver.create_volume(volume2)
-        props1 = self.driver.initialize_connection(volume1, connector1)
-        props2 = self.driver.initialize_connection(volume2, connector2)
+        self.driver.initialize_connection(volume1, connector1)
+        self.driver.initialize_connection(volume2, connector2)
 
         self.assertRaises(exception.ZadaraServerNotFound,
                           self.driver.terminate_connection,
@@ -666,9 +662,9 @@ class ZadaraVPSADriverTestCase(test.TestCase):
         connector3 = dict(initiator='test_iqn.3')
 
         self.driver.create_volume(volume1)
-        props1 = self.driver.initialize_connection(volume1, connector1)
-        props2 = self.driver.initialize_connection(volume1, connector2)
-        props3 = self.driver.initialize_connection(volume1, connector3)
+        self.driver.initialize_connection(volume1, connector1)
+        self.driver.initialize_connection(volume1, connector2)
+        self.driver.initialize_connection(volume1, connector3)
 
         self.flags(zadara_vpsa_auto_detach_on_delete=False)
         self.assertRaises(exception.VolumeAttached,
index ca9c3a8920fea2434db9233ed2fb4a1ff8aeb126..5be6233208eb1c6c56323fbdf0e28b5c799b25ad 100644 (file)
@@ -81,7 +81,7 @@ class TestBrcdFCSanLookupService(brcd_lookup.BrcdFCSanLookupService,
     def test_get_device_mapping_from_network(self, get_nameserver_info_mock):
         initiator_list = ['10008c7cff523b01']
         target_list = ['20240002ac000a50', '20240002ac000a40']
-        with mock.patch.object(self.client, 'connect') as client_connect_mock:
+        with mock.patch.object(self.client, 'connect'):
             get_nameserver_info_mock.return_value = (nsshow_data)
             device_map = self.get_device_mapping_from_network(
                 initiator_list, target_list)
index 7cd41c7b508e40889b97b8231e43ed8909afc42d..a0a3e086f7e1017c35a066d4173679efc0a7f045 100644 (file)
@@ -465,7 +465,7 @@ def safe_minidom_parse_string(xml_string):
     """
     try:
         return minidom.parseString(xml_string, parser=ProtectedExpatParser())
-    except sax.SAXParseException as se:
+    except sax.SAXParseException:
         raise expat.ExpatError()
 
 
index d05800b4562700109ded6193adf0aafa36c53124..1a454d8f59ba8daf07322fbfb2553e0d44ead243 100644 (file)
@@ -50,7 +50,6 @@ class EMCSMISFCDriver(driver.FibreChannelDriver):
         """Creates a EMC(VMAX/VNX) volume."""
         volpath = self.common.create_volume(volume)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
@@ -60,7 +59,6 @@ class EMCSMISFCDriver(driver.FibreChannelDriver):
         """Creates a volume from a snapshot."""
         volpath = self.common.create_volume_from_snapshot(volume, snapshot)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
@@ -70,7 +68,6 @@ class EMCSMISFCDriver(driver.FibreChannelDriver):
         """Creates a cloned volume."""
         volpath = self.common.create_cloned_volume(volume, src_vref)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
index 205daafd04ec5eed1852039c0bf8017feec89af5..8ea75a0b8fe3ad27db92210c78d81d428cf41b0f 100644 (file)
@@ -52,7 +52,6 @@ class EMCSMISISCSIDriver(driver.ISCSIDriver):
         """Creates a EMC(VMAX/VNX) volume."""
         volpath = self.common.create_volume(volume)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
@@ -62,7 +61,6 @@ class EMCSMISISCSIDriver(driver.ISCSIDriver):
         """Creates a volume from a snapshot."""
         volpath = self.common.create_volume_from_snapshot(volume, snapshot)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
@@ -72,7 +70,6 @@ class EMCSMISISCSIDriver(driver.ISCSIDriver):
         """Creates a cloned volume."""
         volpath = self.common.create_cloned_volume(volume, src_vref)
 
-        ctxt = context.get_admin_context()
         model_update = {}
         volume['provider_location'] = str(volpath)
         model_update['provider_location'] = volume['provider_location']
index a188bffb8079ea99293160636a77c392fa897d98..1e0f4f9accf5ad1fd9ec4db4a6b47ab2cebd5ffd 100644 (file)
@@ -97,7 +97,7 @@ def _xml_read(root, element, check=None):
         if check:
             raise exception.ParameterNotFound(param=element)
         return None
-    except ETree.ParseError as e:
+    except ETree.ParseError:
         if check:
             with excutils.save_and_reraise_exception():
                 LOG.error(_("XML exception reading parameter: %s") % element)
@@ -361,14 +361,14 @@ class HUSDriver(driver.ISCSIDriver):
     def extend_volume(self, volume, new_size):
         """Extend an existing volume."""
         (arid, lun) = _loc_info(volume['provider_location'])['id_lu']
-        out = self.bend.extend_vol(self.config['hus_cmd'],
-                                   HDS_VERSION,
-                                   self.config['mgmt_ip0'],
-                                   self.config['mgmt_ip1'],
-                                   self.config['username'],
-                                   self.config['password'],
-                                   arid, lun,
-                                   '%s' % (new_size * 1024))
+        self.bend.extend_vol(self.config['hus_cmd'],
+                             HDS_VERSION,
+                             self.config['mgmt_ip0'],
+                             self.config['mgmt_ip1'],
+                             self.config['username'],
+                             self.config['password'],
+                             arid, lun,
+                             '%s' % (new_size * 1024))
         LOG.debug(_("LUN %(lun)s extended to %(size)s GB.")
                   % {'lun': lun,
                      'size': new_size})
@@ -383,25 +383,25 @@ class HUSDriver(driver.ISCSIDriver):
         (arid, lun) = info['id_lu']
         if 'tgt' in info.keys():  # connected?
             (_portal, iqn, loc, ctl, port) = info['tgt']
-            _out = self.bend.del_iscsi_conn(self.config['hus_cmd'],
-                                            HDS_VERSION,
-                                            self.config['mgmt_ip0'],
-                                            self.config['mgmt_ip1'],
-                                            self.config['username'],
-                                            self.config['password'],
-                                            arid, lun, ctl, port, iqn,
-                                            '')
+            self.bend.del_iscsi_conn(self.config['hus_cmd'],
+                                     HDS_VERSION,
+                                     self.config['mgmt_ip0'],
+                                     self.config['mgmt_ip1'],
+                                     self.config['username'],
+                                     self.config['password'],
+                                     arid, lun, ctl, port, iqn,
+                                     '')
         name = self.hus_name
         LOG.debug(_("delete lun %(lun)s on %(name)s")
                   % {'lun': lun,
                      'name': name})
-        _out = self.bend.delete_lu(self.config['hus_cmd'],
-                                   HDS_VERSION,
-                                   self.config['mgmt_ip0'],
-                                   self.config['mgmt_ip1'],
-                                   self.config['username'],
-                                   self.config['password'],
-                                   arid, lun)
+        self.bend.delete_lu(self.config['hus_cmd'],
+                            HDS_VERSION,
+                            self.config['mgmt_ip0'],
+                            self.config['mgmt_ip1'],
+                            self.config['username'],
+                            self.config['password'],
+                            arid, lun)
 
     def remove_export(self, context, volume):
         """Disconnect a volume from an attached instance."""
@@ -448,14 +448,14 @@ class HUSDriver(driver.ISCSIDriver):
         (arid, lun) = info['id_lu']
         (_portal, iqn, loc, ctl, port) = info['tgt']
 
-        _out = self.bend.del_iscsi_conn(self.config['hus_cmd'],
-                                        HDS_VERSION,
-                                        self.config['mgmt_ip0'],
-                                        self.config['mgmt_ip1'],
-                                        self.config['username'],
-                                        self.config['password'],
-                                        arid, lun, ctl, port, iqn,
-                                        connector['initiator'])
+        self.bend.del_iscsi_conn(self.config['hus_cmd'],
+                                 HDS_VERSION,
+                                 self.config['mgmt_ip0'],
+                                 self.config['mgmt_ip1'],
+                                 self.config['username'],
+                                 self.config['password'],
+                                 arid, lun, ctl, port, iqn,
+                                 connector['initiator'])
         self._update_vol_location(volume['id'], loc)
         return {'provider_location': loc}
 
@@ -512,13 +512,13 @@ class HUSDriver(driver.ISCSIDriver):
         if loc is None:         # to take care of spurious input
             return              # which could cause exception.
         (arid, lun) = loc.split('.')
-        _out = self.bend.delete_lu(self.config['hus_cmd'],
-                                   HDS_VERSION,
-                                   self.config['mgmt_ip0'],
-                                   self.config['mgmt_ip1'],
-                                   self.config['username'],
-                                   self.config['password'],
-                                   arid, lun)
+        self.bend.delete_lu(self.config['hus_cmd'],
+                            HDS_VERSION,
+                            self.config['mgmt_ip0'],
+                            self.config['mgmt_ip1'],
+                            self.config['username'],
+                            self.config['password'],
+                            arid, lun)
         LOG.debug(_("LUN %s is deleted.") % lun)
         return
 
index 8366c14a44d548c66412e72a716c76cb0307d503..922a2e891efa38db21d967f3770a9f5fa8fe7f9a 100644 (file)
@@ -71,7 +71,6 @@ def is_xml_item_exist(xml_root, item, attrib_key=None):
     :return: True of False
     """
     items_list = get_xml_item(xml_root, item)
-    value = []
     if attrib_key:
         for tmp_dict in items_list:
             if tmp_dict['attrib'].get(attrib_key, None):
index 5e44aefc96cb46ad7edcef88a1851f390fe0ce3d..0e3de752f96b84c9e095c65e87d09d015b830954 100644 (file)
@@ -409,8 +409,6 @@ class TseriesCommon():
 
         """
 
-        maxpool_id = None
-        maxpool_size = 0.0
         nameindex, sizeindex = ((1, 4) if luntype == 'Thin' else (5, 3))
         pools_dev = sorted(pools_dev, key=lambda x: float(x[sizeindex]))
         while len(pools_dev) > 0:
index 2dc2fdaf2f62d82d3258f3ba8494f0d590dcba87..814960dd4e8336ee1fdfc7ef6437d47511c06af3 100644 (file)
@@ -394,7 +394,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
         Error checking done by manage_existing_get_size is not repeated.
         """
         lv_name = existing_ref['lv_name']
-        lv = self.vg.get_volume(lv_name)
+        self.vg.get_volume(lv_name)
 
         # Attempt to rename the LV to match the OpenStack internal name.
         try:
index 630bd4c64b228b65d82a26d857489bfff3c4876f..2f1a90c294a041a1cae9635178b0f1f3be740a68 100644 (file)
@@ -95,7 +95,7 @@ class NetAppNFSDriver(nfs.NfsDriver):
             if vol_size != snap_size:
                 try:
                     self.extend_volume(volume, vol_size)
-                except Exception as e:
+                except Exception:
                     with excutils.save_and_reraise_exception():
                         LOG.error(
                             _("Resizing %s failed. Cleaning volume."),
@@ -1413,7 +1413,7 @@ class NetAppDirect7modeNfsDriver (NetAppDirectNfsDriver):
             try:
                 self._invoke_successfully(clone_clear, None)
                 break
-            except Exception as e:
+            except Exception:
                 # Filer might be rebooting
                 time.sleep(5)
             retry = retry - 1
index b392d9f2536c62ad1e048413edc892495bcf2098..884a5c92114a9bb3a0906773f3a187f1bc7e6a49 100644 (file)
@@ -227,8 +227,8 @@ class HP3PARCommon(object):
 
     def validate_cpg(self, cpg_name):
         try:
-            cpg = self.client.getCPG(cpg_name)
-        except hpexceptions.HTTPNotFound as ex:
+            self.client.getCPG(cpg_name)
+        except hpexceptions.HTTPNotFound:
             err = (_("CPG (%s) doesn't exist on array") % cpg_name)
             LOG.error(err)
             raise exception.InvalidInput(reason=err)
index e48051224e890f1cafdf2e9b6db3071089b3c577..6931723872c6a693abd1d40517e525e60d65895b 100644 (file)
@@ -291,7 +291,7 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
         domain = self.common.get_domain(cpg)
         try:
             host = self.common._get_3par_host(hostname)
-        except hpexceptions.HTTPNotFound as ex:
+        except hpexceptions.HTTPNotFound:
             # get persona from the volume type extra specs
             persona_id = self.common.get_persona_type(volume)
             # host doesn't exist, we have to create it
index 2127133dd52da20b42d1f004d9a3660fb9885b7a..e0b51356e8e7ff158f047159f5642ebea85742ba 100644 (file)
@@ -313,7 +313,7 @@ class HPLeftHandCLIQProxy(SanISCSIDriver):
         cliq_args['volumeName'] = volume['name']
         cliq_args['prompt'] = 'false'  # Don't confirm
         try:
-            volume_info = self._cliq_get_volume_info(volume['name'])
+            self._cliq_get_volume_info(volume['name'])
         except processutils.ProcessExecutionError:
             LOG.error(_("Volume did not exist. It will not be deleted"))
             return
@@ -325,7 +325,7 @@ class HPLeftHandCLIQProxy(SanISCSIDriver):
         cliq_args['snapshotName'] = snapshot['name']
         cliq_args['prompt'] = 'false'  # Don't confirm
         try:
-            volume_info = self._cliq_get_snapshot_info(snapshot['name'])
+            self._cliq_get_snapshot_info(snapshot['name'])
         except processutils.ProcessExecutionError:
             LOG.error(_("Snapshot did not exist. It will not be deleted"))
             return
index 222331184857ad142042bc6332f18900a0e6f811..992a3baafab3453a6de490a35182626abbda8da7 100644 (file)
@@ -67,7 +67,7 @@ class HPMSACommon(object):
                    {'host': self.config.san_ip, 'err': ex})
             LOG.error(msg)
             raise exception.HPMSAConnectionError(reason=msg)
-        except msa.HPMSAAuthenticationError as e:
+        except msa.HPMSAAuthenticationError:
             msg = _("Failed to log on MSA Array (invalid login?)")
             LOG.error(msg)
             raise exception.HPMSAConnectionError(reason=msg)
index 45ef69f00dd64b050d1fb10f7526b733af1c68dc..0151058f1407694956b84a79a74b9548074c3016 100644 (file)
@@ -118,7 +118,6 @@ class SanDriver(driver.VolumeDriver):
                                          max_size=max_size)
         last_exception = None
         try:
-            total_attempts = attempts
             with self.sshpool.item() as ssh:
                 while attempts > 0:
                     attempts -= 1
index ffe61e700c5a6244e7f6a07671cfd1eb395ba840..b5ea2fb84ed882dd409af50c1de5e78949653cbb 100644 (file)
@@ -513,7 +513,7 @@ class NFSBasedVolumeOperations(object):
         glance_host, glance_port, glance_use_ssl = glance_server
 
         try:
-            result = self.glance_plugin.upload_vhd(
+            self.glance_plugin.upload_vhd(
                 vdi_uuids, image_id, glance_host, glance_port, glance_use_ssl,
                 os.path.join(sr_base_path, sr_uuid), auth_token, dict())
         finally:
index f96bc287fd339a1b49082656206bc705b5f57375..2152b4ae797ff6d752b63075f826df72b1e8ddd4 100644 (file)
@@ -130,7 +130,6 @@ class XenAPINFSDriver(driver.VolumeDriver):
             snapshot, volume['display_name'], volume['name_description'])
 
     def create_snapshot(self, snapshot):
-        volume_id = snapshot['volume_id']
         volume = snapshot['volume']
         return self._copy_volume(
             volume, snapshot['display_name'], snapshot['display_description'])
index 5f29163ea70d45d059be25474310d23e19bf72ef..d9c42bd9b674ec46b318cfecfd2da6bbeef07279 100644 (file)
@@ -684,7 +684,7 @@ class VolumeManager(manager.SchedulerDependentManager):
         volume = self.db.volume_get(context, volume_id)
         try:
             utils.require_driver_initialized(self.driver)
-        except exception.DriverNotInitialized as ex:
+        except exception.DriverNotInitialized:
             with excutils.save_and_reraise_exception():
                 LOG.exception(_("Error detaching volume %(volume)s, "
                                 "due to uninitialized driver."),
diff --git a/tox.ini b/tox.ini
index 2f306065eb8ff7b60cb24923f31c7b2de2931dc1..8380abbedb9f229d2480ee6494ee3d547d10dd0d 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -40,6 +40,6 @@ commands =
 commands = {posargs}
 
 [flake8]
-ignore = E711,E712,F403,F841,H302,H303,H304,H803
+ignore = E711,E712,F403,H302,H303,H304,H803
 builtins = _
 exclude = .git,.venv,.tox,dist,tools,doc,common,*egg,build