Commit 4be4691d authored by Iustin Pop's avatar Iustin Pop
Browse files

Slight change to the LU initialization code

This patch adds support for a separate LU.CheckArguments() method which
should do syntactic checks without holding locks and without polluting
the ExpandNames which is a lock-related function. See for example the
FIXME in LUSetInstanceParams.CheckPrereq.

The patch also removes the REQ_MASTER and IsCluster checks since with
the current architecture, inside LU code we are always in a valid
cluster and we are always running on the master node.

Reviewed-by: ultrotter
parent b637ae4d
......@@ -54,7 +54,6 @@ class LogicalUnit(object):
- implement BuildHooksEnv
- redefine HPATH and HTYPE
- optionally redefine their run requirements:
REQ_MASTER: the LU needs to run on the master node
REQ_BGL: the LU needs to hold the Big Ganeti Lock exclusively
Note that all commands require root permissions.
......@@ -63,7 +62,6 @@ class LogicalUnit(object):
HPATH = None
HTYPE = None
_OP_REQP = []
REQ_BGL = True
def __init__(self, processor, op, context, rpc):
......@@ -96,15 +94,7 @@ class LogicalUnit(object):
if attr_val is None:
raise errors.OpPrereqError("Required parameter '%s' missing" %
if not self.cfg.IsCluster():
raise errors.OpPrereqError("Cluster not initialized yet,"
" use 'gnt-cluster init' first.")
if self.REQ_MASTER:
master = self.cfg.GetMasterNode()
if master != utils.HostInfo().name:
raise errors.OpPrereqError("Commands must be run on the master"
" node %s" % master)
def __GetSSH(self):
"""Returns the SshRunner object
......@@ -116,6 +106,24 @@ class LogicalUnit(object):
ssh = property(fget=__GetSSH)
def CheckArguments(self):
"""Check syntactic validity for the opcode arguments.
This method is for doing a simple syntactic check and ensure
validity of opcode parameters, without any cluster-related
checks. While the same can be accomplished in ExpandNames and/or
CheckPrereq, doing these separate is better because:
- ExpandNames is left as as purely a lock-related function
- CheckPrereq is run after we have aquired locks (and possible
waited for them)
The function is allowed to change the self.op attribute so that
later methods can no longer worry about missing parameters.
def ExpandNames(self):
"""Expand names for this LU.
......@@ -1947,7 +1955,6 @@ class LUQueryClusterInfo(NoHooksLU):
_OP_REQP = []
REQ_BGL = False
def ExpandNames(self):
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