Commit 36b6d149 authored by Thomas Thrainer's avatar Thomas Thrainer

Merge branch 'stable-2.11' into stable-2.12

* stable-2.11
  (no commits)
* stable-2.10
  tiered allocation: try canonical search path first
  Add QA config flag for all performance tests
  build-bash-completion: reduce branches
  Convert all the classes to new-style classes
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parents 809a055b 98da4d04
......@@ -50,15 +50,7 @@ from ganeti.tools import burnin
_OPT_NAME_RE = re.compile(r"^-[a-zA-Z0-9]|--[a-z][-a-z0-9]+$")
def WritePreamble(sw, support_debug):
"""Writes the script preamble.
Helper functions should be written here.
"""
sw.Write("# This script is automatically generated at build time.")
sw.Write("# Do not modify manually.")
def _WriteGntLog(sw, support_debug):
if support_debug:
sw.Write("_gnt_log() {")
sw.IncIndent()
......@@ -82,6 +74,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteNodes(sw):
sw.Write("_ganeti_nodes() {")
sw.IncIndent()
try:
......@@ -91,6 +85,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteInstances(sw):
sw.Write("_ganeti_instances() {")
sw.IncIndent()
try:
......@@ -101,6 +97,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteJobs(sw):
sw.Write("_ganeti_jobs() {")
sw.IncIndent()
try:
......@@ -113,6 +111,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteOSAndIAllocator(sw):
for (fnname, paths) in [
("os", pathutils.OS_SEARCH_PATH),
("iallocator", constants.IALLOCATOR_SEARCH_PATH),
......@@ -128,6 +128,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteNodegroup(sw):
sw.Write("_ganeti_nodegroup() {")
sw.IncIndent()
try:
......@@ -137,6 +139,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteNetwork(sw):
sw.Write("_ganeti_network() {")
sw.IncIndent()
try:
......@@ -146,6 +150,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteFindFirstArg(sw):
# Params: <offset> <options with values> <options without values>
# Result variable: $first_arg_idx
sw.Write("_ganeti_find_first_arg() {")
......@@ -175,6 +181,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteListOptions(sw):
# Params: <list of options separated by space>
# Input variable: $first_arg_idx
# Result variables: $arg_idx, $choices
......@@ -205,6 +213,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteGntCheckopt(sw, support_debug):
# Params: <long options with equal sign> <all options>
# Result variable: $optcur
sw.Write("_gnt_checkopt() {")
......@@ -234,6 +244,8 @@ def WritePreamble(sw, support_debug):
sw.DecIndent()
sw.Write("}")
def _WriteGntCompgen(sw, support_debug):
# Params: <compgen options>
# Result variable: $COMPREPLY
sw.Write("_gnt_compgen() {")
......@@ -247,12 +259,34 @@ def WritePreamble(sw, support_debug):
sw.Write("}")
def WritePreamble(sw, support_debug):
"""Writes the script preamble.
Helper functions should be written here.
"""
sw.Write("# This script is automatically generated at build time.")
sw.Write("# Do not modify manually.")
_WriteGntLog(sw, support_debug)
_WriteNodes(sw)
_WriteInstances(sw)
_WriteJobs(sw)
_WriteOSAndIAllocator(sw)
_WriteNodegroup(sw)
_WriteNetwork(sw)
_WriteFindFirstArg(sw)
_WriteListOptions(sw)
_WriteGntCheckopt(sw, support_debug)
_WriteGntCompgen(sw, support_debug)
def WriteCompReply(sw, args, cur="\"$cur\""):
sw.Write("_gnt_compgen %s -- %s", args, cur)
sw.Write("return")
class CompletionWriter:
class CompletionWriter(object):
"""Command completion writer class.
"""
......
......@@ -99,7 +99,7 @@ def SetupLogging():
return child_logger
class StatusFile:
class StatusFile(object):
"""Status file manager.
"""
......
......@@ -1881,7 +1881,7 @@ def InstanceShutdown(instance, timeout, reason, store_reason=True):
logging.info("Instance %s not running, doing nothing", iname)
return
class _TryShutdown:
class _TryShutdown(object):
def __init__(self):
self.tried_once = False
......
......@@ -366,7 +366,7 @@ _QFT_NAMES = {
}
class _Argument:
class _Argument(object):
def __init__(self, min=0, max=None): # pylint: disable=W0622
self.min = min
self.max = max
......@@ -2246,7 +2246,7 @@ def GenericPollJob(job_id, cbs, report_cbs):
raise errors.OpExecError(result)
class JobPollCbBase:
class JobPollCbBase(object):
"""Base class for L{GenericPollJob} callbacks.
"""
......@@ -2274,7 +2274,7 @@ class JobPollCbBase:
raise NotImplementedError()
class JobPollReportCbBase:
class JobPollReportCbBase(object):
"""Base class for L{GenericPollJob} reporting callbacks.
"""
......@@ -2905,7 +2905,7 @@ def GenericInstanceCreate(mode, opts, args):
return 0
class _RunWhileClusterStoppedHelper:
class _RunWhileClusterStoppedHelper(object):
"""Helper class for L{RunWhileClusterStopped} to simplify state management
"""
......@@ -3195,7 +3195,7 @@ def _GetColumnFormatter(fdef, override, unit):
raise NotImplementedError("Can't format column type '%s'" % fdef.kind)
class _QueryColumnFormatter:
class _QueryColumnFormatter(object):
"""Callable class for formatting fields of a query.
"""
......@@ -3469,7 +3469,7 @@ def GenericListFields(resource, fields, separator, header, cl=None):
return constants.EXIT_SUCCESS
class TableColumn:
class TableColumn(object):
"""Describes a column for L{FormatTable}.
"""
......
......@@ -1429,7 +1429,7 @@ def _InstanceStart(opts, inst_list, start, no_remember=False):
return True
class _RunWhenNodesReachableHelper:
class _RunWhenNodesReachableHelper(object):
"""Helper class to make shared internal state sharing easier.
@ivar success: Indicates if all action_cb calls were successful
......
......@@ -31,7 +31,7 @@ from ganeti import utils
from ganeti.cmdlib.common import ExpandInstanceUuidAndName
class ResultWithJobs:
class ResultWithJobs(object):
"""Data container for LU results with jobs.
Instances of this class returned from L{LogicalUnit.Exec} will be recognized
......@@ -515,7 +515,7 @@ class NoHooksLU(LogicalUnit): # pylint: disable=W0223
raise AssertionError("PreparePostHookNodes called for NoHooksLU")
class Tasklet:
class Tasklet(object):
"""Tasklet base class.
Tasklets are subcomponents for LUs. LUs can consist entirely of tasklets or
......@@ -561,7 +561,7 @@ class Tasklet:
raise NotImplementedError
class QueryBase:
class QueryBase(object):
"""Base for query utility classes.
"""
......
......@@ -2371,7 +2371,7 @@ class LUInstanceMultiAlloc(NoHooksLU):
return ResultWithJobs(jobs, **self._ConstructPartialResult())
class _InstNicModPrivate:
class _InstNicModPrivate(object):
"""Data structure for network interface modifications.
Used by L{LUInstanceSetParams}.
......
......@@ -106,7 +106,7 @@ class _Request(object):
self.rcvd = set()
class ConfdClient:
class ConfdClient(object):
"""Send queries to confd, and get back answers.
Since the confd model works by querying multiple master candidates, and
......@@ -462,7 +462,7 @@ class ConfdClientRequest(objects.ConfdRequest):
raise errors.ConfdClientError("Invalid request type")
class ConfdFilterCallback:
class ConfdFilterCallback(object):
"""Callback that calls another callback, but filters duplicate results.
@ivar consistent: a dictionary indexed by salt; for each salt, if
......@@ -567,7 +567,7 @@ class ConfdFilterCallback:
self._callback(up)
class ConfdCountingCallback:
class ConfdCountingCallback(object):
"""Callback that calls another callback, and counts the answers
"""
......@@ -629,7 +629,7 @@ class ConfdCountingCallback:
self._callback(up)
class StoreResultCallback:
class StoreResultCallback(object):
"""Callback that simply stores the most recent answer.
@ivar _answers: dict of salt to (have_answer, reply)
......
......@@ -130,7 +130,7 @@ def _ValidateConfig(data):
data['version'])
class TemporaryReservationManager:
class TemporaryReservationManager(object):
"""A temporary resource reservation manager.
This is used to reserve resources in a job, before using them, making sure
......
......@@ -457,7 +457,7 @@ class AsyncAwaker(GanetiBaseAsyncoreDispatcher):
self.out_socket.send(chr(0))
class _ShutdownCheck:
class _ShutdownCheck(object):
"""Logic for L{Mainloop} shutdown.
"""
......
......@@ -174,7 +174,7 @@ def _StartRequest(curl, req):
return _PendingRequest(curl, req, resp_buffer.getvalue)
class _PendingRequest:
class _PendingRequest(object):
def __init__(self, curl, req, resp_buffer_read):
"""Initializes this class.
......@@ -233,7 +233,7 @@ class _PendingRequest:
req.completion_cb(req)
class _NoOpRequestMonitor: # pylint: disable=W0232
class _NoOpRequestMonitor(object): # pylint: disable=W0232
"""No-op request monitor.
"""
......@@ -245,7 +245,7 @@ class _NoOpRequestMonitor: # pylint: disable=W0232
Disable = acquire
class _PendingRequestMonitor:
class _PendingRequestMonitor(object):
_LOCK = "_lock"
def __init__(self, owner, pending_fn):
......
......@@ -581,6 +581,7 @@ class _QueuedJob(object):
class _OpExecCallbacks(mcpu.OpExecCbBase):
def __init__(self, queue, job, op):
"""Initializes this class.
......@@ -592,6 +593,8 @@ class _OpExecCallbacks(mcpu.OpExecCbBase):
@param op: OpCode
"""
super(_OpExecCallbacks, self).__init__()
assert queue, "Queue is missing"
assert job, "Job is missing"
assert op, "Opcode is missing"
......
......@@ -971,7 +971,7 @@ class _AcquireTimeout(Exception):
"""
class LockSet:
class LockSet(object):
"""Implements a set of locks.
This abstraction implements a set of shared locks for the same resource type,
......
......@@ -659,7 +659,7 @@ def FormatProgress(progress):
return utils.CommaJoin(parts)
class ImportExportLoop:
class ImportExportLoop(object):
MIN_DELAY = 1.0
MAX_DELAY = 20.0
......@@ -1139,7 +1139,7 @@ class _RemoteExportCb(ImportExportCbBase):
finished_fn()
class ExportInstanceHelper:
class ExportInstanceHelper(object):
def __init__(self, lu, feedback_fn, instance):
"""Initializes this class.
......
......@@ -140,7 +140,7 @@ class LockAttemptTimeoutStrategy(object):
return timeout
class OpExecCbBase: # pylint: disable=W0232
class OpExecCbBase(object): # pylint: disable=W0232
"""Base class for OpCode execution callbacks.
"""
......
......@@ -157,7 +157,7 @@ def GetHostname(name=None, family=None):
(err[0], err[2]), errors.ECODE_RESOLVER)
class Hostname:
class Hostname(object):
"""Class implementing resolver and hostname functionality.
"""
......
......@@ -204,7 +204,7 @@ def GetAllFields(fielddefs):
return [fdef for (fdef, _, _, _) in fielddefs]
class _FilterHints:
class _FilterHints(object):
"""Class for filter analytics.
When filters are used, the user of the L{Query} class usually doesn't know
......@@ -390,7 +390,7 @@ def _MakeComparisonChecks(fn):
]
class _FilterCompilerHelper:
class _FilterCompilerHelper(object):
"""Converts a query filter to a callable usable for filtering.
"""
......@@ -658,7 +658,7 @@ def _CompileFilter(fields, hints, qfilter):
return _FilterCompilerHelper(fields)(hints, qfilter)
class Query:
class Query(object):
def __init__(self, fieldlist, selected, qfilter=None, namefield=None):
"""Initializes this class.
......@@ -1090,7 +1090,7 @@ def _GetItemTimestampFields(datatype):
]
class NodeQueryData:
class NodeQueryData(object):
"""Data container for node data queries.
"""
......@@ -1409,7 +1409,7 @@ def _BuildNodeFields():
return _PrepareFieldList(fields, [])
class InstanceQueryData:
class InstanceQueryData(object):
"""Data container for instance data queries.
"""
......@@ -2254,7 +2254,7 @@ def _BuildInstanceFields():
return _PrepareFieldList(fields, aliases)
class LockQueryData:
class LockQueryData(object):
"""Data container for lock data queries.
"""
......@@ -2316,7 +2316,7 @@ def _BuildLockFields():
], [])
class GroupQueryData:
class GroupQueryData(object):
"""Data container for node group data queries.
"""
......@@ -2688,7 +2688,7 @@ _CLUSTER_SIMPLE_FIELDS = {
}
class ClusterQueryData:
class ClusterQueryData(object):
def __init__(self, cluster, nodes, drain_flag, watcher_pause):
"""Initializes this class.
......@@ -2760,7 +2760,7 @@ def _BuildClusterFields():
("name", "cluster_name")])
class NetworkQueryData:
class NetworkQueryData(object):
"""Data container for network data queries.
"""
......
......@@ -43,7 +43,7 @@ _DISK_PATTERN = r"\d+"
CONNECTOR = {}
class Mapper:
class Mapper(object):
"""Map resource to method.
"""
......
......@@ -146,7 +146,7 @@ def _FormatHeaders(headers):
return "\n".join(headers)
class FakeCurl:
class FakeCurl(object):
"""Fake cURL object.
"""
......@@ -207,7 +207,7 @@ class FakeCurl:
writefn(resp_body)
class _RapiMock:
class _RapiMock(object):
"""Mocking out the RAPI server parts.
"""
......@@ -250,7 +250,7 @@ class _RapiMock:
return (resp_msg.start_line.code, resp_msg.headers, resp_msg.body)
class _TestLuxiTransport:
class _TestLuxiTransport(object):
"""Mocked LUXI transport.
Raises L{errors.RapiTestResult} for all method calls, no matter the
......@@ -283,7 +283,7 @@ class _TestLuxiTransport:
raise errors.RapiTestResult
class _LuxiCallRecorder:
class _LuxiCallRecorder(object):
"""Records all called LUXI client methods.
"""
......@@ -328,7 +328,7 @@ def _TestWrapper(fn, *args, **kwargs):
return NotImplemented
class InputTestClient:
class InputTestClient(object):
"""Test version of RAPI client.
Instances of this class can be used to test input arguments for RAPI client
......
......@@ -72,7 +72,7 @@ def GetGid(group, _getgrnam):
raise errors.ConfigurationError("Group '%s' not found (%s)" % (group, err))
class GetentResolver:
class GetentResolver(object):
"""Resolves Ganeti uids and gids by name.
@ivar masterd_uid: The resolved uid of the masterd user
......
......@@ -136,7 +136,7 @@ class MasterClientHandler(daemon.AsyncTerminatedMessageStream):
self.server.request_workers.AddTask((self.server, message, self))
class _MasterShutdownCheck:
class _MasterShutdownCheck(object):
"""Logic for master daemon shutdown.
"""
......@@ -261,7 +261,7 @@ class MasterServer(daemon.AsyncStreamServer):
self.context.livelock.close()
class ClientOps:
class ClientOps(object):
"""Class holding high-level client operations."""
def __init__(self, server):
self.server = server
......
......@@ -205,7 +205,7 @@ class RemoteApiHandler(http.auth.HttpServerRequestAuthentication,
return serializer.DumpJson(result)
class RapiUsers:
class RapiUsers(object):
def __init__(self):
"""Initializes this class.
......
......@@ -106,7 +106,7 @@ def GetAllUserFiles(user, mkdir=False, dircheck=True, _homedir_fn=None):
for (kind, (privkey, pubkey, _)) in result))
class SshRunner:
class SshRunner(object):
"""Wrapper for SSH commands.
"""
......
......@@ -43,7 +43,7 @@ def _ParseSize(value):
return int(round(float(value), 0))
class _Base:
class _Base(object):
"""Base class for storage abstraction.
"""
......@@ -95,6 +95,8 @@ class FileStorage(_Base): # pylint: disable=W0223
@param paths: List of file storage paths
"""
super(FileStorage, self).__init__()
self._paths = paths
def List(self, name, fields):
......
......@@ -711,7 +711,7 @@ class DRBD8Dev(base.BlockDev):
base.ThrowError("drbd%d: DRBD disk missing network info in"
" DisconnectNet()", self.minor)
class _DisconnectStatus:
class _DisconnectStatus(object):
def __init__(self, ever_disconnected):
self.ever_disconnected = ever_disconnected
......
......@@ -72,7 +72,7 @@ def ErrnoOrStr(err):
return detail
class FileStatHelper:
class FileStatHelper(object):
"""Helper to store file handle's C{fstat}.
Useful in combination with L{ReadFile}'s C{preread} parameter.
......
......@@ -249,7 +249,7 @@ def ShellCombineCommands(cmdlist):
return ["/bin/sh", "-c", " && ".join(ShellQuoteArgs(c) for c in cmdlist)]
class ShellWriter:
class ShellWriter(object):
"""Helper class to write scripts with indentation.
"""
......@@ -533,7 +533,7 @@ def FormatSeconds(secs):
return " ".join(parts)
class LineSplitter:
class LineSplitter(object):