Remove more unused variables
authorIustin Pop <iustin@google.com>
Tue, 29 Dec 2009 15:03:44 +0000 (16:03 +0100)
committerIustin Pop <iustin@google.com>
Mon, 4 Jan 2010 09:15:49 +0000 (10:15 +0100)
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
daemons/ganeti-watcher
scripts/gnt-backup
scripts/gnt-cluster
scripts/gnt-instance
scripts/gnt-job
scripts/gnt-node
scripts/gnt-os
tools/cfgshell
tools/lvmstrap

index 96d5c7a..48816c1 100755 (executable)
@@ -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))
 
index 71b548f..d82b8ba 100755 (executable)
@@ -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)
index 4d65648..2890ecb 100755 (executable)
@@ -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)
index 59f1b30..fc97894 100755 (executable)
@@ -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
index 4fc8c8e..ec08c0d 100755 (executable)
@@ -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:
index cd4612b..f377478 100755 (executable)
@@ -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?
index 26cfd7e..b639b58 100755 (executable)
@@ -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
index ed8d27f..40bea55 100755 (executable)
@@ -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 = {}
index acdf9fb..b3d5968 100755 (executable)
@@ -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:
index bd867d0..01ad670 100755 (executable)
@@ -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))