diff --git a/nova/api/openstack/compute/contrib/quota_classes.py b/nova/api/openstack/compute/contrib/quota_classes.py index 3b799241e37d..861a974ffc1c 100644 --- a/nova/api/openstack/compute/contrib/quota_classes.py +++ b/nova/api/openstack/compute/contrib/quota_classes.py @@ -84,8 +84,7 @@ class QuotaClassSetsController(wsgi.Controller): bad_keys.append(key) continue try: - value = utils.validate_integer( - body['quota_class_set'][key], key) + utils.validate_integer(body['quota_class_set'][key], key) except exception.InvalidInput as e: raise webob.exc.HTTPBadRequest( explanation=e.format_message()) diff --git a/nova/api/openstack/compute/contrib/quotas.py b/nova/api/openstack/compute/contrib/quotas.py index 1ac076e478e0..21d1b078cf27 100644 --- a/nova/api/openstack/compute/contrib/quotas.py +++ b/nova/api/openstack/compute/contrib/quotas.py @@ -161,7 +161,7 @@ class QuotaSetsController(wsgi.Controller): force_update = strutils.bool_from_string(value) elif key not in NON_QUOTA_KEYS and value: try: - value = utils.validate_integer(value, key) + utils.validate_integer(value, key) except exception.InvalidInput as e: raise webob.exc.HTTPBadRequest( explanation=e.format_message()) diff --git a/nova/api/validator.py b/nova/api/validator.py index 755de1912c43..9bc51e86632b 100644 --- a/nova/api/validator.py +++ b/nova/api/validator.py @@ -81,7 +81,7 @@ def validate_image_path(val): def validate_user_data(user_data): """Check if the user_data is encoded properly.""" try: - user_data = base64.b64decode(user_data) + base64.b64decode(user_data) except TypeError: return False return True diff --git a/nova/compute/api.py b/nova/compute/api.py index ff26924792e1..5372247fa15a 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -421,7 +421,6 @@ class API(base.Base): # Convert to the appropriate exception message if allowed <= 0: msg = _("Cannot run any more instances of this type.") - allowed = 0 elif min_count <= allowed <= max_count: # We're actually OK, but still need reservations return self._check_num_instances_quota(context, instance_type, diff --git a/nova/compute/manager.py b/nova/compute/manager.py index a7d6b0d5ce80..2441e6e4bf6e 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2112,7 +2112,7 @@ class ComputeManager(manager.Manager): resources['block_device_info'] = block_device_info except (exception.InstanceNotFound, exception.UnexpectedDeletingTaskStateError): - with excutils.save_and_reraise_exception() as ctxt: + with excutils.save_and_reraise_exception(): # Make sure the async call finishes if network_info is not None: network_info.wait(do_raise=False) diff --git a/nova/scheduler/filters/extra_specs_ops.py b/nova/scheduler/filters/extra_specs_ops.py index ef245345609f..c21dceddaf0f 100644 --- a/nova/scheduler/filters/extra_specs_ops.py +++ b/nova/scheduler/filters/extra_specs_ops.py @@ -55,7 +55,7 @@ def match(value, req): return True if not words: break - op = words.pop(0) # remove a keyword + words.pop(0) # remove a keyword if not words: break return False diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py index 54615adbff4d..80ca1874b215 100644 --- a/nova/tests/unit/compute/test_compute.py +++ b/nova/tests/unit/compute/test_compute.py @@ -9969,7 +9969,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): aggr = self.api.create_aggregate(self.context, 'fake_aggregate', 'fake_zone') fake_notifier.NOTIFICATIONS = [] - aggr = self.api.update_aggregate(self.context, aggr['id'], + self.api.update_aggregate(self.context, aggr['id'], {'name': 'new_fake_aggregate'}) self.assertIsNone(availability_zones._get_cache().get('cache')) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2) @@ -9993,8 +9993,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): fake_host) metadata = {'name': 'new_fake_aggregate'} fake_notifier.NOTIFICATIONS = [] - aggr2 = self.api.update_aggregate(self.context, aggr2['id'], - metadata) + self.api.update_aggregate(self.context, aggr2['id'], metadata) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2) msg = fake_notifier.NOTIFICATIONS[0] self.assertEqual(msg.event_type, @@ -10016,8 +10015,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): fake_host) metadata = {'availability_zone': 'new_fake_zone'} fake_notifier.NOTIFICATIONS = [] - aggr1 = self.api.update_aggregate(self.context, aggr1['id'], - metadata) + self.api.update_aggregate(self.context, aggr1['id'], metadata) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2) msg = fake_notifier.NOTIFICATIONS[0] self.assertEqual(msg.event_type, @@ -10045,8 +10043,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): aggr3 = self._init_aggregate_with_host(None, 'fake_aggregate3', None, fake_host2) metadata = {'availability_zone': fake_zone} - aggr3 = self.api.update_aggregate(self.context, aggr3['id'], - metadata) + self.api.update_aggregate(self.context, aggr3['id'], metadata) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 15) msg = fake_notifier.NOTIFICATIONS[13] self.assertEqual(msg.event_type, @@ -10146,8 +10143,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): fake_host) metadata = {'availability_zone': 'new_fake_zone'} fake_notifier.NOTIFICATIONS = [] - aggr1 = self.api.update_aggregate_metadata(self.context, - aggr1['id'], metadata) + self.api.update_aggregate_metadata(self.context, aggr1['id'], metadata) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2) msg = fake_notifier.NOTIFICATIONS[0] self.assertEqual(msg.event_type, @@ -10190,9 +10186,7 @@ class ComputeAPIAggrTestCase(BaseTestCase): aggr3 = self._init_aggregate_with_host(None, 'fake_aggregate3', None, fake_host) metadata = {'availability_zone': fake_zone} - aggr3 = self.api.update_aggregate_metadata(self.context, - aggr3['id'], - metadata) + self.api.update_aggregate_metadata(self.context, aggr3['id'], metadata) self.assertEqual(len(fake_notifier.NOTIFICATIONS), 15) msg = fake_notifier.NOTIFICATIONS[13] self.assertEqual(msg.event_type, diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index 7f884c70bc61..7aeebc41a8a5 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -2411,8 +2411,8 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin): db.instance_update(self.ctxt, instance['uuid'], {"task_state": None}) # Ensure the newly rebooted instance is not returned. - instance = self.create_instance_with_args(task_state="rebooting", - updated_at=timeutils.utcnow()) + self.create_instance_with_args(task_state="rebooting", + updated_at=timeutils.utcnow()) results = db.instance_get_all_hung_in_rebooting(self.ctxt, 10) self.assertEqual([], results) diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py index 736e277f61c7..b514a340137d 100644 --- a/nova/tests/unit/network/test_neutronv2.py +++ b/nova/tests/unit/network/test_neutronv2.py @@ -407,7 +407,6 @@ class TestNeutronv2Base(test.TestCase): macs = set(macs) req_net_ids = [] ordered_networks = [] - port = {} if 'requested_networks' in kwargs: for request in kwargs['requested_networks']: if request.port_id: @@ -583,7 +582,6 @@ class TestNeutronv2Base(test.TestCase): mox.IgnoreArg()).AndReturn( fake_info_cache) port_data = number == 1 and self.port_data1 or self.port_data2 - nets = number == 1 and self.nets1 or self.nets2 net_info_cache = [] for port in port_data: net_info_cache.append({"network": {"id": port['network_id']}, diff --git a/nova/tests/unit/test_context.py b/nova/tests/unit/test_context.py index 2f0273b02ddf..5b4056eade49 100644 --- a/nova/tests/unit/test_context.py +++ b/nova/tests/unit/test_context.py @@ -134,7 +134,7 @@ class ContextTestCase(test.NoDBTestCase): '222', roles=['admin', 'weasel']) - ctxt = context.RequestContext.from_dict(ctxt.to_dict()) + context.RequestContext.from_dict(ctxt.to_dict()) self.assertEqual(len(warns), 0, warns) diff --git a/nova/tests/unit/virt/libvirt/test_fakelibvirt.py b/nova/tests/unit/virt/libvirt/test_fakelibvirt.py index ee3bebaab570..c7cbca3054d1 100644 --- a/nova/tests/unit/virt/libvirt/test_fakelibvirt.py +++ b/nova/tests/unit/virt/libvirt/test_fakelibvirt.py @@ -173,7 +173,7 @@ class FakeLibvirtTests(test.NoDBTestCase): self.assertEqual(1, dom.isActive()) dom.destroy() try: - dom = conn.lookupByName('testname') + conn.lookupByName('testname') except libvirt.libvirtError as e: self.assertEqual(e.get_error_code(), libvirt.VIR_ERR_NO_DOMAIN) self.assertEqual(e.get_error_domain(), libvirt.VIR_FROM_QEMU)