Commit 1122eb25 authored by Iustin Pop's avatar Iustin Pop
Browse files

Remove many 'Unused variable' warnings



Note there are some cases left which need extra cleanup.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarOlivier Tharan <olive@google.com>
parent 07b8a2b5
...@@ -1516,7 +1516,7 @@ def BlockdevGetsize(disks): ...@@ -1516,7 +1516,7 @@ def BlockdevGetsize(disks):
for cf in disks: for cf in disks:
try: try:
rbd = _RecursiveFindBD(cf) rbd = _RecursiveFindBD(cf)
except errors.BlockDeviceError, err: except errors.BlockDeviceError:
result.append(None) result.append(None)
continue continue
if rbd is None: if rbd is None:
......
...@@ -79,7 +79,7 @@ def _CanReadDevice(path): ...@@ -79,7 +79,7 @@ def _CanReadDevice(path):
try: try:
utils.ReadFile(path, size=_DEVICE_READ_SIZE) utils.ReadFile(path, size=_DEVICE_READ_SIZE)
return True return True
except EnvironmentError, err: except EnvironmentError:
logging.warning("Can't read from device %s", path, exc_info=True) logging.warning("Can't read from device %s", path, exc_info=True)
return False return False
...@@ -623,7 +623,7 @@ class LogicalVolume(BlockDev): ...@@ -623,7 +623,7 @@ class LogicalVolume(BlockDev):
_ThrowError("Can't compute PV info for vg %s", self._vg_name) _ThrowError("Can't compute PV info for vg %s", self._vg_name)
pvs_info.sort() pvs_info.sort()
pvs_info.reverse() pvs_info.reverse()
free_size, pv_name, _ = pvs_info[0] free_size, _, _ = pvs_info[0]
if free_size < size: if free_size < size:
_ThrowError("Not enough free space: required %s," _ThrowError("Not enough free space: required %s,"
" available %s", size, free_size) " available %s", size, free_size)
......
...@@ -1163,7 +1163,7 @@ class LUVerifyCluster(LogicalUnit): ...@@ -1163,7 +1163,7 @@ class LUVerifyCluster(LogicalUnit):
# check that ':' is not present in PV names, since it's a # check that ':' is not present in PV names, since it's a
# special character for lvcreate (denotes the range of PEs to # special character for lvcreate (denotes the range of PEs to
# use on the PV) # use on the PV)
for size, pvname, owner_vg in pvlist: for _, pvname, owner_vg in pvlist:
test = ":" in pvname test = ":" in pvname
_ErrorIf(test, self.ENODELVM, node, "Invalid character ':' in PV" _ErrorIf(test, self.ENODELVM, node, "Invalid character ':' in PV"
" '%s' of VG '%s'", pvname, owner_vg) " '%s' of VG '%s'", pvname, owner_vg)
...@@ -1594,7 +1594,6 @@ class LUVerifyCluster(LogicalUnit): ...@@ -1594,7 +1594,6 @@ class LUVerifyCluster(LogicalUnit):
assert hooks_results, "invalid result from hooks" assert hooks_results, "invalid result from hooks"
for node_name in hooks_results: for node_name in hooks_results:
show_node_header = True
res = hooks_results[node_name] res = hooks_results[node_name]
msg = res.fail_msg msg = res.fail_msg
test = msg and not res.offline test = msg and not res.offline
...@@ -1684,7 +1683,7 @@ class LUVerifyDisks(NoHooksLU): ...@@ -1684,7 +1683,7 @@ class LUVerifyDisks(NoHooksLU):
continue continue
lvs = node_res.payload lvs = node_res.payload
for lv_name, (_, lv_inactive, lv_online) in lvs.items(): for lv_name, (_, _, lv_online) in lvs.items():
inst = nv_dict.pop((node, lv_name), None) inst = nv_dict.pop((node, lv_name), None)
if (not lv_online and inst is not None if (not lv_online and inst is not None
and inst.name not in res_instances): and inst.name not in res_instances):
...@@ -2475,7 +2474,7 @@ class LURemoveNode(LogicalUnit): ...@@ -2475,7 +2474,7 @@ class LURemoveNode(LogicalUnit):
# Run post hooks on the node before it's removed # Run post hooks on the node before it's removed
hm = self.proc.hmclass(self.rpc.call_hooks_runner, self) hm = self.proc.hmclass(self.rpc.call_hooks_runner, self)
try: try:
h_results = hm.RunPhase(constants.HOOKS_PHASE_POST, [node.name]) hm.RunPhase(constants.HOOKS_PHASE_POST, [node.name])
except: except:
self.LogWarning("Errors occurred running hooks on %s" % node.name) self.LogWarning("Errors occurred running hooks on %s" % node.name)
...@@ -2592,7 +2591,7 @@ class LUQueryNodes(NoHooksLU): ...@@ -2592,7 +2591,7 @@ class LUQueryNodes(NoHooksLU):
if inst_fields & frozenset(self.op.output_fields): if inst_fields & frozenset(self.op.output_fields):
inst_data = self.cfg.GetAllInstancesInfo() inst_data = self.cfg.GetAllInstancesInfo()
for instance_name, inst in inst_data.items(): for inst in inst_data.values():
if inst.primary_node in node_to_primary: if inst.primary_node in node_to_primary:
node_to_primary[inst.primary_node].add(inst.name) node_to_primary[inst.primary_node].add(inst.name)
for secnode in inst.secondary_nodes: for secnode in inst.secondary_nodes:
...@@ -4067,7 +4066,7 @@ class LURecreateInstanceDisks(LogicalUnit): ...@@ -4067,7 +4066,7 @@ class LURecreateInstanceDisks(LogicalUnit):
""" """
to_skip = [] to_skip = []
for idx, disk in enumerate(self.instance.disks): for idx, _ in enumerate(self.instance.disks):
if idx not in self.op.disks: # disk idx has not been passed in if idx not in self.op.disks: # disk idx has not been passed in
to_skip.append(idx) to_skip.append(idx)
continue continue
...@@ -6795,7 +6794,7 @@ class TLReplaceDisks(Tasklet): ...@@ -6795,7 +6794,7 @@ class TLReplaceDisks(Tasklet):
return iv_names return iv_names
def _CheckDevices(self, node_name, iv_names): def _CheckDevices(self, node_name, iv_names):
for name, (dev, old_lvs, new_lvs) in iv_names.iteritems(): for name, (dev, _, _) in iv_names.iteritems():
self.cfg.SetDiskID(dev, node_name) self.cfg.SetDiskID(dev, node_name)
result = self.rpc.call_blockdev_find(node_name, dev) result = self.rpc.call_blockdev_find(node_name, dev)
...@@ -6811,7 +6810,7 @@ class TLReplaceDisks(Tasklet): ...@@ -6811,7 +6810,7 @@ class TLReplaceDisks(Tasklet):
raise errors.OpExecError("DRBD device %s is degraded!" % name) raise errors.OpExecError("DRBD device %s is degraded!" % name)
def _RemoveOldStorage(self, node_name, iv_names): def _RemoveOldStorage(self, node_name, iv_names):
for name, (dev, old_lvs, _) in iv_names.iteritems(): for name, (_, old_lvs, _) in iv_names.iteritems():
self.lu.LogInfo("Remove logical volumes for %s" % name) self.lu.LogInfo("Remove logical volumes for %s" % name)
for lv in old_lvs: for lv in old_lvs:
...@@ -7006,6 +7005,7 @@ class TLReplaceDisks(Tasklet): ...@@ -7006,6 +7005,7 @@ class TLReplaceDisks(Tasklet):
if self.instance.primary_node == o_node1: if self.instance.primary_node == o_node1:
p_minor = o_minor1 p_minor = o_minor1
else: else:
assert self.instance.primary_node == o_node2, "Three-node instance?"
p_minor = o_minor2 p_minor = o_minor2
new_alone_id = (self.instance.primary_node, self.new_node, None, new_alone_id = (self.instance.primary_node, self.new_node, None,
...@@ -7809,7 +7809,7 @@ class LUSetInstanceParams(LogicalUnit): ...@@ -7809,7 +7809,7 @@ class LUSetInstanceParams(LogicalUnit):
raise errors.OpPrereqError("Disk operations not supported for" raise errors.OpPrereqError("Disk operations not supported for"
" diskless instances", " diskless instances",
errors.ECODE_INVAL) errors.ECODE_INVAL)
for disk_op, disk_dict in self.op.disks: for disk_op, _ in self.op.disks:
if disk_op == constants.DDM_REMOVE: if disk_op == constants.DDM_REMOVE:
if len(instance.disks) == 1: if len(instance.disks) == 1:
raise errors.OpPrereqError("Cannot remove the last disk of" raise errors.OpPrereqError("Cannot remove the last disk of"
...@@ -7853,7 +7853,6 @@ class LUSetInstanceParams(LogicalUnit): ...@@ -7853,7 +7853,6 @@ class LUSetInstanceParams(LogicalUnit):
result = [] result = []
instance = self.instance instance = self.instance
cluster = self.cluster
# disk changes # disk changes
for disk_op, disk_dict in self.op.disks: for disk_op, disk_dict in self.op.disks:
if disk_op == constants.DDM_REMOVE: if disk_op == constants.DDM_REMOVE:
......
...@@ -187,7 +187,6 @@ class InstanceIpToNodePrimaryIpQuery(ConfdQuery): ...@@ -187,7 +187,6 @@ class InstanceIpToNodePrimaryIpQuery(ConfdQuery):
instances_list = query[constants.CONFD_REQQ_IPLIST] instances_list = query[constants.CONFD_REQQ_IPLIST]
mode = constants.CONFD_REQQ_IPLIST mode = constants.CONFD_REQQ_IPLIST
else: else:
status = constants.CONFD_REPL_STATUS_ERROR
logging.debug("missing IP or IPLIST in query dict") logging.debug("missing IP or IPLIST in query dict")
return QUERY_ARGUMENT_ERROR return QUERY_ARGUMENT_ERROR
......
...@@ -424,7 +424,7 @@ class ConfigWriter: ...@@ -424,7 +424,7 @@ class ConfigWriter:
node.offline)) node.offline))
# drbd minors check # drbd minors check
d_map, duplicates = self._UnlockedComputeDRBDMap() _, duplicates = self._UnlockedComputeDRBDMap()
for node, minor, instance_a, instance_b in duplicates: for node, minor, instance_a, instance_b in duplicates:
result.append("DRBD minor %d on node %s is assigned twice to instances" result.append("DRBD minor %d on node %s is assigned twice to instances"
" %s and %s" % (minor, node, instance_a, instance_b)) " %s and %s" % (minor, node, instance_a, instance_b))
......
...@@ -340,7 +340,7 @@ def WaitForSocketCondition(sock, event, timeout): ...@@ -340,7 +340,7 @@ def WaitForSocketCondition(sock, event, timeout):
if not io_events: if not io_events:
# Timeout # Timeout
return None return None
for (evfd, evcond) in io_events: for (_, evcond) in io_events:
if evcond & check: if evcond & check:
return evcond return evcond
finally: finally:
......
...@@ -504,7 +504,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher): ...@@ -504,7 +504,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
for child in self._children: for child in self._children:
try: try:
pid, status = os.waitpid(child, os.WNOHANG) pid, _ = os.waitpid(child, os.WNOHANG)
except os.error: except os.error:
pid = None pid = None
if pid and pid in self._children: if pid and pid in self._children:
......
...@@ -97,7 +97,7 @@ class ChrootManager(hv_base.BaseHypervisor): ...@@ -97,7 +97,7 @@ class ChrootManager(hv_base.BaseHypervisor):
fh = open("/proc/mounts", "r") fh = open("/proc/mounts", "r")
try: try:
for line in fh: for line in fh:
fstype, mountpoint, rest = line.split(" ", 2) _, mountpoint, _ = line.split(" ", 2)
if (mountpoint.startswith(path) and if (mountpoint.startswith(path) and
mountpoint != path): mountpoint != path):
data.append(mountpoint) data.append(mountpoint)
......
...@@ -240,7 +240,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -240,7 +240,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
@return: tuple (name, id, memory, vcpus, stat, times) @return: tuple (name, id, memory, vcpus, stat, times)
""" """
pidfile, pid, alive = self._InstancePidAlive(instance_name) _, pid, alive = self._InstancePidAlive(instance_name)
if not alive: if not alive:
return None return None
...@@ -278,7 +278,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -278,7 +278,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
if utils.IsProcessAlive(utils.ReadPidFile(filename)): if utils.IsProcessAlive(utils.ReadPidFile(filename)):
try: try:
info = self.GetInstanceInfo(name) info = self.GetInstanceInfo(name)
except errors.HypervisorError, err: except errors.HypervisorError:
continue continue
if info: if info:
data.append(info) data.append(info)
...@@ -470,7 +470,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -470,7 +470,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
@param incoming: (target_host_ip, port) @param incoming: (target_host_ip, port)
""" """
pidfile, pid, alive = self._InstancePidAlive(instance.name) pidfile, _, alive = self._InstancePidAlive(instance.name)
hvp = instance.hvparams hvp = instance.hvparams
if alive: if alive:
raise errors.HypervisorError("Failed to start instance %s: %s" % raise errors.HypervisorError("Failed to start instance %s: %s" %
...@@ -581,7 +581,7 @@ class KVMHypervisor(hv_base.BaseHypervisor): ...@@ -581,7 +581,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
# For some reason if we do a 'send-key ctrl-alt-delete' to the control # For some reason if we do a 'send-key ctrl-alt-delete' to the control
# socket the instance will stop, but now power up again. So we'll resort # socket the instance will stop, but now power up again. So we'll resort
# to shutdown and restart. # to shutdown and restart.
pidfile, pid, alive = self._InstancePidAlive(instance.name) _, _, alive = self._InstancePidAlive(instance.name)
if not alive: if not alive:
raise errors.HypervisorError("Failed to reboot instance %s:" raise errors.HypervisorError("Failed to reboot instance %s:"
" not running" % instance.name) " not running" % instance.name)
......
...@@ -50,7 +50,6 @@ def _CalculateLockAttemptTimeouts(): ...@@ -50,7 +50,6 @@ def _CalculateLockAttemptTimeouts():
"""Calculate timeouts for lock attempts. """Calculate timeouts for lock attempts.
""" """
running_sum = 0
result = [1.0] result = [1.0]
# Wait for a total of at least 150s before doing a blocking acquire # Wait for a total of at least 150s before doing a blocking acquire
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment