From f4ad2ef0db3eeeffd60598d855523ba357f5f5c7 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 29 Dec 2009 16:03:44 +0100
Subject: [PATCH] Remove more unused variables

This removes unused variables in the rest of the code (outside lib/).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>
---
 daemons/ganeti-rapi    |  2 +-
 daemons/ganeti-watcher |  2 +-
 scripts/gnt-backup     |  2 --
 scripts/gnt-cluster    |  2 +-
 scripts/gnt-instance   |  1 -
 scripts/gnt-job        |  2 +-
 scripts/gnt-node       |  2 --
 scripts/gnt-os         |  2 +-
 tools/cfgshell         | 10 +++++-----
 tools/lvmstrap         | 12 ++++++------
 10 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/daemons/ganeti-rapi b/daemons/ganeti-rapi
index 96d5c7a16..48816c10e 100755
--- a/daemons/ganeti-rapi
+++ b/daemons/ganeti-rapi
@@ -110,7 +110,7 @@ class RemoteApiHttpServer(http.auth.HttpServerRequestAuthentication,
       method = req.request_method.upper()
       try:
         ctx.handler_fn = getattr(ctx.handler, method)
-      except AttributeError, err:
+      except AttributeError:
         raise http.HttpBadRequest("Method %s is unsupported for path %s" %
                                   (method, req.request_path))
 
diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher
index 71b548f2e..d82b8ba00 100755
--- a/daemons/ganeti-watcher
+++ b/daemons/ganeti-watcher
@@ -470,7 +470,7 @@ def main():
   """
   global client # pylint: disable-msg=W0603
 
-  options, args = ParseOptions()
+  options, _ = ParseOptions()
 
   utils.SetupLogging(constants.LOG_WATCHER, debug=options.debug,
                      stderr_logging=options.debug)
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index 4d65648b5..2890ecb11 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -81,7 +81,6 @@ def ExportInstance(opts, args):
   if not isinstance(dlist, list):
     ToStderr("Cannot parse execution results")
     return 1
-  tot_dsk = len(dlist)
   # TODO: handle diskless instances
   if dlist.count(False) == 0:
     # all OK
@@ -119,7 +118,6 @@ def RemoveExport(opts, args):
   @return: the desired exit code
 
   """
-  instance = args[0]
   op = opcodes.OpRemoveExport(instance_name=args[0])
 
   SubmitOpCode(op)
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index 59f1b3092..fc978948e 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -512,7 +512,7 @@ def SetClusterParams(opts, args):
 
   # a list of (name, dict) we can pass directly to dict() (or [])
   hvparams = dict(opts.hvparams)
-  for hv, hv_params in hvparams.iteritems():
+  for hv_params in hvparams.values():
     utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
 
   beparams = opts.beparams
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 4fc8c8ef4..ec08c0d04 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -756,7 +756,6 @@ def ReplaceDisks(opts, args):
   @return: the desired exit code
 
   """
-  instance_name = args[0]
   new_2ndary = opts.dst_node
   iallocator = opts.iallocator
   if opts.disks is None:
diff --git a/scripts/gnt-job b/scripts/gnt-job
index cd4612b5e..f377478cb 100755
--- a/scripts/gnt-job
+++ b/scripts/gnt-job
@@ -181,7 +181,7 @@ def CancelJobs(opts, args):
   client = GetClient()
 
   for job_id in args:
-    (success, msg) = client.CancelJob(job_id)
+    (_, msg) = client.CancelJob(job_id)
     ToStdout(msg)
 
   # TODO: Different exit value if not all jobs were canceled?
diff --git a/scripts/gnt-node b/scripts/gnt-node
index 26cfd7e51..b639b58ac 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -356,8 +356,6 @@ def MigrateNode(opts, args):
 
   pinst = utils.NiceSort(pinst)
 
-  retcode = 0
-
   if not force and not AskUser("Migrate instance(s) %s?" %
                                (",".join("'%s'" % name for name in pinst))):
     return 2
diff --git a/scripts/gnt-os b/scripts/gnt-os
index ed8d27f60..40bea5516 100755
--- a/scripts/gnt-os
+++ b/scripts/gnt-os
@@ -106,7 +106,7 @@ def DiagnoseOS(opts, args):
 
   has_bad = False
 
-  for os_name, os_valid, os_variants, node_data in result:
+  for os_name, _, os_variants, node_data in result:
     nodes_valid = {}
     nodes_bad = {}
     nodes_hidden = {}
diff --git a/tools/cfgshell b/tools/cfgshell
index acdf9fb5a..b3d59689d 100755
--- a/tools/cfgshell
+++ b/tools/cfgshell
@@ -177,7 +177,7 @@ class ConfigShell(cmd.Cmd):
 
     """
     pointer = self.parents[-1]
-    dirs, entries = self._get_entries(pointer)
+    dirs, _ = self._get_entries(pointer)
     matches = [str(name) for name in dirs if name.startswith(text)]
     return matches
 
@@ -202,7 +202,7 @@ class ConfigShell(cmd.Cmd):
       return False
 
     pointer = self.parents[-1]
-    dirs, entries = self._get_entries(pointer)
+    dirs, _ = self._get_entries(pointer)
 
     if line not in dirs:
       print "No such child"
@@ -232,7 +232,7 @@ class ConfigShell(cmd.Cmd):
 
     """
     pointer = self.parents[-1]
-    dirs, entries = self._get_entries(pointer)
+    _, entries = self._get_entries(pointer)
     matches = [name for name in entries if name.startswith(text)]
     return matches
 
@@ -244,7 +244,7 @@ class ConfigShell(cmd.Cmd):
 
     """
     pointer = self.parents[-1]
-    dirs, entries = self._get_entries(pointer)
+    _, entries = self._get_entries(pointer)
     if line not in entries:
       print "No such entry"
       return False
@@ -351,7 +351,7 @@ def main():
 
   This is just a wrapper over BootStrap, to handle our own exceptions.
   """
-  options, args = ParseOptions()
+  _, args = ParseOptions()
   if args:
     cfg_file = args[0]
   else:
diff --git a/tools/lvmstrap b/tools/lvmstrap
index bd867d027..01ad670c5 100755
--- a/tools/lvmstrap
+++ b/tools/lvmstrap
@@ -192,7 +192,7 @@ def CheckPrereq():
   if os.getuid() != 0:
     raise PrereqError("This tool runs as root only. Really.")
 
-  osname, nodename, release, version, arch = os.uname()
+  osname, _, release, _, _ = os.uname()
   if osname != 'Linux':
     raise PrereqError("This tool only runs on Linux"
                       " (detected OS: %s)." % osname)
@@ -271,7 +271,7 @@ def CheckSysDev(name, devnum):
   """
 
   path = "/dev/%s" % name
-  for retries in range(40):
+  for _ in range(40):
     if os.path.exists(path):
       break
     time.sleep(0.250)
@@ -426,7 +426,7 @@ def GetMountInfo():
   mountlines = ReadFile("/proc/mounts").splitlines()
   mounts = {}
   for line in mountlines:
-    device, mountpoint, fstype, rest = line.split(None, 3)
+    _, mountpoint, fstype, _ = line.split(None, 3)
     # fs type blacklist
     if fstype in ["nfs", "nfs4", "autofs", "tmpfs", "proc", "sysfs"]:
       continue
@@ -542,7 +542,7 @@ def CheckReread(name):
     boolean, the in-use status of the device
   """
 
-  for retries in range(3):
+  for _ in range(3):
     result = ExecCommand("blockdev --rereadpt /dev/%s" % name)
     if not result.failed:
       break
@@ -672,7 +672,7 @@ def ValidateDiskList(options):
                       " non-removable block devices).")
   sysd_free = []
   sysd_used = []
-  for name, size, dev, part, used in sysdisks:
+  for name, _, _, _, used in sysdisks:
     if used:
       sysd_used.append(name)
     else:
@@ -726,7 +726,7 @@ def BootStrap():
     CreatePVOnDisk(disk)
   CreateVG(vgname, disklist)
 
-  status, lv_count, size, free = CheckVGExists(vgname)
+  status, lv_count, size, _ = CheckVGExists(vgname)
   if status:
     print "Done! %s: size %s GiB, disks: %s" % (vgname, size,
                                               ",".join(disklist))
-- 
GitLab