Commit 65fe4693 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent d74c2ca1
......@@ -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))
......
......@@ -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")
......
......@@ -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
......
......@@ -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())
......
......@@ -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)
......
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