This patch should have only:
- pylint disables
- docstring changes
- whitespace changes
---
daemons/ganeti-confd | 6 ++++++
daemons/ganeti-masterd | 21 +++++++++++++++------
daemons/ganeti-noded | 13 +++++++++----
daemons/ganeti-rapi | 7 ++++++-
daemons/ganeti-watcher | 12 ++++++++----
lib/asyncnotifier.py | 3 ++-
lib/backend.py | 4 +++-
lib/build/__init__.py | 1 +
lib/cli.py | 3 ++-
lib/cmdlib.py | 20 +++++++++++++++-----
lib/confd/querylib.py | 2 +-
lib/daemon.py | 4 ++--
lib/http/__init__.py | 2 +-
lib/http/client.py | 2 +-
lib/http/server.py | 3 ++-
lib/hypervisor/hv_base.py | 2 +-
lib/jqueue.py | 6 ++++--
lib/locking.py | 6 +++---
lib/luxi.py | 2 +-
lib/mcpu.py | 2 +-
lib/objects.py | 5 +++--
lib/rapi/__init__.py | 1 +
lib/rapi/rlib2.py | 3 +++
lib/rpc.py | 2 +-
lib/storage.py | 18 +++++++++++++-----
lib/utils.py | 10 +++++++---
lib/workerpool.py | 5 +++--
scripts/gnt-backup | 4 +++-
scripts/gnt-cluster | 4 +++-
scripts/gnt-debug | 5 ++++-
scripts/gnt-instance | 9 ++++++---
scripts/gnt-job | 4 +++-
scripts/gnt-node | 4 +++-
scripts/gnt-os | 4 +++-
tools/burnin | 15 ++++++++-------
tools/cfgshell | 6 +++---
tools/cfgupgrade | 2 +-
tools/lvmstrap | 2 +-
38 files changed, 153 insertions(+), 71 deletions(-)
diff --git a/daemons/ganeti-confd b/daemons/ganeti-confd
index 421e73c..de12700 100755
--- a/daemons/ganeti-confd
+++ b/daemons/ganeti-confd
@@ -26,12 +26,16 @@ It uses UDP+HMAC for authentication with a global cluster
key.
"""
+# pylint: disable-msg=C0103
+# C0103: Invalid name ganeti-confd
+
import os
import sys
import logging
import time
try:
+ # pylint: disable-msg=E0611
from pyinotify import pyinotify
except ImportError:
import pyinotify
@@ -102,6 +106,8 @@ class ConfdInotifyEventHandler(pyinotify.ProcessEvent):
# no need to call the parent's constructor
self.watch_manager = watch_manager
self.callback = callback
+ # pylint: disable-msg=E1103
+ # pylint for some reason doesn't see the below constants
self.mask = pyinotify.EventsCodes.IN_IGNORED | \
pyinotify.EventsCodes.IN_MODIFY
self.file = filename
diff --git a/daemons/ganeti-masterd b/daemons/ganeti-masterd
index 3a77be4..2951410 100755
--- a/daemons/ganeti-masterd
+++ b/daemons/ganeti-masterd
@@ -26,6 +26,8 @@ inheritance from parent classes requires it.
"""
+# pylint: disable-msg=C0103
+# C0103: Invalid name ganeti-masterd
import os
import sys
@@ -61,6 +63,7 @@ EXIT_NODESETUP_ERROR = constants.EXIT_NODESETUP_ERROR
class ClientRequestWorker(workerpool.BaseWorker):
+ # pylint: disable-msg=W0221
def RunTask(self, server, request, client_address):
"""Process the request.
@@ -70,7 +73,7 @@ class ClientRequestWorker(workerpool.BaseWorker):
try:
server.finish_request(request, client_address)
server.close_request(request)
- except:
+ except: # pylint: disable-msg=W0702
server.handle_error(request, client_address)
server.close_request(request)
@@ -108,7 +111,7 @@ class IOServer(SocketServer.UnixStreamServer):
self.request_workers.AddTask(self, request, client_address)
@utils.SignalHandled([signal.SIGINT, signal.SIGTERM])
- def serve_forever(self, signal_handlers=None):
+ def serve_forever(self, signal_handlers=None): # pylint: disable-msg=W0221
"""Handle one request at a time until told to quit."""
assert isinstance(signal_handlers, dict) and \
len(signal_handlers) > 0, \
@@ -141,6 +144,8 @@ class ClientRqHandler(SocketServer.BaseRequestHandler):
READ_SIZE = 4096
def setup(self):
+ # pylint: disable-msg=W0201
+ # setup() is the api for initialising for this class
self._buffer = ""
self._msgs = collections.deque()
self._ops = ClientOps(self.server)
@@ -204,11 +209,13 @@ class ClientOps:
def __init__(self, server):
self.server = server
- def handle_request(self, method, args):
+ def handle_request(self, method, args): # pylint: disable-msg=R0911
queue = self.server.context.jobqueue
# TODO: Parameter validation
+ # TODO: Rewrite to not exit in each 'if/elif' branch
+
if method == luxi.REQ_SUBMIT_JOB:
logging.info("Received new job")
ops = [opcodes.OpCode.LoadOpCode(state) for state in args]
@@ -333,6 +340,8 @@ class GanetiContext(object):
This class creates and holds common objects shared by all threads.
"""
+ # pylint: disable-msg=W0212
+ # we do want to ensure a singleton here
_instance = None
def __init__(self):
@@ -498,12 +507,12 @@ def _RunInSeparateProcess(fn):
# Call function
result = int(bool(fn()))
assert result in (0, 1)
- except:
+ except: # pylint: disable-msg=W0702
logging.exception("Error while calling function in separate process")
# 0 and 1 are reserved for the return value
result = 33
- os._exit(result)
+ os._exit(result) # pylint: disable-msg=W0212
# Parent process
@@ -544,7 +553,7 @@ def CheckMasterd(options, args):
confirmation = sys.stdin.readline().strip()
if confirmation != "YES":
- print >>sys.stderr, "Aborting."
+ print >> sys.stderr, "Aborting."
sys.exit(constants.EXIT_FAILURE)
return
diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index 0486dd1..4e24224 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -21,8 +21,13 @@
"""Ganeti node daemon"""
-# functions in this module need to have a given name structure, so:
-# pylint: disable-msg=C0103
+# pylint: disable-msg=C0103,W0142
+
+# C0103: Functions in this module need to have a given name structure,
+# and the name of the daemon doesn't match
+
+# W0142: Used * or ** magic, since we do use it extensively in this
+# module
import os
import sys
@@ -66,7 +71,7 @@ def _RequireJobQueueLock(fn):
return wrapper
-class NodeHttpServer(http.server.HttpServer):
+class NodeHttpServer(http.server.HttpServer): # pylint: disable-msg=R0904
"""The server implementation.
This class holds all methods exposed over the RPC interface.
@@ -786,7 +791,7 @@ def ExecNoded(options, args):
"""Main node daemon function, executed with the PID file held.
"""
- global queue_lock
+ global queue_lock # pylint: disable-msg=W0603
# Read SSL certificate
if options.ssl:
diff --git a/daemons/ganeti-rapi b/daemons/ganeti-rapi
index 5928537..96d5c7a 100755
--- a/daemons/ganeti-rapi
+++ b/daemons/ganeti-rapi
@@ -18,9 +18,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-""" Ganeti Remote API master script.
+"""Ganeti Remote API master script.
+
"""
+# pylint: disable-msg=C0103,W0142
+
+# C0103: Invalid name ganeti-watcher
+
import glob
import logging
import optparse
diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher
index a603802..71b548f 100755
--- a/daemons/ganeti-watcher
+++ b/daemons/ganeti-watcher
@@ -27,6 +27,10 @@ by a node reboot. Run from cron or similar.
"""
+# pylint: disable-msg=C0103,W0142
+
+# C0103: Invalid name ganeti-watcher
+
import os
import sys
import time
@@ -115,7 +119,7 @@ class WatcherState(object):
self._data = {}
else:
self._data = serializer.Load(state_data)
- except Exception, msg:
+ except Exception, msg: # pylint: disable-msg=W0703
# Ignore errors while loading the file and treat it as empty
self._data = {}
logging.warning(("Invalid state file. Using defaults."
@@ -369,7 +373,7 @@ class Watcher(object):
try:
logging.info("Activating disks for instance %s", instance.name)
instance.ActivateDisks()
- except Exception:
+ except Exception: # pylint: disable-msg=W0703
logging.exception("Error while activating disks for instance %s",
instance.name)
@@ -400,7 +404,7 @@ class Watcher(object):
instance.name, last)
instance.Restart()
self.started_instances.add(instance.name)
- except Exception:
+ except Exception: # pylint: disable-msg=W0703
logging.exception("Error while restarting instance %s",
instance.name)
@@ -464,7 +468,7 @@ def main():
"""Main function.
"""
- global client
+ global client # pylint: disable-msg=W0603
options, args = ParseOptions()
diff --git a/lib/asyncnotifier.py b/lib/asyncnotifier.py
index 5c64f26..63c020f 100644
--- a/lib/asyncnotifier.py
+++ b/lib/asyncnotifier.py
@@ -25,6 +25,7 @@
import asyncore
try:
+ # pylint: disable-msg=E0611
from pyinotify import pyinotify
except ImportError:
import pyinotify
@@ -34,7 +35,7 @@ class AsyncNotifier(asyncore.file_dispatcher):
"""An asyncore dispatcher for inotify events.
"""
-
+ # pylint: disable-msg=W0622,W0212
def __init__(self, watch_manager, default_proc_fun=None, map=None):
"""Initializes this class.
diff --git a/lib/backend.py b/lib/backend.py
index d2b75c6..7de7abb 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -392,7 +392,7 @@ def LeaveCluster(modify_ssh_setup):
utils.RemoveFile(constants.HMAC_CLUSTER_KEY)
utils.RemoveFile(constants.RAPI_CERT_FILE)
utils.RemoveFile(constants.SSL_CERT_FILE)
- except:
+ except: # pylint: disable-msg=W0702
logging.exception("Error while removing cluster secrets")
result = utils.RunCmd([constants.DAEMON_UTIL, "stop", constants.CONFD])
@@ -1195,6 +1195,8 @@ def BlockdevCreate(disk, size, owner, on_primary, info):
it's not required to return anything.
"""
+ # TODO: remove the obsolete 'size' argument
+ # pylint: disable-msg=W0613
clist = []
if disk.children:
for child in disk.children:
diff --git a/lib/build/__init__.py b/lib/build/__init__.py
index 0f58b61..be7f32e 100644
--- a/lib/build/__init__.py
+++ b/lib/build/__init__.py
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Module used during the Ganeti build process"""
import imp
import os
diff --git a/lib/cli.py b/lib/cli.py
index 996f453..38557f3 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -170,7 +170,7 @@ UN_PREFIX = "-"
class _Argument:
- def __init__(self, min=0, max=None):
+ def __init__(self, min=0, max=None): # pylint: disable-msg=W0622
self.min = min
self.max = max
@@ -185,6 +185,7 @@ class ArgSuggest(_Argument):
Value can be any of the ones passed to the constructor.
"""
+ # pylint: disable-msg=W0622
def __init__(self, min=0, max=None, choices=None):
_Argument.__init__(self, min=min, max=max)
self.choices = choices
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 74318c8..978bacf 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -261,6 +261,8 @@ class LogicalUnit(object):
"""
raise NotImplementedError
+ # this is valid in this entire class even if added here
+ # pylint: disable-msg=R0201
def HooksCallBack(self, phase, hook_results, feedback_fn, lu_result):
"""Notify the LU about the results of its hooks.
@@ -699,7 +701,7 @@ def _BuildInstanceHookEnvByObject(lu, instance,
override=None):
}
if override:
args.update(override)
- return _BuildInstanceHookEnv(**args)
+ return _BuildInstanceHookEnv(**args) # pylint: disable-msg=W0142
def _AdjustCandidatePool(lu, exceptions):
@@ -909,6 +911,7 @@ class LUDestroyCluster(LogicalUnit):
try:
hm.RunPhase(constants.HOOKS_PHASE_POST, [master])
except:
+ # pylint: disable-msg=W0702
self.LogWarning("Errors occurred running hooks on %s" % master)
result = self.rpc.call_node_stop_master(master, False)
@@ -1029,7 +1032,7 @@ class LUVerifyCluster(LogicalUnit):
"""
node = nodeinfo.name
- _ErrorIf = self._ErrorIf
+ _ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
# main result, node_result should be a non-empty dict
test = not node_result or not isinstance(node_result, dict)
@@ -1176,7 +1179,7 @@ class LUVerifyCluster(LogicalUnit):
available on the instance's node.
"""
- _ErrorIf = self._ErrorIf
+ _ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
node_current = instanceconfig.primary_node
node_vol_should = {}
@@ -1291,7 +1294,7 @@ class LUVerifyCluster(LogicalUnit):
"""
self.bad = False
- _ErrorIf = self._ErrorIf
+ _ErrorIf = self._ErrorIf # pylint: disable-msg=C0103
verbose = self.op.verbose
self._feedback_fn = feedback_fn
feedback_fn("* Verifying global settings")
@@ -2476,6 +2479,7 @@ class LURemoveNode(LogicalUnit):
try:
hm.RunPhase(constants.HOOKS_PHASE_POST, [node.name])
except:
+ # pylint: disable-msg=W0702
self.LogWarning("Errors occurred running hooks on %s" % node.name)
result = self.rpc.call_node_leave_cluster(node.name, modify_ssh_setup)
@@ -2489,6 +2493,7 @@ class LUQueryNodes(NoHooksLU):
"""Logical unit for querying nodes.
"""
+ # pylint: disable-msg=W0142
_OP_REQP = ["output_fields", "names", "use_locking"]
REQ_BGL = False
@@ -3019,7 +3024,7 @@ class LUAddNode(LogicalUnit):
# later in the procedure; this also means that if the re-add
# fails, we are left with a non-offlined, broken node
if self.op.readd:
- new_node.drained = new_node.offline = False
+ new_node.drained = new_node.offline = False # pylint: disable-msg=W0201
self.LogInfo("Readding a node, the offline/drained flags were reset")
# if we demote the node, we do cleanup later in the procedure
new_node.master_candidate = self.master_candidate
@@ -4261,6 +4266,7 @@ class LUQueryInstances(NoHooksLU):
"""Logical unit for querying instances.
"""
+ # pylint: disable-msg=W0142
_OP_REQP = ["output_fields", "names", "use_locking"]
REQ_BGL = False
_SIMPLE_FIELDS = ["name", "os", "network_port", "hypervisor",
@@ -4322,6 +4328,8 @@ class LUQueryInstances(NoHooksLU):
"""Computes the list of nodes and their attributes.
"""
+ # pylint: disable-msg=R0912
+ # way too many branches here
all_info = self.cfg.GetAllInstancesInfo()
if self.wanted == locking.ALL_SET:
# caller didn't specify instance names, so ordering is not important
@@ -8454,6 +8462,8 @@ class IAllocator(object):
easy usage
"""
+ # pylint: disable-msg=R0902
+ # lots of instance attributes
_ALLO_KEYS = [
"mem_size", "disks", "disk_template",
"os", "tags", "nics", "vcpus", "hypervisor",
diff --git a/lib/confd/querylib.py b/lib/confd/querylib.py
index f2831a3..7dd474c 100644
--- a/lib/confd/querylib.py
+++ b/lib/confd/querylib.py
@@ -50,7 +50,7 @@ class ConfdQuery(object):
"""
self.reader = reader
- def Exec(self, query):
+ def Exec(self, query): # pylint: disable-msg=R0201
"""Process a single UDP request from a client.
Different queries should override this function, which by defaults returns
diff --git a/lib/daemon.py b/lib/daemon.py
index 6fb2f66..09c1393 100644
--- a/lib/daemon.py
+++ b/lib/daemon.py
@@ -105,7 +105,7 @@ class AsyncUDPSocket(asyncore.dispatcher):
raise
ip, port = address
self.handle_datagram(payload, ip, port)
- except:
+ except: # pylint: disable-msg=W0702
# we need to catch any exception here, log it, but proceed, because even
# if we failed handling a single request, we still want to continue.
logging.error("Unexpected exception", exc_info=True)
@@ -139,7 +139,7 @@ class AsyncUDPSocket(asyncore.dispatcher):
else:
raise
self._out_queue.pop(0)
- except:
+ except: # pylint: disable-msg=W0702
# we need to catch any exception here, log it, but proceed, because even
# if we failed sending a single datagram we still want to continue.
logging.error("Unexpected exception", exc_info=True)
diff --git a/lib/http/__init__.py b/lib/http/__init__.py
index c4b9ec2..c6e9ee0 100644
--- a/lib/http/__init__.py
+++ b/lib/http/__init__.py
@@ -299,7 +299,7 @@ class HttpVersionNotSupported(HttpException):
code = 505
-class HttpJsonConverter:
+class HttpJsonConverter: # pylint: disable-msg=W0232
CONTENT_TYPE = "application/json"
def Encode(self, data):
diff --git a/lib/http/client.py b/lib/http/client.py
index 0bf4031..490e4da 100644
--- a/lib/http/client.py
+++ b/lib/http/client.py
@@ -333,7 +333,7 @@ class HttpClientWorker(workerpool.BaseWorker):
"""HTTP client worker class.
"""
- def RunTask(self, pend_req):
+ def RunTask(self, pend_req): # pylint: disable-msg=W0221
try:
HttpClientRequestExecutor(pend_req.request)
finally:
diff --git a/lib/http/server.py b/lib/http/server.py
index d073cfb..ba5cc97 100644
--- a/lib/http/server.py
+++ b/lib/http/server.py
@@ -514,6 +514,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
"""Called for each incoming connection
"""
+ # pylint: disable-msg=W0212
(connection, client_addr) = self.socket.accept()
self._CollectChildren(False)
@@ -533,7 +534,7 @@ class HttpServer(http.HttpBase, asyncore.dispatcher):
self.socket = None
self.request_executor(self, connection, client_addr)
- except Exception:
+ except Exception: # pylint: disable-msg=W0703
logging.exception("Error while handling request from %s:%s",
client_addr[0], client_addr[1])
os._exit(1)
diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py
index cdef0d0..86b85c9 100644
--- a/lib/hypervisor/hv_base.py
+++ b/lib/hypervisor/hv_base.py
@@ -190,7 +190,7 @@ class BaseHypervisor(object):
"""
raise NotImplementedError
- def MigrationInfo(self, instance):
+ def MigrationInfo(self, instance): # pylint: disable-msg=R0201,W0613
"""Get instance information to perform a migration.
By default assume no information is needed.
diff --git a/lib/jqueue.py b/lib/jqueue.py
index 13f112f..25f464e 100644
--- a/lib/jqueue.py
+++ b/lib/jqueue.py
@@ -154,6 +154,7 @@ class _QueuedJob(object):
@ivar change: a Condition variable we use for waiting for job changes
"""
+ # pylint: disable-msg=W0212
__slots__ = ["queue", "id", "ops", "log_serial",
"received_timestamp", "start_timestamp", "end_timestamp",
"lock_status", "change",
@@ -419,7 +420,7 @@ class _JobQueueWorker(workerpool.BaseWorker):
"""The actual job workers.
"""
- def RunTask(self, job):
+ def RunTask(self, job): # pylint: disable-msg=W0221
"""Job executor.
This functions processes a job. It is closely tied to the _QueuedJob and
@@ -559,6 +560,7 @@ def _RequireOpenQueue(fn):
"""
def wrapper(self, *args, **kwargs):
+ # pylint: disable-msg=W0212
assert self._queue_lock is not None, "Queue should be open"
return fn(self, *args, **kwargs)
return wrapper
@@ -963,7 +965,7 @@ class JobQueue(object):
try:
job = _QueuedJob.Restore(self, data)
- except Exception, err:
+ except Exception, err: # pylint: disable-msg=W0703
new_path = self._GetArchivedJobPath(job_id)
if filepath == new_path:
# job already archived (future case)
diff --git a/lib/locking.py b/lib/locking.py
index c92f1e5..6ba74f2 100644
--- a/lib/locking.py
+++ b/lib/locking.py
@@ -287,7 +287,7 @@ class SingleNotifyPipeCondition(_BaseCondition):
if self._nwaiters == 0:
self._Cleanup()
- def notifyAll(self):
+ def notifyAll(self): # pylint: disable-msg=C0103
"""Close the writing side of the pipe to notify all waiters.
"""
@@ -345,7 +345,7 @@ class PipeCondition(_BaseCondition):
assert self._nwaiters > 0
self._nwaiters -= 1
- def notifyAll(self):
+ def notifyAll(self): # pylint: disable-msg=C0103
"""Notify all currently waiting threads.
"""
@@ -382,7 +382,7 @@ class _CountingCondition(object):
self._cond = threading.Condition(lock=lock)
self._nwaiters = 0
- def notifyAll(self):
+ def notifyAll(self): # pylint: disable-msg=C0103
"""Notifies the condition.
"""
diff --git a/lib/luxi.py b/lib/luxi.py
index 753b005..e72d7d0 100644
--- a/lib/luxi.py
+++ b/lib/luxi.py
@@ -286,7 +286,7 @@ class Client(object):
old_transp = self.transport
self.transport = None
old_transp.Close()
- except Exception:
+ except Exception: # pylint: disable-msg=W0703
pass
def CallMethod(self, method, args):
diff --git a/lib/mcpu.py b/lib/mcpu.py
index e97c743..af4ff1a 100644
--- a/lib/mcpu.py
+++ b/lib/mcpu.py
@@ -136,7 +136,7 @@ class _LockAttemptTimeoutStrategy(object):
return timeout
-class OpExecCbBase:
+class OpExecCbBase: # pylint: disable-msg=W0232
"""Base class for OpCode execution callbacks.
"""
diff --git a/lib/objects.py b/lib/objects.py
index e7eb537..f8d94da 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -26,11 +26,12 @@ pass to and from external parties.
"""
-# pylint: disable-msg=E0203
+# pylint: disable-msg=E0203,W0201
# E0203: Access to member %r before its definition, since we use
# objects.py which doesn't explicitely initialise its members
+# W0201: Attribute '%s' defined outside __init__
import ConfigParser
import re
@@ -153,7 +154,7 @@ class ConfigObject(object):
raise errors.ConfigurationError("Invalid object passed to FromDict:"
" expected dict, got %s" % type(val))
val_str = dict([(str(k), v) for k, v in val.iteritems()])
- obj = cls(**val_str)
+ obj = cls(**val_str) # pylint: disable-msg=W0142
return obj
@staticmethod
diff --git a/lib/rapi/__init__.py b/lib/rapi/__init__.py
index fde366c..28d6ead 100644
--- a/lib/rapi/__init__.py
+++ b/lib/rapi/__init__.py
@@ -18,5 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Ganeti RAPI module"""
RAPI_ACCESS_WRITE = "write"
diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py
index 58fb2a8..934abe3 100644
--- a/lib/rapi/rlib2.py
+++ b/lib/rapi/rlib2.py
@@ -672,6 +672,7 @@ class _R_Tags(baserlib.R_Generic):
Example: ["tag1", "tag2", "tag3"]
"""
+ # pylint: disable-msg=W0212
return baserlib._Tags_GET(self.TAG_LEVEL, name=self.name)
def PUT(self):
@@ -681,6 +682,7 @@ class _R_Tags(baserlib.R_Generic):
you'll have back a job id.
"""
+ # pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
raise http.HttpBadRequest("Please specify tag(s) to add using the"
" the 'tag' parameter")
@@ -696,6 +698,7 @@ class _R_Tags(baserlib.R_Generic):
/tags?tag=[tag]&tag=[tag]
"""
+ # pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
# no we not gonna delete all tags
raise http.HttpBadRequest("Cannot delete all tags - please specify"
diff --git a/lib/rpc.py b/lib/rpc.py
index 0980875..69e692c 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -163,7 +163,7 @@ class RpcResult(object):
args = (msg, prereq)
else:
args = (msg, )
- raise ec(*args)
+ raise ec(*args) # pylint: disable-msg=W0142
class Client:
diff --git a/lib/storage.py b/lib/storage.py
index b4b303a..5d30396 100644
--- a/lib/storage.py
+++ b/lib/storage.py
@@ -23,6 +23,14 @@
"""
+# pylint: disable-msg=W0232,R0201
+
+# W0232, since we use these as singletons rather than object holding
+# data
+
+# R0201, for the same reason
+
+# TODO: FileStorage initialised with paths whereas the others not
import logging
@@ -50,7 +58,7 @@ class _Base:
"""
raise NotImplementedError()
- def Modify(self, name, changes):
+ def Modify(self, name, changes): # pylint: disable-msg=W0613
"""Modifies an entity within the storage unit.
@type name: string
@@ -76,7 +84,7 @@ class _Base:
raise NotImplementedError()
-class FileStorage(_Base):
+class FileStorage(_Base): # pylint: disable-msg=W0223
"""File storage unit.
"""
@@ -153,7 +161,7 @@ class FileStorage(_Base):
return values
-class _LvmBase(_Base):
+class _LvmBase(_Base): # pylint: disable-msg=W0223
"""Base class for LVM storage containers.
@cvar LIST_FIELDS: list of tuples consisting of three elements: SF_*
@@ -248,7 +256,7 @@ class _LvmBase(_Base):
if callable(mapper):
# we got a function, call it with all the declared fields
- val = mapper(*values)
+ val = mapper(*values) # pylint: disable-msg=W0142
elif len(values) == 1:
# we don't have a function, but we had a single field
# declared, pass it unchanged
@@ -324,7 +332,7 @@ class _LvmBase(_Base):
yield fields
-class LvmPvStorage(_LvmBase):
+class LvmPvStorage(_LvmBase): # pylint: disable-msg=W0223
"""LVM Physical Volume storage unit.
"""
diff --git a/lib/utils.py b/lib/utils.py
index 105364e..c8ac96a 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -1369,14 +1369,14 @@ def FirstFree(seq, base=0):
return None
-def all(seq, pred=bool):
+def all(seq, pred=bool): # pylint: disable-msg=W0622
"Returns True if pred(x) is True for every element in the iterable"
for _ in itertools.ifilterfalse(pred, seq):
return False
return True
-def any(seq, pred=bool):
+def any(seq, pred=bool): # pylint: disable-msg=W0622
"Returns True if pred(x) is True for at least one element in the iterable"
for _ in itertools.ifilter(pred, seq):
return True
@@ -1493,6 +1493,8 @@ def Daemonize(logfile):
@return: the value zero
"""
+ # pylint: disable-msg=W0212
+ # yes, we really want os._exit
UMASK = 077
WORKDIR = "/"
@@ -1567,7 +1569,7 @@ def RemovePidFile(name):
# TODO: we could check here that the file contains our pid
try:
RemoveFile(pidfilename)
- except:
+ except: # pylint: disable-msg=W0702
pass
@@ -1958,6 +1960,7 @@ def LockedMethod(fn):
logging.debug(*args, **kwargs)
def wrapper(self, *args, **kwargs):
+ # pylint: disable-msg=W0212
assert hasattr(self, '_lock')
lock = self._lock
_LockDebug("Waiting for %s", lock)
@@ -2164,6 +2167,7 @@ def Retry(fn, delay, timeout, args=None,
wait_fn=time.sleep,
while True:
try:
+ # pylint: disable-msg=W0142
return fn(*args)
except RetryAgain:
pass
diff --git a/lib/workerpool.py b/lib/workerpool.py
index fa202d0..2d3937a 100644
--- a/lib/workerpool.py
+++ b/lib/workerpool.py
@@ -34,6 +34,7 @@ class BaseWorker(threading.Thread, object):
Users of a worker pool must override RunTask in a subclass.
"""
+ # pylint: disable-msg=W0212
def __init__(self, pool, worker_id):
"""Constructor for BaseWorker thread.
@@ -118,7 +119,7 @@ class BaseWorker(threading.Thread, object):
self.RunTask(*self._current_task)
logging.debug("Worker %s: done with task %r",
self.worker_id, self._current_task)
- except:
+ except: # pylint: disable-msg=W0702
logging.error("Worker %s: Caught unhandled exception",
self.worker_id, exc_info=True)
finally:
@@ -223,7 +224,7 @@ class WorkerPool(object):
"""
for worker in self._workers + self._termworkers:
- if worker._HasRunningTaskUnlocked():
+ if worker._HasRunningTaskUnlocked(): # pylint: disable-msg=W0212
return True
return False
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index 986b449..4d65648 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Backup related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-backup
import sys
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index 85a2a12..59f1b30 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Cluster related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-cluster
import sys
import os.path
diff --git a/scripts/gnt-debug b/scripts/gnt-debug
index e34b409..475ccb7 100755
--- a/scripts/gnt-debug
+++ b/scripts/gnt-debug
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Debugging commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-backup
import sys
import simplejson
@@ -77,6 +79,7 @@ def GenericOpCodes(opts, args):
ToStdout("Loading...")
for job_idx in range(opts.rep_job):
for fname in args:
+ # pylint: disable-msg=W0142
op_data = simplejson.loads(utils.ReadFile(fname))
op_list = [opcodes.OpCode.LoadOpCode(val) for val in op_data]
op_list = op_list * opts.rep_op
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index d32b254..4fc8c8e 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Instance related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-instance
import sys
import os
@@ -75,6 +77,7 @@ def _ExpandMultiNames(mode, names, client=None):
@raise errors.OpPrereqError: for invalid input parameters
"""
+ # pylint: disable-msg=W0142
if client is None:
client = GetClient()
if mode == _SHUTDOWN_CLUSTER:
@@ -395,7 +398,7 @@ def BatchCreate(opts, args):
json_filename = args[0]
try:
instance_data = simplejson.loads(utils.ReadFile(json_filename))
- except Exception, err:
+ except Exception, err: # pylint: disable-msg=W0703
ToStderr("Can't parse the instance definition file: %s" % str(err))
return 1
@@ -911,7 +914,7 @@ def ConnectToInstanceConsole(opts, args):
finally:
ToStderr("Can't run console command %s with arguments:\n'%s'",
cmd[0], " ".join(cmd))
- os._exit(1)
+ os._exit(1) # pylint: disable-msg=W0212
def _FormatLogicalID(dev_type, logical_id):
diff --git a/scripts/gnt-job b/scripts/gnt-job
index 44ae4b2..cd4612b 100755
--- a/scripts/gnt-job
+++ b/scripts/gnt-job
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Job related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-job
import sys
diff --git a/scripts/gnt-node b/scripts/gnt-node
index 7e3e439..26cfd7e 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""Node related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-node
import sys
diff --git a/scripts/gnt-os b/scripts/gnt-os
index f3667c4..ed8d27f 100755
--- a/scripts/gnt-os
+++ b/scripts/gnt-os
@@ -18,10 +18,12 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
+"""OS scripts related commands"""
-# pylint: disable-msg=W0401,W0614
+# pylint: disable-msg=W0401,W0614,C0103
# W0401: Wildcard import ganeti.cli
# W0614: Unused import %s from wildcard import (since we need cli)
+# C0103: Invalid name gnt-os
import sys
diff --git a/tools/burnin b/tools/burnin
index 3d70161..b566df8 100755
--- a/tools/burnin
+++ b/tools/burnin
@@ -83,8 +83,9 @@ def Err(msg, exit_code=1):
class SimpleOpener(urllib.FancyURLopener):
"""A simple url opener"""
+ # pylint: disable-msg=W0221
- def prompt_user_passwd(self, host, realm, clear_cache = 0):
+ def prompt_user_passwd(self, host, realm, clear_cache=0):
"""No-interaction version of prompt_user_passwd."""
return None, None
@@ -208,7 +209,7 @@ def _DoCheckInstances(fn):
def wrapper(self, *args, **kwargs):
val = fn(self, *args, **kwargs)
for instance in self.instances:
- self._CheckInstanceAlive(instance)
+ self._CheckInstanceAlive(instance) # pylint: disable-msg=W0212
return val
return wrapper
@@ -289,7 +290,7 @@ class Burner(object):
Log("Idempotent %s succeeded after %d retries" %
(msg, MAX_RETRIES - retry_count))
return val
- except Exception, err:
+ except Exception, err: # pylint: disable-msg=W0703
if retry_count == 0:
Log("Non-idempotent %s failed, aborting" % (msg, ))
raise
@@ -377,7 +378,7 @@ class Burner(object):
Log("waiting for job %s for %s" % (jid, iname), indent=2)
try:
results.append(cli.PollJob(jid, cl=self.cl, feedback_fn=self.Feedback))
- except Exception, err:
+ except Exception, err: # pylint: disable-msg=W0703
Log("Job for %s failed: %s" % (iname, err))
if len(results) != len(jobs):
raise BurninFailure()
@@ -544,7 +545,7 @@ class Burner(object):
disks=[i for i in range(self.disk_count)])
Log("run %s" % mode, indent=2)
ops.append(op)
- self.ExecOrQueue(instance, *ops)
+ self.ExecOrQueue(instance, *ops) # pylint: disable-msg=W0142
@_DoBatch(True)
def BurnReplaceDisks2(self):
@@ -760,7 +761,7 @@ class Burner(object):
ignore_secondaries=False)
Log("reboot with type '%s'" % reboot_type, indent=2)
ops.append(op)
- self.ExecOrQueue(instance, *ops)
+ self.ExecOrQueue(instance, *ops) # pylint: disable-msg=W0142
@_DoCheckInstances
@_DoBatch(True)
@@ -913,7 +914,7 @@ class Burner(object):
if not self.opts.keep_instances:
try:
self.BurnRemove()
- except Exception, err:
+ except Exception, err: # pylint: disable-msg=W0703
if has_err: # already detected errors, so errors in removal
# are quite expected
Log("Note: error detected during instance remove: %s" % str(err))
diff --git a/tools/cfgshell b/tools/cfgshell
index 101e2ca..acdf9fb 100755
--- a/tools/cfgshell
+++ b/tools/cfgshell
@@ -152,7 +152,7 @@ class ConfigShell(cmd.Cmd):
arg = None
try:
self.cfg = config.ConfigWriter(cfg_file=arg, offline=True)
- self.parents = [self.cfg._config_data]
+ self.parents = [self.cfg._config_data] # pylint: disable-msg=W0212
self.path = []
except errors.ConfigurationError, err:
print "Error: %s" % str(err)
@@ -284,7 +284,7 @@ class ConfigShell(cmd.Cmd):
if self.cfg.VerifyConfig():
print "Config data does not validate, refusing to save."
return False
- self.cfg._WriteConfig()
+ self.cfg._WriteConfig() # pylint: disable-msg=W0212
def do_rm(self, line):
"""Removes an instance or a node.
@@ -294,7 +294,7 @@ class ConfigShell(cmd.Cmd):
"""
pointer = self.parents[-1]
- data = self.cfg._config_data
+ data = self.cfg._config_data # pylint: disable-msg=W0212
if pointer not in (data.instances, data.nodes):
print "Can only delete instances and nodes"
return False
diff --git a/tools/cfgupgrade b/tools/cfgupgrade
index deaba33..5755505 100755
--- a/tools/cfgupgrade
+++ b/tools/cfgupgrade
@@ -98,7 +98,7 @@ def main():
"""Main program.
"""
- global options, args
+ global options, args # pylint: disable-msg=W0603
program = os.path.basename(sys.argv[0])
diff --git a/tools/lvmstrap b/tools/lvmstrap
index 223f6fd..bd867d0 100755
--- a/tools/lvmstrap
+++ b/tools/lvmstrap
@@ -130,7 +130,7 @@ def ParseOptions():
Returns:
(options, args), as returned by OptionParser.parse_args
"""
- global verbose_flag
+ global verbose_flag # pylint: disable-msg=W0603
parser = optparse.OptionParser(usage="\n%s" % USAGE,
version="%%prog (ganeti) %s" %
--
1.6.5.7