From 65fe4693f9adb432f8368b0aab9acbac738f6a23 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 5 Nov 2007 15:06:24 +0000
Subject: [PATCH] Miscellaneous style fixes

This patch fixes some minor pylint warnings (unused variables, wrong
indentation, etc.) and a real bug in the recovery for drbd8 rename
procedure.

Reviewed-by: imsnah
---
 lib/backend.py | 17 +++++++++--------
 lib/bdev.py    |  2 +-
 lib/cli.py     |  6 ++++++
 lib/cmdlib.py  |  2 --
 lib/utils.py   |  4 ++--
 5 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index bb5bfe048..4415223d2 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -942,10 +942,10 @@ def _OSSearch(name, search_path=None):
   if search_path is None:
     search_path = constants.OS_SEARCH_PATH
 
-  for dir in search_path:
-    t_os_dir = os.path.sep.join([dir, name])
+  for dir_name in search_path:
+    t_os_dir = os.path.sep.join([dir_name, name])
     if os.path.isdir(t_os_dir):
-        return dir
+      return dir_name
 
   return None
 
@@ -1006,16 +1006,17 @@ def DiagnoseOS(top_dirs=None):
     top_dirs = constants.OS_SEARCH_PATH
 
   result = []
-  for dir in top_dirs:
-    if os.path.isdir(dir):
+  for dir_name in top_dirs:
+    if os.path.isdir(dir_name):
       try:
-        f_names = utils.ListVisibleFiles(dir)
+        f_names = utils.ListVisibleFiles(dir_name)
       except EnvironmentError, err:
-        logger.Error("Can't list the OS directory %s: %s" % (dir,str(err)))
+        logger.Error("Can't list the OS directory %s: %s" %
+                     (dir_name, str(err)))
         break
       for name in f_names:
         try:
-          os_inst = OSFromDisk(name, base_dir=dir)
+          os_inst = OSFromDisk(name, base_dir=dir_name)
           result.append(os_inst)
         except errors.InvalidOS, err:
           result.append(objects.OS.FromInvalidOS(err))
diff --git a/lib/bdev.py b/lib/bdev.py
index a2d7e4f30..bfa333b7b 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -2146,7 +2146,7 @@ class DRBD8(BaseDRBD):
     self.unique_id = new_uid
     if not self._AssembleNet(self.minor, self.unique_id, "C"):
       logger.Error("Can't attach to new peer!")
-      if self.old_id is not None:
+      if old_id is not None:
         self._AssembleNet(self.minor, old_id, "C")
       self.unique_id = old_id
       raise errors.BlockDeviceError("Can't attach to new peer")
diff --git a/lib/cli.py b/lib/cli.py
index 780e002e4..2f3dbf721 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -195,6 +195,9 @@ ARGS_ANY = ARGS_ATLEAST(0)
 
 
 def check_unit(option, opt, value):
+  """OptParsers custom converter for units.
+
+  """
   try:
     return utils.ParseUnit(value)
   except errors.UnitParseError, err:
@@ -202,6 +205,9 @@ def check_unit(option, opt, value):
 
 
 class CliOption(Option):
+  """Custom option class for optparse.
+
+  """
   TYPES = Option.TYPES + ("unit",)
   TYPE_CHECKER = copy.copy(Option.TYPE_CHECKER)
   TYPE_CHECKER["unit"] = check_unit
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index cb403383e..6bd0ed03e 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -26,7 +26,6 @@
 import os
 import os.path
 import sha
-import socket
 import time
 import tempfile
 import re
@@ -856,7 +855,6 @@ class LUVerifyCluster(NoHooksLU):
     feedback_fn("* Verifying global settings")
     self.cfg.VerifyConfig()
 
-    master = self.sstore.GetMasterNode()
     vg_name = self.cfg.GetVGName()
     nodelist = utils.NiceSort(self.cfg.GetNodeList())
     instancelist = utils.NiceSort(self.cfg.GetInstanceList())
diff --git a/lib/utils.py b/lib/utils.py
index f22537917..56c0bf338 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -752,11 +752,11 @@ def CreateBackup(file_name):
                                 file_name)
 
   prefix = '%s.backup-%d.' % (os.path.basename(file_name), int(time.time()))
-  dir = os.path.dirname(file_name)
+  dir_name = os.path.dirname(file_name)
 
   fsrc = open(file_name, 'rb')
   try:
-    (fd, backup_name) = tempfile.mkstemp(prefix=prefix, dir=dir)
+    (fd, backup_name) = tempfile.mkstemp(prefix=prefix, dir=dir_name)
     fdst = os.fdopen(fd, 'wb')
     try:
       shutil.copyfileobj(fsrc, fdst)
-- 
GitLab