Remove trivial cases of unused variables (1)
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 1, split to reduce conflicts. Change-Id: I82854349574ec4bcb9336aba626eefdaed81a8c8
This commit is contained in:
@@ -802,7 +802,6 @@ class CloudController(object):
|
|||||||
'detaching': 'in-use'}
|
'detaching': 'in-use'}
|
||||||
|
|
||||||
instance_ec2_id = None
|
instance_ec2_id = None
|
||||||
instance_data = None
|
|
||||||
|
|
||||||
if volume.get('instance_uuid', None):
|
if volume.get('instance_uuid', None):
|
||||||
instance_uuid = volume['instance_uuid']
|
instance_uuid = volume['instance_uuid']
|
||||||
@@ -810,8 +809,7 @@ class CloudController(object):
|
|||||||
instance_uuid)
|
instance_uuid)
|
||||||
|
|
||||||
instance_ec2_id = ec2utils.id_to_ec2_inst_id(instance_uuid)
|
instance_ec2_id = ec2utils.id_to_ec2_inst_id(instance_uuid)
|
||||||
instance_data = '%s[%s]' % (instance_ec2_id,
|
|
||||||
instance['host'])
|
|
||||||
v = {}
|
v = {}
|
||||||
v['volumeId'] = ec2utils.id_to_ec2_vol_id(volume['id'])
|
v['volumeId'] = ec2utils.id_to_ec2_vol_id(volume['id'])
|
||||||
v['status'] = valid_ec2_api_volume_status_map.get(volume['status'],
|
v['status'] = valid_ec2_api_volume_status_map.get(volume['status'],
|
||||||
|
@@ -49,7 +49,6 @@ def convert_password(context, password):
|
|||||||
|
|
||||||
def handle_password(req, meta_data):
|
def handle_password(req, meta_data):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
password = meta_data.password
|
|
||||||
if req.method == 'GET':
|
if req.method == 'GET':
|
||||||
return meta_data.password
|
return meta_data.password
|
||||||
elif req.method == 'POST':
|
elif req.method == 'POST':
|
||||||
|
@@ -60,7 +60,7 @@ class InterfaceAttachmentController(object):
|
|||||||
|
|
||||||
port_id = id
|
port_id = id
|
||||||
try:
|
try:
|
||||||
instance = self.compute_api.get(context, server_id)
|
self.compute_api.get(context, server_id)
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
raise exc.HTTPNotFound()
|
raise exc.HTTPNotFound()
|
||||||
|
|
||||||
|
@@ -94,7 +94,7 @@ def make_server(elem):
|
|||||||
class ExtendedIpsServerTemplate(xmlutil.TemplateBuilder):
|
class ExtendedIpsServerTemplate(xmlutil.TemplateBuilder):
|
||||||
def construct(self):
|
def construct(self):
|
||||||
root = xmlutil.TemplateElement('server', selector='server')
|
root = xmlutil.TemplateElement('server', selector='server')
|
||||||
elem = xmlutil.SubTemplateElement(root, 'server', selector='servers')
|
xmlutil.SubTemplateElement(root, 'server', selector='servers')
|
||||||
make_server(root)
|
make_server(root)
|
||||||
return xmlutil.SlaveTemplate(root, 1, nsmap={
|
return xmlutil.SlaveTemplate(root, 1, nsmap={
|
||||||
Extended_ips.alias: Extended_ips.namespace})
|
Extended_ips.alias: Extended_ips.namespace})
|
||||||
|
@@ -69,8 +69,7 @@ class FixedIPController(object):
|
|||||||
fixed_ip = db.fixed_ip_get_by_address(context, address)
|
fixed_ip = db.fixed_ip_get_by_address(context, address)
|
||||||
db.fixed_ip_update(context, fixed_ip['address'],
|
db.fixed_ip_update(context, fixed_ip['address'],
|
||||||
{'reserved': reserved})
|
{'reserved': reserved})
|
||||||
except (exception.FixedIpNotFoundForAddress,
|
except (exception.FixedIpNotFoundForAddress, exception.FixedIpInvalid):
|
||||||
exception.FixedIpInvalid) as ex:
|
|
||||||
msg = _("Fixed IP %s not found") % address
|
msg = _("Fixed IP %s not found") % address
|
||||||
raise webob.exc.HTTPNotFound(explanation=msg)
|
raise webob.exc.HTTPNotFound(explanation=msg)
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ class FlavorExtraSpecsController(object):
|
|||||||
extra_spec = db.instance_type_extra_specs_get_item(context,
|
extra_spec = db.instance_type_extra_specs_get_item(context,
|
||||||
flavor_id, id)
|
flavor_id, id)
|
||||||
return extra_spec
|
return extra_spec
|
||||||
except exception.InstanceTypeExtraSpecsNotFound as e:
|
except exception.InstanceTypeExtraSpecsNotFound:
|
||||||
raise exc.HTTPNotFound()
|
raise exc.HTTPNotFound()
|
||||||
|
|
||||||
def delete(self, req, flavor_id, id):
|
def delete(self, req, flavor_id, id):
|
||||||
|
@@ -183,8 +183,7 @@ class ServiceController(object):
|
|||||||
raise webob.exc.HTTPUnprocessableEntity(detail=msg)
|
raise webob.exc.HTTPUnprocessableEntity(detail=msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
svc = self.host_api.service_update(context, host, binary,
|
self.host_api.service_update(context, host, binary, status_detail)
|
||||||
status_detail)
|
|
||||||
except exception.ServiceNotFound:
|
except exception.ServiceNotFound:
|
||||||
raise webob.exc.HTTPNotFound(_("Unknown service"))
|
raise webob.exc.HTTPNotFound(_("Unknown service"))
|
||||||
|
|
||||||
|
@@ -552,10 +552,10 @@ class Controller(wsgi.Controller):
|
|||||||
search_opts=search_opts,
|
search_opts=search_opts,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
marker=marker)
|
marker=marker)
|
||||||
except exception.MarkerNotFound as e:
|
except exception.MarkerNotFound:
|
||||||
msg = _('marker [%s] not found') % marker
|
msg = _('marker [%s] not found') % marker
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
except exception.FlavorNotFound as e:
|
except exception.FlavorNotFound:
|
||||||
log_msg = _("Flavor '%s' could not be found ")
|
log_msg = _("Flavor '%s' could not be found ")
|
||||||
LOG.debug(log_msg, search_opts['flavor'])
|
LOG.debug(log_msg, search_opts['flavor'])
|
||||||
instance_list = []
|
instance_list = []
|
||||||
@@ -1094,11 +1094,11 @@ class Controller(wsgi.Controller):
|
|||||||
except exception.InstanceInvalidState as state_error:
|
except exception.InstanceInvalidState as state_error:
|
||||||
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
common.raise_http_conflict_for_instance_invalid_state(state_error,
|
||||||
'resize')
|
'resize')
|
||||||
except exception.ImageNotAuthorized as image_error:
|
except exception.ImageNotAuthorized:
|
||||||
msg = _("You are not authorized to access the image "
|
msg = _("You are not authorized to access the image "
|
||||||
"the instance was started with.")
|
"the instance was started with.")
|
||||||
raise exc.HTTPUnauthorized(explanation=msg)
|
raise exc.HTTPUnauthorized(explanation=msg)
|
||||||
except exception.ImageNotFound as image_error:
|
except exception.ImageNotFound:
|
||||||
msg = _("Image that the instance was started "
|
msg = _("Image that the instance was started "
|
||||||
"with could not be found.")
|
"with could not be found.")
|
||||||
raise exc.HTTPBadRequest(explanation=msg)
|
raise exc.HTTPBadRequest(explanation=msg)
|
||||||
|
@@ -72,7 +72,6 @@ from nova.openstack.common.db import exception as db_exc
|
|||||||
from nova.openstack.common import importutils
|
from nova.openstack.common import importutils
|
||||||
from nova.openstack.common import log as logging
|
from nova.openstack.common import log as logging
|
||||||
from nova.openstack.common import rpc
|
from nova.openstack.common import rpc
|
||||||
from nova.openstack.common import timeutils
|
|
||||||
from nova import quota
|
from nova import quota
|
||||||
from nova import servicegroup
|
from nova import servicegroup
|
||||||
from nova import version
|
from nova import version
|
||||||
@@ -655,7 +654,6 @@ class ServiceCommands(object):
|
|||||||
"""
|
"""
|
||||||
servicegroup_api = servicegroup.API()
|
servicegroup_api = servicegroup.API()
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
now = timeutils.utcnow()
|
|
||||||
services = db.service_get_all(ctxt)
|
services = db.service_get_all(ctxt)
|
||||||
services = availability_zones.set_availability_zones(ctxt, services)
|
services = availability_zones.set_availability_zones(ctxt, services)
|
||||||
if host:
|
if host:
|
||||||
@@ -1003,13 +1001,12 @@ class AgentBuildCommands(object):
|
|||||||
hypervisor='xen'):
|
hypervisor='xen'):
|
||||||
"""Creates a new agent build."""
|
"""Creates a new agent build."""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
agent_build = db.agent_build_create(ctxt,
|
db.agent_build_create(ctxt, {'hypervisor': hypervisor,
|
||||||
{'hypervisor': hypervisor,
|
'os': os,
|
||||||
'os': os,
|
'architecture': architecture,
|
||||||
'architecture': architecture,
|
'version': version,
|
||||||
'version': version,
|
'url': url,
|
||||||
'url': url,
|
'md5hash': md5hash})
|
||||||
'md5hash': md5hash})
|
|
||||||
|
|
||||||
def delete(self, os, architecture, hypervisor='xen'):
|
def delete(self, os, architecture, hypervisor='xen'):
|
||||||
"""Deletes an existing agent build."""
|
"""Deletes an existing agent build."""
|
||||||
|
@@ -494,7 +494,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
'assuming it\'s not on shared storage'),
|
'assuming it\'s not on shared storage'),
|
||||||
instance=instance)
|
instance=instance)
|
||||||
shared_storage = False
|
shared_storage = False
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception(_('Failed to check if instance shared'),
|
LOG.exception(_('Failed to check if instance shared'),
|
||||||
instance=instance)
|
instance=instance)
|
||||||
finally:
|
finally:
|
||||||
|
@@ -395,7 +395,7 @@ class API(LocalAPI):
|
|||||||
self.base_rpcapi.ping(context, '1.21 GigaWatts',
|
self.base_rpcapi.ping(context, '1.21 GigaWatts',
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
break
|
break
|
||||||
except rpc_common.Timeout as e:
|
except rpc_common.Timeout:
|
||||||
LOG.warning(_('Timed out waiting for nova-conductor. '
|
LOG.warning(_('Timed out waiting for nova-conductor. '
|
||||||
'Is it running? Or did this service start '
|
'Is it running? Or did this service start '
|
||||||
'before nova-conductor?'))
|
'before nova-conductor?'))
|
||||||
|
@@ -111,9 +111,6 @@ def _upgrade_bdm_v2(meta, bdm_table, bdm_shadow_table):
|
|||||||
_bdm_rows_v1 = ('id', 'device_name', 'virtual_name',
|
_bdm_rows_v1 = ('id', 'device_name', 'virtual_name',
|
||||||
'snapshot_id', 'volume_id', 'instance_uuid')
|
'snapshot_id', 'volume_id', 'instance_uuid')
|
||||||
|
|
||||||
_bdm_rows_v2 = ('id', 'source_type', 'destination_type', 'guest_format',
|
|
||||||
'device_type', 'disk_bus', 'boot_index', 'image_id')
|
|
||||||
|
|
||||||
_instance_cols = ('uuid', 'image_ref', 'root_device_name')
|
_instance_cols = ('uuid', 'image_ref', 'root_device_name')
|
||||||
|
|
||||||
def _get_columns(table, names):
|
def _get_columns(table, names):
|
||||||
|
@@ -70,7 +70,7 @@ def visit_insert_from_select(element, compiler, **kw):
|
|||||||
def _get_not_supported_column(col_name_col_instance, column_name):
|
def _get_not_supported_column(col_name_col_instance, column_name):
|
||||||
try:
|
try:
|
||||||
column = col_name_col_instance[column_name]
|
column = col_name_col_instance[column_name]
|
||||||
except Exception as e:
|
except Exception:
|
||||||
msg = _("Please specify column %s in col_name_col_instance "
|
msg = _("Please specify column %s in col_name_col_instance "
|
||||||
"param. It is required because column has unsupported "
|
"param. It is required because column has unsupported "
|
||||||
"type by sqlite).")
|
"type by sqlite).")
|
||||||
|
@@ -198,13 +198,11 @@ class S3ImageService(object):
|
|||||||
def _s3_parse_manifest(self, context, metadata, manifest):
|
def _s3_parse_manifest(self, context, metadata, manifest):
|
||||||
manifest = etree.fromstring(manifest)
|
manifest = etree.fromstring(manifest)
|
||||||
image_format = 'ami'
|
image_format = 'ami'
|
||||||
image_type = 'machine'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kernel_id = manifest.find('machine_configuration/kernel_id').text
|
kernel_id = manifest.find('machine_configuration/kernel_id').text
|
||||||
if kernel_id == 'true':
|
if kernel_id == 'true':
|
||||||
image_format = 'aki'
|
image_format = 'aki'
|
||||||
image_type = 'kernel'
|
|
||||||
kernel_id = None
|
kernel_id = None
|
||||||
except Exception:
|
except Exception:
|
||||||
kernel_id = None
|
kernel_id = None
|
||||||
@@ -213,7 +211,6 @@ class S3ImageService(object):
|
|||||||
ramdisk_id = manifest.find('machine_configuration/ramdisk_id').text
|
ramdisk_id = manifest.find('machine_configuration/ramdisk_id').text
|
||||||
if ramdisk_id == 'true':
|
if ramdisk_id == 'true':
|
||||||
image_format = 'ari'
|
image_format = 'ari'
|
||||||
image_type = 'ramdisk'
|
|
||||||
ramdisk_id = None
|
ramdisk_id = None
|
||||||
except Exception:
|
except Exception:
|
||||||
ramdisk_id = None
|
ramdisk_id = None
|
||||||
@@ -270,7 +267,7 @@ class S3ImageService(object):
|
|||||||
|
|
||||||
#TODO(bcwaldon): right now, this removes user-defined ids.
|
#TODO(bcwaldon): right now, this removes user-defined ids.
|
||||||
# We need to re-enable this.
|
# We need to re-enable this.
|
||||||
image_id = metadata.pop('id', None)
|
metadata.pop('id', None)
|
||||||
|
|
||||||
image = self.service.create(context, metadata)
|
image = self.service.create(context, metadata)
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ class IP(Model):
|
|||||||
if self['address'] and not self['version']:
|
if self['address'] and not self['version']:
|
||||||
try:
|
try:
|
||||||
self['version'] = netaddr.IPAddress(self['address']).version
|
self['version'] = netaddr.IPAddress(self['address']).version
|
||||||
except netaddr.AddrFormatError as e:
|
except netaddr.AddrFormatError:
|
||||||
raise exception.InvalidIpAddressError(self['address'])
|
raise exception.InvalidIpAddressError(self['address'])
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
@@ -325,7 +325,7 @@ class API(base.Base):
|
|||||||
for port in ports:
|
for port in ports:
|
||||||
try:
|
try:
|
||||||
quantumv2.get_client(context).delete_port(port['id'])
|
quantumv2.get_client(context).delete_port(port['id'])
|
||||||
except Exception as ex:
|
except Exception:
|
||||||
LOG.exception(_("Failed to delete quantum port %(portid)s ")
|
LOG.exception(_("Failed to delete quantum port %(portid)s ")
|
||||||
% {'portid': port['id']})
|
% {'portid': port['id']})
|
||||||
|
|
||||||
|
@@ -153,7 +153,7 @@ class AttestationService(object):
|
|||||||
return httplib.OK, res
|
return httplib.OK, res
|
||||||
return status_code, None
|
return status_code, None
|
||||||
|
|
||||||
except (socket.error, IOError) as e:
|
except (socket.error, IOError):
|
||||||
return IOError, None
|
return IOError, None
|
||||||
|
|
||||||
def _request(self, cmd, subcmd, hosts):
|
def _request(self, cmd, subcmd, hosts):
|
||||||
|
@@ -286,7 +286,7 @@ class Service(service.Service):
|
|||||||
"""Perform basic config checks before starting processing."""
|
"""Perform basic config checks before starting processing."""
|
||||||
# Make sure the tempdir exists and is writable
|
# Make sure the tempdir exists and is writable
|
||||||
try:
|
try:
|
||||||
with utils.tempdir() as tmpdir:
|
with utils.tempdir():
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(_('Temporary directory is invalid: %s'), e)
|
LOG.error(_('Temporary directory is invalid: %s'), e)
|
||||||
|
@@ -57,7 +57,7 @@ class XCPVNCProxy(object):
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
d = source.recv(32384)
|
d = source.recv(32384)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
d = None
|
d = None
|
||||||
|
|
||||||
# If recv fails, send a write shutdown the other direction
|
# If recv fails, send a write shutdown the other direction
|
||||||
@@ -68,7 +68,7 @@ class XCPVNCProxy(object):
|
|||||||
try:
|
try:
|
||||||
# sendall raises an exception on write error, unlike send
|
# sendall raises an exception on write error, unlike send
|
||||||
dest.sendall(d)
|
dest.sendall(d)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
source.close()
|
source.close()
|
||||||
dest.close()
|
dest.close()
|
||||||
break
|
break
|
||||||
@@ -102,7 +102,6 @@ class XCPVNCProxy(object):
|
|||||||
|
|
||||||
client = req.environ['eventlet.input'].get_socket()
|
client = req.environ['eventlet.input'].get_socket()
|
||||||
client.sendall("HTTP/1.1 200 OK\r\n\r\n")
|
client.sendall("HTTP/1.1 200 OK\r\n\r\n")
|
||||||
socketsserver = None
|
|
||||||
sockets['client'] = client
|
sockets['client'] = client
|
||||||
sockets['server'] = server
|
sockets['server'] = server
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ class SmokeTestCase(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
conn = self.connect_ssh(ip, key_name)
|
conn = self.connect_ssh(ip, key_name)
|
||||||
conn.close()
|
conn.close()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
time.sleep(wait)
|
time.sleep(wait)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
@@ -96,7 +96,7 @@ class InstanceTestsFromPublic(base.UserSmokeTestCase):
|
|||||||
conn = self.connect_ssh(
|
conn = self.connect_ssh(
|
||||||
self.data['ip_v6'], TEST_KEY)
|
self.data['ip_v6'], TEST_KEY)
|
||||||
conn.close()
|
conn.close()
|
||||||
except Exception as ex:
|
except Exception:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
@@ -161,7 +161,6 @@ class InstanceTests(base.UserSmokeTestCase):
|
|||||||
self.data['instance'] = reservation.instances[0]
|
self.data['instance'] = reservation.instances[0]
|
||||||
|
|
||||||
def test_003_instance_runs_within_60_seconds(self):
|
def test_003_instance_runs_within_60_seconds(self):
|
||||||
instance = self.data['instance']
|
|
||||||
# allow 60 seconds to exit pending with IP
|
# allow 60 seconds to exit pending with IP
|
||||||
if not self.wait_for_running(self.data['instance']):
|
if not self.wait_for_running(self.data['instance']):
|
||||||
self.fail('instance failed to start')
|
self.fail('instance failed to start')
|
||||||
|
Reference in New Issue
Block a user