From a6d036d199a476f906cb585464021515c8481ccd Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Wed, 29 Apr 2015 14:23:46 +0300 Subject: [PATCH] Removed twice declared variables Co-Author: Pavel Kholkin Change-Id: If58247371bbc10b9694594dd5f01446f7e5b5921 --- .../compute/contrib/attach_interfaces.py | 1 - .../compute/plugins/v3/attach_interfaces.py | 1 - nova/api/openstack/compute/servers.py | 1 - nova/network/neutronv2/api.py | 1 - nova/tests/functional/test_api_samples.py | 4 ++-- .../functional/v3/test_deferred_delete.py | 4 ++-- nova/tests/unit/api/ec2/test_cinder_cloud.py | 2 +- nova/tests/unit/api/ec2/test_cloud.py | 22 +++++++++---------- .../openstack/compute/test_image_metadata.py | 1 - .../openstack/compute/test_server_actions.py | 5 ++--- nova/tests/unit/db/test_db_api.py | 10 ++++----- nova/tests/unit/fake_ldap.py | 2 +- nova/tests/unit/fake_volume.py | 3 +-- nova/tests/unit/image/test_glance.py | 6 ++--- nova/tests/unit/virt/ironic/test_driver.py | 1 - nova/virt/libvirt/driver.py | 1 - nova/virt/vmwareapi/vm_util.py | 1 - nova/volume/cinder.py | 1 - 18 files changed, 27 insertions(+), 40 deletions(-) diff --git a/nova/api/openstack/compute/contrib/attach_interfaces.py b/nova/api/openstack/compute/contrib/attach_interfaces.py index aa052332ad86..7c79dbcf7f34 100644 --- a/nova/api/openstack/compute/contrib/attach_interfaces.py +++ b/nova/api/openstack/compute/contrib/attach_interfaces.py @@ -173,7 +173,6 @@ class InterfaceAttachmentController(object): context = req.environ['nova.context'] authorize(context) instance = common.get_instance(self.compute_api, context, server_id) - results = [] search_opts = {'device_id': instance.uuid} try: diff --git a/nova/api/openstack/compute/plugins/v3/attach_interfaces.py b/nova/api/openstack/compute/plugins/v3/attach_interfaces.py index 7a8e6fe1e3b0..f481c937a744 100644 --- a/nova/api/openstack/compute/plugins/v3/attach_interfaces.py +++ b/nova/api/openstack/compute/plugins/v3/attach_interfaces.py @@ -168,7 +168,6 @@ class InterfaceAttachmentController(wsgi.Controller): authorize(context) instance = common.get_instance(self.compute_api, context, server_id) - results = [] search_opts = {'device_id': instance.uuid} try: diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 185855351933..f663b1418fce 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -391,7 +391,6 @@ class Controller(wsgi.Controller): def _extract_bdm(self, server_dict, image_uuid_specified): legacy_bdm = True - block_device_mapping = None block_device_mapping_v2 = None if not self.ext_mgr.is_loaded('os-volumes'): return legacy_bdm, None diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 9d175e321754..6e8f9ba76b80 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -959,7 +959,6 @@ class API(base_api.NetworkAPI): Return vnic type and the attached physical network name. """ phynet_name = None - vnic_type = None port = neutron.show_port(port_id, fields=['binding:vnic_type', 'network_id']).get('port') vnic_type = port.get('binding:vnic_type', diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index bcfdd7098b33..385a5ea903e2 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -1192,7 +1192,7 @@ class DeferredDeleteSampleJsonTests(ServersSampleBase): def test_restore(self): uuid = self._post_server() - response = self._do_delete('servers/%s' % uuid) + self._do_delete('servers/%s' % uuid) response = self._do_post('servers/%s/action' % uuid, 'restore-post-req', {}) @@ -1201,7 +1201,7 @@ class DeferredDeleteSampleJsonTests(ServersSampleBase): def test_force_delete(self): uuid = self._post_server() - response = self._do_delete('servers/%s' % uuid) + self._do_delete('servers/%s' % uuid) response = self._do_post('servers/%s/action' % uuid, 'force-delete-post-req', {}) diff --git a/nova/tests/functional/v3/test_deferred_delete.py b/nova/tests/functional/v3/test_deferred_delete.py index d65319b781ac..5625e06fbc45 100644 --- a/nova/tests/functional/v3/test_deferred_delete.py +++ b/nova/tests/functional/v3/test_deferred_delete.py @@ -25,7 +25,7 @@ class DeferredDeleteSampleJsonTests(test_servers.ServersSampleBase): def test_restore(self): uuid = self._post_server() - response = self._do_delete('servers/%s' % uuid) + self._do_delete('servers/%s' % uuid) response = self._do_post('servers/%s/action' % uuid, 'restore-post-req', {}) @@ -34,7 +34,7 @@ class DeferredDeleteSampleJsonTests(test_servers.ServersSampleBase): def test_force_delete(self): uuid = self._post_server() - response = self._do_delete('servers/%s' % uuid) + self._do_delete('servers/%s' % uuid) response = self._do_post('servers/%s/action' % uuid, 'force-delete-post-req', {}) diff --git a/nova/tests/unit/api/ec2/test_cinder_cloud.py b/nova/tests/unit/api/ec2/test_cinder_cloud.py index 37970b18f56e..d647ed1382a0 100644 --- a/nova/tests/unit/api/ec2/test_cinder_cloud.py +++ b/nova/tests/unit/api/ec2/test_cinder_cloud.py @@ -426,7 +426,7 @@ class CinderCloudTestCase(test.TestCase): def test_create_snapshot(self): # Makes sure create_snapshot works. availability_zone = 'zone1:host1' - result = self.cloud.describe_snapshots(self.context) + self.cloud.describe_snapshots(self.context) vol1 = self.cloud.create_volume(self.context, size=1, availability_zone=availability_zone) diff --git a/nova/tests/unit/api/ec2/test_cloud.py b/nova/tests/unit/api/ec2/test_cloud.py index 38ccbcf92662..977d19cbeef3 100644 --- a/nova/tests/unit/api/ec2/test_cloud.py +++ b/nova/tests/unit/api/ec2/test_cloud.py @@ -584,16 +584,16 @@ class CloudTestCase(test.TestCase): 'user_id': self.context.user_id, 'name': 'test' } - sec = db.security_group_create(self.context, - {'project_id': 'someuser', - 'user_id': 'someuser', - 'description': '', - 'name': 'somegroup1'}) - sec = db.security_group_create(self.context, - {'project_id': 'someuser', - 'user_id': 'someuser', - 'description': '', - 'name': 'othergroup2'}) + db.security_group_create(self.context, + {'project_id': 'someuser', + 'user_id': 'someuser', + 'description': '', + 'name': 'somegroup1'}) + db.security_group_create(self.context, + {'project_id': 'someuser', + 'user_id': 'someuser', + 'description': '', + 'name': 'othergroup2'}) sec = db.security_group_create(self.context, kwargs) authz = self.cloud.authorize_security_group_ingress kwargs = {'ip_permissions': [{'to_port': 81, 'from_port': 81, @@ -766,7 +766,7 @@ class CloudTestCase(test.TestCase): expected_rules[0]['toPort'] = 65535 self.assertTrue(expected_rules == actual_rules) describe = self.cloud.describe_security_groups - groups = describe(self.context, group_name=['test']) + describe(self.context, group_name=['test']) db.security_group_destroy(self.context, sec['id']) diff --git a/nova/tests/unit/api/openstack/compute/test_image_metadata.py b/nova/tests/unit/api/openstack/compute/test_image_metadata.py index da0f7eb00d98..6eb75f085096 100644 --- a/nova/tests/unit/api/openstack/compute/test_image_metadata.py +++ b/nova/tests/unit/api/openstack/compute/test_image_metadata.py @@ -296,7 +296,6 @@ class ImageMetaDataTestV21(test.NoDBTestCase): @mock.patch('nova.image.api.API.get', return_value=get_image_123()) def test_too_many_metadata_items_on_put(self, _get_mocked, update_mocked, _quota_mocked): - body = {"metadata": {"foo": "bar"}} req = fakes.HTTPRequest.blank('/v2/fake/images/123/metadata/blah') req.method = 'PUT' body = {"meta": {"blah": "blah", "blah1": "blah1"}} diff --git a/nova/tests/unit/api/openstack/compute/test_server_actions.py b/nova/tests/unit/api/openstack/compute/test_server_actions.py index a42bb1ae2404..316a9f06f188 100644 --- a/nova/tests/unit/api/openstack/compute/test_server_actions.py +++ b/nova/tests/unit/api/openstack/compute/test_server_actions.py @@ -655,7 +655,7 @@ class ServerActionsControllerTestV21(test.TestCase): self.stubs.Set(compute_api.API, 'resize', resize_mock) - body = self.controller._action_resize(self.req, FAKE_UUID, body=body) + self.controller._action_resize(self.req, FAKE_UUID, body=body) self.assertEqual(self.resize_called, True) @@ -810,8 +810,7 @@ class ServerActionsControllerTestV21(test.TestCase): self.stubs.Set(compute_api.API, 'confirm_resize', cr_mock) - body = self.controller._action_confirm_resize(self.req, FAKE_UUID, - body=body) + self.controller._action_confirm_resize(self.req, FAKE_UUID, body=body) self.assertEqual(self.confirm_resize_called, True) diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index 9e31e848d933..ebc1a6dca141 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -2718,16 +2718,14 @@ class InstanceMetadataTestCase(test.TestCase): 'project_id': 'p1', 'metadata': {'key': 'value'}}) # This should add new key/value pair - metadata = db.instance_metadata_update( - self.ctxt, instance['uuid'], - {'new_key': 'new_value'}, False) + db.instance_metadata_update(self.ctxt, instance['uuid'], + {'new_key': 'new_value'}, False) metadata = db.instance_metadata_get(self.ctxt, instance['uuid']) self.assertEqual(metadata, {'key': 'value', 'new_key': 'new_value'}) # This should leave only one key/value pair - metadata = db.instance_metadata_update( - self.ctxt, instance['uuid'], - {'new_key': 'new_value'}, True) + db.instance_metadata_update(self.ctxt, instance['uuid'], + {'new_key': 'new_value'}, True) metadata = db.instance_metadata_get(self.ctxt, instance['uuid']) self.assertEqual(metadata, {'new_key': 'new_value'}) diff --git a/nova/tests/unit/fake_ldap.py b/nova/tests/unit/fake_ldap.py index fe42e8445ccb..5e44b22f4822 100644 --- a/nova/tests/unit/fake_ldap.py +++ b/nova/tests/unit/fake_ldap.py @@ -265,7 +265,7 @@ class FakeLDAP(object): values = [v] else: values.remove(v) - values = store.hset(key, k, _to_json(values)) + store.hset(key, k, _to_json(values)) def modrdn_s(self, dn, newrdn): oldobj = self.search_s(dn, SCOPE_BASE) diff --git a/nova/tests/unit/fake_volume.py b/nova/tests/unit/fake_volume.py index 25c657670084..8dd7be5a0b6b 100644 --- a/nova/tests/unit/fake_volume.py +++ b/nova/tests/unit/fake_volume.py @@ -183,8 +183,7 @@ class API(object): def check_attach(self, context, volume, instance=None): if volume['status'] != 'available': - msg = "status must be available" - msg = "%s" % volume + msg = "Status of volume '%s' must be available" % volume raise exception.InvalidVolume(reason=msg) if volume['attach_status'] == 'attached': msg = "already attached" diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py index 3fc7b0c7781a..bc1fcd2a6383 100644 --- a/nova/tests/unit/image/test_glance.py +++ b/nova/tests/unit/image/test_glance.py @@ -1027,7 +1027,7 @@ class TestCreate(test.NoDBTestCase): # Now verify that if we supply image data to the call, # that the client is also called with the data kwarg client.reset_mock() - image_meta = service.create(ctx, image_mock, data=mock.sentinel.data) + service.create(ctx, image_mock, data=mock.sentinel.data) client.call.assert_called_once_with(ctx, 1, 'create', image_id=mock.sentinel.image_id, @@ -1088,8 +1088,8 @@ class TestUpdate(test.NoDBTestCase): # Now verify that if we supply image data to the call, # that the client is also called with the data kwarg client.reset_mock() - image_meta = service.update(ctx, mock.sentinel.image_id, - image_mock, data=mock.sentinel.data) + service.update(ctx, mock.sentinel.image_id, + image_mock, data=mock.sentinel.data) client.call.assert_called_once_with(ctx, 1, 'update', mock.sentinel.image_id, diff --git a/nova/tests/unit/virt/ironic/test_driver.py b/nova/tests/unit/virt/ironic/test_driver.py index b3c3cc2b7b74..5b660afd9c12 100644 --- a/nova/tests/unit/virt/ironic/test_driver.py +++ b/nova/tests/unit/virt/ironic/test_driver.py @@ -909,7 +909,6 @@ class IronicDriverTestCase(test.NoDBTestCase): mock_required_by): mock_required_by.return_value = False node_uuid = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee' - fake_net_info = utils.get_test_network_info() node = ironic_utils.get_test_node(driver='fake', uuid=node_uuid) flavor = ironic_utils.get_test_flavor() instance = fake_instance.fake_instance_obj(self.ctx, node=node_uuid) diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 599d156e2805..76544b348de7 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -4814,7 +4814,6 @@ class LibvirtDriver(driver.ComputeDriver): instance = instance_bdms['instance'] for bdm in instance_bdms['instance_bdms']: - vol_stats = [] mountpoint = bdm['device_name'] if mountpoint.startswith('/dev/'): mountpoint = mountpoint[5:] diff --git a/nova/virt/vmwareapi/vm_util.py b/nova/virt/vmwareapi/vm_util.py index 250e1c8f4b3b..2d13d4fccafb 100644 --- a/nova/virt/vmwareapi/vm_util.py +++ b/nova/virt/vmwareapi/vm_util.py @@ -542,7 +542,6 @@ def get_vmdk_info(session, vm_ref, uuid=None): vmdk_controller_key = None disk_type = None capacity_in_bytes = 0 - vmdk_device = None # Determine if we need to get the details of the root disk root_disk = None diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py index d581ffe3caa5..79bc7350ca33 100644 --- a/nova/volume/cinder.py +++ b/nova/volume/cinder.py @@ -98,7 +98,6 @@ def cinderclient(context): url = None endpoint_override = None - version = None auth = context.get_auth_plugin() service_type, service_name, interface = CONF.cinder.catalog_info.split(':')