Merge "Removed unused variables"

This commit is contained in:
Jenkins 2015-05-28 23:11:18 +00:00 committed by Gerrit Code Review
commit 46bba88413
11 changed files with 15 additions and 25 deletions

View File

@ -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())

View File

@ -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())

View File

@ -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

View File

@ -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,

View File

@ -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)

View File

@ -55,7 +55,7 @@ def match(value, req):
return True
if not words:
break
op = words.pop(0) # remove a keyword <or>
words.pop(0) # remove a keyword <or>
if not words:
break
return False

View File

@ -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,

View File

@ -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)

View File

@ -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']},

View File

@ -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)

View File

@ -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)