Commit afee0879 authored by Iustin Pop's avatar Iustin Pop
Browse files

Introduce a very simple LU to force config updates

This LU can be used to force a push of the config in case it's needed,
for example after an upgrade to update the ssconf_release_version file.

Reviewed-by: imsnah
parent 8a113c7a
......@@ -1437,6 +1437,33 @@ class LUSetClusterParams(LogicalUnit):
_AdjustCandidatePool(self)
class LURedistributeConfig(NoHooksLU):
"""Force the redistribution of cluster configuration.
This is a very simple LU.
"""
_OP_REQP = []
REQ_BGL = False
def ExpandNames(self):
self.needed_locks = {
locking.LEVEL_NODE: locking.ALL_SET,
}
self.share_locks[locking.LEVEL_NODE] = 1
def CheckPrereq(self):
"""Check prerequisites.
"""
def Exec(self, feedback_fn):
"""Redistribute the configuration.
"""
self.cfg.Update(self.cfg.GetClusterInfo())
def _WaitForSync(lu, instance, oneshot=False, unlock=False):
"""Sleep and poll for an instance's disk to sync.
......
......@@ -49,6 +49,7 @@ class Processor(object):
opcodes.OpRenameCluster: cmdlib.LURenameCluster,
opcodes.OpVerifyDisks: cmdlib.LUVerifyDisks,
opcodes.OpSetClusterParams: cmdlib.LUSetClusterParams,
opcodes.OpRedistributeConfig: cmdlib.LURedistributeConfig,
# node lu
opcodes.OpAddNode: cmdlib.LUAddNode,
opcodes.OpQueryNodes: cmdlib.LUQueryNodes,
......
......@@ -171,6 +171,8 @@ class OpCode(BaseOpCode):
return txt
# cluster opcodes
class OpDestroyCluster(OpCode):
"""Destroy the cluster.
......@@ -264,6 +266,14 @@ class OpSetClusterParams(OpCode):
]
class OpRedistributeConfig(OpCode):
"""Force a full push of the cluster configuration.
"""
OP_ID = "OP_CLUSTER_REDIST_CONF"
__slots__ = [
]
# node opcodes
class OpRemoveNode(OpCode):
......
......@@ -177,6 +177,21 @@ def RenameCluster(opts, args):
return 0
def RedistributeConfig(opts, args):
"""Forces push of the cluster configuration.
@param opts: the command line options selected by the user
@type args: list
@param args: empty list
@rtype: int
@return: the desired exit code
"""
op = opcodes.OpRedistributeConf()
SubmitOrSend(op, opts)
return 0
def ShowClusterVersion(opts, args):
"""Write version of ganeti software to the standard output.
......@@ -589,6 +604,10 @@ commands = {
'rename': (RenameCluster, ARGS_ONE, [DEBUG_OPT, FORCE_OPT],
"<new_name>",
"Renames the cluster"),
'redist-conf': (RedistributeConfig, ARGS_NONE, [DEBUG_OPT, SUBMIT_OPT],
"",
"Forces a push of the configuration file and ssconf files"
" to the nodes in the cluster"),
'verify': (VerifyCluster, ARGS_NONE, [DEBUG_OPT,
make_option("--no-nplus1-mem", dest="skip_nplusone_mem",
help="Skip N+1 memory redundancy tests",
......
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