summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Pitucha <stanislaw.pitucha@hp.com>2013-06-13 17:08:49 +0000
committerStanislaw Pitucha <stanislaw.pitucha@hp.com>2013-06-27 17:34:17 +0000
commit5c6c5216b329d42dcee1eed61c5345cbe76b87f3 (patch)
tree0ca10f7d595c3df3fb6b659f1292f9fcc5e9f1b7
parentc7b4a3513c21474d163b3487fa417ebb80212881 (diff)
downloadnova-5c6c5216b329d42dcee1eed61c5345cbe76b87f3.tar.gz
nova-5c6c5216b329d42dcee1eed61c5345cbe76b87f3.tar.xz
nova-5c6c5216b329d42dcee1eed61c5345cbe76b87f3.zip
Remove trivial cases of unused variables (3)
Kill some of the variables marked as unused by flakes8. This should allow to enable F841 check in the future. Only trivial cases with no function calls and obviously pure functions (like datetime.now(), or len()) are cleaned up here. Part 3, split to reduce conflicts. Change-Id: I7b8e806ddd7b0e077243d4e31de140cd08fe0155
-rw-r--r--nova/tests/conductor/test_conductor.py5
-rw-r--r--nova/tests/db/test_db_api.py138
-rw-r--r--nova/tests/db/test_migrations.py3
-rw-r--r--nova/tests/integrated/test_api_samples.py6
-rw-r--r--nova/tests/network/test_linux_net.py1
-rw-r--r--nova/tests/network/test_network_info.py2
-rw-r--r--nova/tests/network/test_quantumv2.py5
-rw-r--r--nova/tests/servicegroup/test_mc_servicegroup.py16
-rw-r--r--nova/tests/servicegroup/test_zk_driver.py2
-rw-r--r--nova/tests/test_availability_zones.py4
-rw-r--r--nova/tests/test_cinder.py10
-rw-r--r--nova/tests/test_flavors.py16
-rw-r--r--nova/tests/test_quota.py2
-rw-r--r--nova/virt/baremetal/pxe.py2
-rwxr-xr-xnova/virt/baremetal/tilera.py4
-rwxr-xr-xnova/virt/baremetal/tilera_pdu.py2
-rw-r--r--nova/virt/hyperv/vmutils.py2
-rwxr-xr-xnova/virt/libvirt/driver.py7
-rw-r--r--nova/virt/powervm/lpar.py2
-rw-r--r--nova/virt/powervm/operator.py4
20 files changed, 103 insertions, 130 deletions
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py
index 7df829a53..609c2164c 100644
--- a/nova/tests/conductor/test_conductor.py
+++ b/nova/tests/conductor/test_conductor.py
@@ -246,9 +246,8 @@ class _BaseTestCase(object):
self.mox.StubOutWithMock(db, 'aggregate_metadata_delete')
db.aggregate_metadata_delete(mox.IgnoreArg(), aggregate['id'], 'fake')
self.mox.ReplayAll()
- result = self.conductor.aggregate_metadata_delete(self.context,
- aggregate,
- 'fake')
+ self.conductor.aggregate_metadata_delete(self.context, aggregate,
+ 'fake')
def test_aggregate_metadata_get_by_host(self):
self.mox.StubOutWithMock(db, 'aggregate_metadata_get_by_host')
diff --git a/nova/tests/db/test_db_api.py b/nova/tests/db/test_db_api.py
index deaf8d035..2baa7ee3a 100644
--- a/nova/tests/db/test_db_api.py
+++ b/nova/tests/db/test_db_api.py
@@ -286,7 +286,7 @@ class DbApiTestCase(DbTestCase):
def test_instance_get_all_by_filters_deleted_and_soft_deleted(self):
inst1 = self.create_instance_with_args()
inst2 = self.create_instance_with_args(vm_state=vm_states.SOFT_DELETED)
- inst3 = self.create_instance_with_args()
+ self.create_instance_with_args()
db.instance_destroy(self.context, inst1['uuid'])
result = db.instance_get_all_by_filters(self.context,
{'deleted': True})
@@ -296,8 +296,8 @@ class DbApiTestCase(DbTestCase):
def test_instance_get_all_by_filters_deleted_no_soft_deleted(self):
inst1 = self.create_instance_with_args()
- inst2 = self.create_instance_with_args(vm_state=vm_states.SOFT_DELETED)
- inst3 = self.create_instance_with_args()
+ self.create_instance_with_args(vm_state=vm_states.SOFT_DELETED)
+ self.create_instance_with_args()
db.instance_destroy(self.context, inst1['uuid'])
result = db.instance_get_all_by_filters(self.context,
{'deleted': True,
@@ -948,8 +948,8 @@ class AggregateDBApiTestCase(test.TestCase):
values2 = {'name': 'fake_aggregate4'}
a1 = _create_aggregate_with_hosts(context=ctxt,
metadata={'goodkey': 'good'})
- a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
- a3 = _create_aggregate(context=ctxt, values=values2)
+ _create_aggregate_with_hosts(context=ctxt, values=values)
+ _create_aggregate(context=ctxt, values=values2)
# filter result by key
r1 = db.aggregate_get_by_host(ctxt, 'foo.openstack.org', key='goodkey')
self.assertEqual([a1['id']], [x['id'] for x in r1])
@@ -958,9 +958,9 @@ class AggregateDBApiTestCase(test.TestCase):
ctxt = context.get_admin_context()
values = {'name': 'fake_aggregate2'}
values2 = {'name': 'fake_aggregate3'}
- a1 = _create_aggregate_with_hosts(context=ctxt)
- a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
- a3 = _create_aggregate_with_hosts(context=ctxt, values=values2,
+ _create_aggregate_with_hosts(context=ctxt)
+ _create_aggregate_with_hosts(context=ctxt, values=values)
+ _create_aggregate_with_hosts(context=ctxt, values=values2,
hosts=['bar.openstack.org'], metadata={'badkey': 'bad'})
r1 = db.aggregate_metadata_get_by_host(ctxt, 'foo.openstack.org')
self.assertEqual(r1['fake_key1'], set(['fake_value1']))
@@ -970,8 +970,8 @@ class AggregateDBApiTestCase(test.TestCase):
ctxt = context.get_admin_context()
values = {'name': 'fake_aggregate2'}
values2 = {'name': 'fake_aggregate3'}
- a1 = _create_aggregate_with_hosts(context=ctxt)
- a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
+ _create_aggregate_with_hosts(context=ctxt)
+ _create_aggregate_with_hosts(context=ctxt, values=values)
a3 = _create_aggregate_with_hosts(context=ctxt, values=values2,
hosts=['foo.openstack.org'], metadata={'good': 'value'})
r1 = db.aggregate_metadata_get_by_host(ctxt, 'foo.openstack.org',
@@ -988,9 +988,9 @@ class AggregateDBApiTestCase(test.TestCase):
ctxt = context.get_admin_context()
values = {'name': 'fake_aggregate2'}
values2 = {'name': 'fake_aggregate3'}
- a1 = _create_aggregate_with_hosts(context=ctxt)
- a2 = _create_aggregate_with_hosts(context=ctxt, values=values)
- a3 = _create_aggregate_with_hosts(context=ctxt, values=values2,
+ _create_aggregate_with_hosts(context=ctxt)
+ _create_aggregate_with_hosts(context=ctxt, values=values)
+ _create_aggregate_with_hosts(context=ctxt, values=values2,
hosts=['foo.openstack.org'], metadata={'good': 'value'})
r1 = db.aggregate_host_get_by_metadata_key(ctxt, key='good')
self.assertEqual(r1, {'foo.openstack.org': set(['value'])})
@@ -1464,7 +1464,7 @@ class ReservationTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_reservation_expire(self):
self.values['expire'] = datetime.datetime.utcnow() + datetime.\
timedelta(days=1)
- reservations = self._quota_reserve()
+ self._quota_reserve()
db.reservation_expire(self.ctxt)
expected = {'project_id': 'project1',
@@ -1628,8 +1628,7 @@ class SecurityGroupTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_security_group_get(self):
security_group1 = self._create_security_group({})
- security_group2 = self._create_security_group(
- {'name': 'fake_sec_group2'})
+ self._create_security_group({'name': 'fake_sec_group2'})
real_security_group = db.security_group_get(self.ctxt,
security_group1['id'],
columns_to_join=['instances'])
@@ -1742,8 +1741,8 @@ class SecurityGroupTestCase(test.TestCase, ModelsObjectComparatorMixin):
{'name': 'fake2', 'project_id': 'fake_proj1'},
{'name': 'fake3', 'project_id': 'fake_proj2'},
]
- security_groups = [self._create_security_group(vals)
- for vals in values]
+ for vals in values:
+ self._create_security_group(vals)
real = []
for project in ('fake_proj1', 'fake_proj2'):
@@ -1776,7 +1775,7 @@ class SecurityGroupTestCase(test.TestCase, ModelsObjectComparatorMixin):
self.ctxt.project_id,
'default'))
- default_group = db.security_group_ensure_default(self.ctxt)
+ db.security_group_ensure_default(self.ctxt)
self.assertTrue(db.security_group_exists(self.ctxt,
self.ctxt.project_id,
@@ -1896,7 +1895,7 @@ class ServiceTestCase(test.TestCase, ModelsObjectComparatorMixin):
def test_service_get(self):
service1 = self._create_service({})
- service2 = self._create_service({'host': 'some_other_fake_host'})
+ self._create_service({'host': 'some_other_fake_host'})
real_service1 = db.service_get(self.ctxt, service1['id'])
self._assertEqualObjects(service1, real_service1,
ignored_keys=['compute_node'])
@@ -1921,7 +1920,7 @@ class ServiceTestCase(test.TestCase, ModelsObjectComparatorMixin):
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'})
+ self._create_service({'host': 'host2', 'topic': 'topic2'})
real_service1 = db.service_get_by_host_and_topic(self.ctxt,
host='host1',
@@ -3693,24 +3692,24 @@ class VolumeUsageDBApiTestCase(test.TestCase):
vol_usages = db.vol_get_usage_by_time(ctxt, start_time)
self.assertEqual(len(vol_usages), 0)
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=10, rd_bytes=20,
- wr_req=30, wr_bytes=40,
- instance_id='fake-instance-uuid1',
- project_id='fake-project-uuid1',
- user_id='fake-user-uuid1',
- availability_zone='fake-az')
- vol_usage = db.vol_usage_update(ctxt, 2, rd_req=100, rd_bytes=200,
- wr_req=300, wr_bytes=400,
- instance_id='fake-instance-uuid2',
- project_id='fake-project-uuid2',
- user_id='fake-user-uuid2',
- availability_zone='fake-az')
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=1000, rd_bytes=2000,
- wr_req=3000, wr_bytes=4000,
- instance_id='fake-instance-uuid1',
- project_id='fake-project-uuid1',
- user_id='fake-user-uuid1',
- availability_zone='fake-az')
+ db.vol_usage_update(ctxt, 1, rd_req=10, rd_bytes=20,
+ wr_req=30, wr_bytes=40,
+ instance_id='fake-instance-uuid1',
+ project_id='fake-project-uuid1',
+ user_id='fake-user-uuid1',
+ availability_zone='fake-az')
+ db.vol_usage_update(ctxt, 2, rd_req=100, rd_bytes=200,
+ wr_req=300, wr_bytes=400,
+ instance_id='fake-instance-uuid2',
+ project_id='fake-project-uuid2',
+ user_id='fake-user-uuid2',
+ availability_zone='fake-az')
+ db.vol_usage_update(ctxt, 1, rd_req=1000, rd_bytes=2000,
+ wr_req=3000, wr_bytes=4000,
+ instance_id='fake-instance-uuid1',
+ project_id='fake-project-uuid1',
+ user_id='fake-user-uuid1',
+ availability_zone='fake-az')
vol_usages = db.vol_get_usage_by_time(ctxt, start_time)
self.assertEqual(len(vol_usages), 2)
@@ -3732,44 +3731,44 @@ class VolumeUsageDBApiTestCase(test.TestCase):
timeutils.utcnow().AndReturn(now3)
self.mox.ReplayAll()
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=100, rd_bytes=200,
- wr_req=300, wr_bytes=400,
- instance_id='fake-instance-uuid',
- project_id='fake-project-uuid',
- user_id='fake-user-uuid',
- availability_zone='fake-az')
+ db.vol_usage_update(ctxt, 1, rd_req=100, rd_bytes=200,
+ wr_req=300, wr_bytes=400,
+ instance_id='fake-instance-uuid',
+ project_id='fake-project-uuid',
+ user_id='fake-user-uuid',
+ availability_zone='fake-az')
current_usage = db.vol_get_usage_by_time(ctxt, start_time)[0]
self.assertEqual(current_usage['tot_reads'], 0)
self.assertEqual(current_usage['curr_reads'], 100)
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=200, rd_bytes=300,
- wr_req=400, wr_bytes=500,
- instance_id='fake-instance-uuid',
- project_id='fake-project-uuid',
- user_id='fake-user-uuid',
- availability_zone='fake-az',
- update_totals=True)
+ db.vol_usage_update(ctxt, 1, rd_req=200, rd_bytes=300,
+ wr_req=400, wr_bytes=500,
+ instance_id='fake-instance-uuid',
+ project_id='fake-project-uuid',
+ user_id='fake-user-uuid',
+ availability_zone='fake-az',
+ update_totals=True)
current_usage = db.vol_get_usage_by_time(ctxt, start_time)[0]
self.assertEqual(current_usage['tot_reads'], 200)
self.assertEqual(current_usage['curr_reads'], 0)
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=300, rd_bytes=400,
- wr_req=500, wr_bytes=600,
- instance_id='fake-instance-uuid',
- project_id='fake-project-uuid',
- availability_zone='fake-az',
- user_id='fake-user-uuid')
+ db.vol_usage_update(ctxt, 1, rd_req=300, rd_bytes=400,
+ wr_req=500, wr_bytes=600,
+ instance_id='fake-instance-uuid',
+ project_id='fake-project-uuid',
+ availability_zone='fake-az',
+ user_id='fake-user-uuid')
current_usage = db.vol_get_usage_by_time(ctxt, start_time)[0]
self.assertEqual(current_usage['tot_reads'], 200)
self.assertEqual(current_usage['curr_reads'], 300)
- vol_usage = db.vol_usage_update(ctxt, 1, rd_req=400, rd_bytes=500,
- wr_req=600, wr_bytes=700,
- instance_id='fake-instance-uuid',
- project_id='fake-project-uuid',
- user_id='fake-user-uuid',
- availability_zone='fake-az',
- update_totals=True)
+ db.vol_usage_update(ctxt, 1, rd_req=400, rd_bytes=500,
+ wr_req=600, wr_bytes=700,
+ instance_id='fake-instance-uuid',
+ project_id='fake-project-uuid',
+ user_id='fake-user-uuid',
+ availability_zone='fake-az',
+ update_totals=True)
vol_usages = db.vol_get_usage_by_time(ctxt, start_time)
@@ -4714,7 +4713,7 @@ class QuotaTestCase(test.TestCase, ModelsObjectComparatorMixin):
self.ctxt, 'p1', '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', 'res0')
expected = {'resource': 'res0', 'project_id': 'p1',
'in_use': 0, 'reserved': 0, 'total': 0}
@@ -4722,7 +4721,7 @@ class QuotaTestCase(test.TestCase, ModelsObjectComparatorMixin):
self.assertEqual(value, quota_usage[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',
'res0': {'in_use': 0, 'reserved': 0},
'res1': {'in_use': 1, 'reserved': 1},
@@ -4735,8 +4734,7 @@ class QuotaTestCase(test.TestCase, ModelsObjectComparatorMixin):
self.ctxt, 'p1', 'resource', in_use=42)
def test_quota_usage_update(self):
- reservations = _quota_reserve(self.ctxt, 'p1')
- until_refresh = datetime.datetime.now() + datetime.timedelta(days=1)
+ _quota_reserve(self.ctxt, 'p1')
db.quota_usage_update(self.ctxt, 'p1', 'res0', in_use=42, reserved=43)
quota_usage = db.quota_usage_get(self.ctxt, 'p1', 'res0')
expected = {'resource': 'res0', 'project_id': 'p1',
@@ -4792,7 +4790,7 @@ class QuotaClassTestCase(test.TestCase, ModelsObjectComparatorMixin):
'resource0': 0, 'resource1': 1, 'resource2': 2})
def test_quota_class_update(self):
- qc = db.quota_class_create(self.ctxt, 'class name', 'resource', 42)
+ db.quota_class_create(self.ctxt, 'class name', 'resource', 42)
db.quota_class_update(self.ctxt, 'class name', 'resource', 43)
self.assertEqual(db.quota_class_get(self.ctxt, 'class name',
'resource').hard_limit, 43)
diff --git a/nova/tests/db/test_migrations.py b/nova/tests/db/test_migrations.py
index a9ea29e69..7e28fb1d5 100644
--- a/nova/tests/db/test_migrations.py
+++ b/nova/tests/db/test_migrations.py
@@ -806,8 +806,6 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn):
def _check_153(self, engine, data):
fake_types, fake_instances = data
# NOTE(danms): Fetch all the tables and data from scratch after change
- instances = db_utils.get_table(engine, 'instances')
- instance_types = db_utils.get_table(engine, 'instance_types')
sys_meta = db_utils.get_table(engine, 'instance_system_metadata')
# Collect all system metadata, indexed by instance_uuid
@@ -1073,7 +1071,6 @@ class TestNovaMigrations(BaseMigrationTestCase, CommonTestsMixIn):
for result in results:
the_id = result['id']
key = result['key']
- value = result['value']
original = data[the_id]
if key == 'instance_type_baz':
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index 380b69079..c058ac2cd 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -3184,7 +3184,7 @@ class ExtendedAvailabilityZoneJsonTests(ServersSampleBase):
self._verify_response('server-get-resp', subs, response, 200)
def test_detail(self):
- uuid = self._post_server()
+ self._post_server()
response = self._do_get('servers/detail')
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
@@ -3418,7 +3418,7 @@ class ConfigDriveSampleJsonTest(ServersSampleBase):
response, 200)
def test_config_drive_detail(self):
- uuid = self._post_server()
+ self._post_server()
response = self._do_get('servers/detail')
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
@@ -3496,7 +3496,7 @@ class FlavorAccessSampleJsonTests(ApiSampleTestBase):
def test_flavor_access_add_tenant(self):
self._create_flavor()
- response = self._add_tenant()
+ self._add_tenant()
def test_flavor_access_remove_tenant(self):
self._create_flavor()
diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py
index 5c7f3828d..e8368d06a 100644
--- a/nova/tests/network/test_linux_net.py
+++ b/nova/tests/network/test_linux_net.py
@@ -861,7 +861,6 @@ class LinuxNetworkTestCase(test.TestCase):
self.stubs.Set(ln, 'ensure_ebtables_rules', lambda *a, **kw: None)
net = {'bridge': 'br100', 'cidr': '10.0.0.0/24'}
ln.ensure_floating_forward('10.10.10.10', '10.0.0.1', 'eth0', net)
- one_forward_rules = len(linux_net.iptables_manager.ipv4['nat'].rules)
ln.ensure_floating_forward('10.10.10.11', '10.0.0.10', 'eth0', net)
two_forward_rules = len(linux_net.iptables_manager.ipv4['nat'].rules)
ln.ensure_floating_forward('10.10.10.10', '10.0.0.3', 'eth0', net)
diff --git a/nova/tests/network/test_network_info.py b/nova/tests/network/test_network_info.py
index bb3d91f55..38a27b51c 100644
--- a/nova/tests/network/test_network_info.py
+++ b/nova/tests/network/test_network_info.py
@@ -372,7 +372,7 @@ class NetworkInfoTests(test.TestCase):
ninfo = model.NetworkInfo([fake_network_cache_model.new_vif(),
fake_network_cache_model.new_vif(
{'address': 'bb:bb:bb:bb:bb:bb'})])
- deserialized = model.NetworkInfo.hydrate(ninfo)
+ model.NetworkInfo.hydrate(ninfo)
self.assertEqual(ninfo.fixed_ips(),
[fake_network_cache_model.new_ip({'address': '10.10.0.2'}),
fake_network_cache_model.new_ip(
diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py
index d97dcae57..2ddeb72bf 100644
--- a/nova/tests/network/test_quantumv2.py
+++ b/nova/tests/network/test_quantumv2.py
@@ -714,7 +714,6 @@ class TestQuantumv2(test.TestCase):
port_data = number == 1 and self.port_data1 or self.port_data2
self.moxed_client.delete_port(port_data[0]['id'])
- nets = [port_data[0]['network_id']]
quantumv2.get_client(mox.IgnoreArg(), admin=True).AndReturn(
self.moxed_client)
self.moxed_client.list_ports(
@@ -1056,7 +1055,6 @@ class TestQuantumv2(test.TestCase):
def test_allocate_floating_ip_with_pool_id(self):
api = quantumapi.API()
- pool_name = self.fip_pool['name']
pool_id = self.fip_pool['id']
search_opts = {'router:external': True,
'fields': 'id',
@@ -1100,7 +1098,6 @@ class TestQuantumv2(test.TestCase):
def test_release_floating_ip_associated(self):
api = quantumapi.API()
address = self.fip_associated['floating_ip_address']
- fip_id = self.fip_associated['id']
self.moxed_client.list_floatingips(floating_ip_address=address).\
AndReturn({'floatingips': [self.fip_associated]})
@@ -1144,7 +1141,6 @@ class TestQuantumv2(test.TestCase):
api = quantumapi.API()
address = self.fip_associated['floating_ip_address']
fixed_address = self.fip_associated['fixed_ip_address']
- fip_id = self.fip_associated['id']
search_opts = {'device_owner': 'compute:nova',
'device_id': self.instance['uuid']}
@@ -1178,7 +1174,6 @@ class TestQuantumv2(test.TestCase):
self.moxed_client.list_subnets(
**search_opts).AndReturn({'subnets': self.subnet_data_n})
- zone = 'compute:%s' % self.instance['availability_zone']
search_opts = {'device_id': self.instance['uuid'],
'device_owner': 'compute:nova',
'network_id': network_id}
diff --git a/nova/tests/servicegroup/test_mc_servicegroup.py b/nova/tests/servicegroup/test_mc_servicegroup.py
index 9d5601ff8..9f27ecc31 100644
--- a/nova/tests/servicegroup/test_mc_servicegroup.py
+++ b/nova/tests/servicegroup/test_mc_servicegroup.py
@@ -103,15 +103,9 @@ class MemcachedServiceGroupTestCase(test.TestCase):
ServiceFixture(host3, self._binary, self._topic)).serv
serv3.start()
- service_ref1 = db.service_get_by_args(self._ctx,
- host1,
- self._binary)
- service_ref2 = db.service_get_by_args(self._ctx,
- host2,
- self._binary)
- service_ref3 = db.service_get_by_args(self._ctx,
- host3,
- self._binary)
+ db.service_get_by_args(self._ctx, host1, self._binary)
+ db.service_get_by_args(self._ctx, host2, self._binary)
+ db.service_get_by_args(self._ctx, host3, self._binary)
host1key = str("%s:%s" % (self._topic, host1))
host2key = str("%s:%s" % (self._topic, host2))
@@ -198,9 +192,7 @@ class MemcachedServiceGroupTestCase(test.TestCase):
serv = self.useFixture(
ServiceFixture(self._host, self._binary, self._topic)).serv
serv.start()
- service_ref = db.service_get_by_args(self._ctx,
- self._host,
- self._binary)
+ db.service_get_by_args(self._ctx, self._host, self._binary)
self.servicegroup_api = servicegroup.API()
# updating model_disconnected
diff --git a/nova/tests/servicegroup/test_zk_driver.py b/nova/tests/servicegroup/test_zk_driver.py
index eb6ddd4bf..716f62e4e 100644
--- a/nova/tests/servicegroup/test_zk_driver.py
+++ b/nova/tests/servicegroup/test_zk_driver.py
@@ -40,7 +40,7 @@ class ZKServiceGroupTestCase(test.TestCase):
self.flags(servicegroup_driver='zk')
self.flags(address='localhost:2181', group="zookeeper")
try:
- _unused = zk.ZooKeeperDriver()
+ zk.ZooKeeperDriver()
except ImportError:
self.skipTest("Unable to test due to lack of ZooKeeper")
diff --git a/nova/tests/test_availability_zones.py b/nova/tests/test_availability_zones.py
index 3923dd9a1..0c58cd08a 100644
--- a/nova/tests/test_availability_zones.py
+++ b/nova/tests/test_availability_zones.py
@@ -179,8 +179,8 @@ class AvailabilityZoneTestCases(test.TestCase):
disabled=False)
service4 = self._create_service_with_topic('compute', 'host4',
disabled=True)
- service5 = self._create_service_with_topic('compute', 'host5',
- disabled=True)
+ self._create_service_with_topic('compute', 'host5',
+ disabled=True)
self._add_to_aggregate(service1, self.agg)
self._add_to_aggregate(service2, self.agg)
diff --git a/nova/tests/test_cinder.py b/nova/tests/test_cinder.py
index 98cc1c3f9..eefc1bab6 100644
--- a/nova/tests/test_cinder.py
+++ b/nova/tests/test_cinder.py
@@ -153,7 +153,7 @@ class CinderTestCase(test.TestCase):
self.fake_client_factory.assert_called(*args, **kwargs)
def test_context_with_catalog(self):
- volume = self.api.get(self.context, '1234')
+ self.api.get(self.context, '1234')
self.assert_called('GET', '/volumes/1234')
self.assertEquals(
self.fake_client_factory.client.client.management_url,
@@ -163,7 +163,7 @@ class CinderTestCase(test.TestCase):
self.flags(
cinder_endpoint_template='http://other_host:8776/v1/%(project_id)s'
)
- volume = self.api.get(self.context, '1234')
+ self.api.get(self.context, '1234')
self.assert_called('GET', '/volumes/1234')
self.assertEquals(
self.fake_client_factory.client.client.management_url,
@@ -183,7 +183,7 @@ class CinderTestCase(test.TestCase):
# The True/False negation is awkward, but better for the client
# to pass us insecure=True and we check verify_cert == False
self.flags(cinder_api_insecure=True)
- volume = self.api.get(self.context, '1234')
+ self.api.get(self.context, '1234')
self.assert_called('GET', '/volumes/1234')
self.assertEquals(
self.fake_client_factory.client.client.verify_cert, False)
@@ -191,7 +191,7 @@ class CinderTestCase(test.TestCase):
def test_cinder_api_cacert_file(self):
cacert = "/etc/ssl/certs/ca-certificates.crt"
self.flags(cinder_ca_certificates_file=cacert)
- volume = self.api.get(self.context, '1234')
+ self.api.get(self.context, '1234')
self.assert_called('GET', '/volumes/1234')
self.assertEquals(
self.fake_client_factory.client.client.verify_cert, cacert)
@@ -199,7 +199,7 @@ class CinderTestCase(test.TestCase):
def test_cinder_http_retries(self):
retries = 42
self.flags(cinder_http_retries=retries)
- volume = self.api.get(self.context, '1234')
+ self.api.get(self.context, '1234')
self.assert_called('GET', '/volumes/1234')
self.assertEquals(
self.fake_client_factory.client.client.retries, retries)
diff --git a/nova/tests/test_flavors.py b/nova/tests/test_flavors.py
index bd3f805cd..6edbddb21 100644
--- a/nova/tests/test_flavors.py
+++ b/nova/tests/test_flavors.py
@@ -69,11 +69,8 @@ class InstanceTypeTestCase(test.TestCase):
project_id = 'fake'
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = 'flavor1'
- type_ref = flavors.create('some flavor', 256, 1, 120, 100,
- flavorid=flavor_id)
- access_ref = flavors.add_flavor_access(flavor_id,
- project_id,
- ctxt=ctxt)
+ flavors.create('some flavor', 256, 1, 120, 100, flavorid=flavor_id)
+ flavors.add_flavor_access(flavor_id, project_id, ctxt=ctxt)
self.assertRaises(exception.FlavorAccessExists,
flavors.add_flavor_access,
flavor_id, project_id, ctxt)
@@ -92,10 +89,8 @@ class InstanceTypeTestCase(test.TestCase):
project_id = 'fake'
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = 'flavor1'
- type_ref = flavors.create('some flavor', 256, 1, 120, 100,
- flavorid=flavor_id)
- access_ref = flavors.add_flavor_access(flavor_id, project_id,
- ctxt)
+ flavors.create('some flavor', 256, 1, 120, 100, flavorid=flavor_id)
+ flavors.add_flavor_access(flavor_id, project_id, ctxt)
flavors.remove_flavor_access(flavor_id, project_id, ctxt)
projects = flavors.get_flavor_access_by_flavor_id(flavor_id,
@@ -107,8 +102,7 @@ class InstanceTypeTestCase(test.TestCase):
project_id = 'fake'
ctxt = context.RequestContext(user_id, project_id, is_admin=True)
flavor_id = 'flavor1'
- type_ref = flavors.create('some flavor', 256, 1, 120, 100,
- flavorid=flavor_id)
+ flavors.create('some flavor', 256, 1, 120, 100, flavorid=flavor_id)
self.assertRaises(exception.FlavorAccessNotFound,
flavors.remove_flavor_access,
flavor_id, project_id, ctxt=ctxt)
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index be3669958..37009f3df 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -227,7 +227,7 @@ class QuotaIntegrationTestCase(test.TestCase):
timeutils.advance_time_seconds(80)
- result = quota.QUOTAS.expire(self.context)
+ quota.QUOTAS.expire(self.context)
assertInstancesReserved(0)
diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py
index f44a5f87a..21fc2ce47 100644
--- a/nova/virt/baremetal/pxe.py
+++ b/nova/virt/baremetal/pxe.py
@@ -213,7 +213,7 @@ def get_tftp_image_info(instance, instance_type):
image_info['ramdisk'][0] = str(instance['ramdisk_id'])
image_info['deploy_kernel'][0] = get_deploy_aki_id(instance_type)
image_info['deploy_ramdisk'][0] = get_deploy_ari_id(instance_type)
- except KeyError as e:
+ except KeyError:
pass
missing_labels = []
diff --git a/nova/virt/baremetal/tilera.py b/nova/virt/baremetal/tilera.py
index bb89a5f94..36127bfa2 100755
--- a/nova/virt/baremetal/tilera.py
+++ b/nova/virt/baremetal/tilera.py
@@ -106,7 +106,7 @@ def get_tftp_image_info(instance):
}
try:
image_info['kernel'][0] = str(instance['kernel_id'])
- except KeyError as e:
+ except KeyError:
pass
missing_labels = []
@@ -347,7 +347,7 @@ class Tilera(base.NodeDriver):
user_data = instance['user_data']
try:
self._iptables_set(node_ip, user_data)
- except Exception as ex:
+ except Exception:
self.deactivate_bootloader(context, node, instance)
raise exception.NovaException(_("Node is "
"unknown error state."))
diff --git a/nova/virt/baremetal/tilera_pdu.py b/nova/virt/baremetal/tilera_pdu.py
index 0e491168f..90f9287e4 100755
--- a/nova/virt/baremetal/tilera_pdu.py
+++ b/nova/virt/baremetal/tilera_pdu.py
@@ -109,7 +109,7 @@ class Pdu(base.PowerManager):
return CONF.baremetal.tile_pdu_off
else:
try:
- out = utils.execute(CONF.baremetal.tile_pdu_mgr,
+ utils.execute(CONF.baremetal.tile_pdu_mgr,
CONF.baremetal.tile_pdu_ip, mode)
time.sleep(CONF.baremetal.tile_power_wait)
return mode
diff --git a/nova/virt/hyperv/vmutils.py b/nova/virt/hyperv/vmutils.py
index 680ec2d61..2cc40a1de 100644
--- a/nova/virt/hyperv/vmutils.py
+++ b/nova/virt/hyperv/vmutils.py
@@ -335,7 +335,7 @@ class VMUtils(object):
def get_vm_storage_paths(self, vm_name):
vm = self._lookup_vm_check(vm_name)
- vs_man_svc = self._conn.Msvm_VirtualSystemManagementService()[0]
+ self._conn.Msvm_VirtualSystemManagementService()
vmsettings = vm.associators(
wmi_result_class='Msvm_VirtualSystemSettingData')
rasds = vmsettings[0].associators(
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 4544d35fb..ca673579b 100755
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -555,7 +555,7 @@ class LibvirtDriver(driver.ComputeDriver):
event_thread.start()
LOG.debug("Starting green dispatch thread")
- dispatch_thread = eventlet.spawn(self._dispatch_thread)
+ eventlet.spawn(self._dispatch_thread)
def init_host(self, host):
if not self.has_min_version(MIN_LIBVIRT_VERSION):
@@ -593,7 +593,7 @@ class LibvirtDriver(driver.ComputeDriver):
libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE,
self._event_lifecycle_callback,
self)
- except Exception as e:
+ except Exception:
LOG.warn(_("URI %s does not support events"),
self.uri())
@@ -1116,7 +1116,7 @@ class LibvirtDriver(driver.ComputeDriver):
if state == power_state.RUNNING:
flags |= libvirt.VIR_DOMAIN_AFFECT_LIVE
virt_dom.attachDeviceFlags(cfg.to_xml(), flags)
- except libvirt.libvirtError as ex:
+ except libvirt.libvirtError:
LOG.error(_('attaching network adapter failed.'),
instance=instance)
self.vif_driver.unplug(instance, (network, mapping))
@@ -3075,7 +3075,6 @@ class LibvirtDriver(driver.ComputeDriver):
(disk_available_gb * 1024) - CONF.reserved_host_disk_mb
# Compare CPU
- src = instance['host']
source_cpu_info = src_compute_info['cpu_info']
self._compare_cpu(source_cpu_info)
diff --git a/nova/virt/powervm/lpar.py b/nova/virt/powervm/lpar.py
index 7be8b046a..a6c782692 100644
--- a/nova/virt/powervm/lpar.py
+++ b/nova/virt/powervm/lpar.py
@@ -51,7 +51,7 @@ def load_from_conf_data(conf_data):
for (key, value) in attribs.items():
try:
lpar[key] = value
- except exception.PowerVMLPARAttributeNotFound as e:
+ except exception.PowerVMLPARAttributeNotFound:
LOG.info(_('Encountered unknown LPAR attribute: %s\n'
'Continuing without storing') % key)
return lpar
diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py
index 18cba0ba2..fffb77fc9 100644
--- a/nova/virt/powervm/operator.py
+++ b/nova/virt/powervm/operator.py
@@ -766,11 +766,11 @@ class BaseOperator(object):
def _decompress_image_file(self, file_path, outfile_path):
command = "/usr/bin/gunzip -c %s > %s" % (file_path, outfile_path)
- output = self.run_vios_command_as_root(command)
+ self.run_vios_command_as_root(command)
# Remove compressed image file
command = "/usr/bin/rm %s" % file_path
- output = self.run_vios_command_as_root(command)
+ self.run_vios_command_as_root(command)
return outfile_path