Revision b31c8676 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1959 | 1959 |
self.context.AddNode(new_node) |
1960 | 1960 |
|
1961 | 1961 |
|
1962 |
class LUSetNodeParams(LogicalUnit): |
|
1963 |
"""Modifies the parameters of a node. |
|
1964 |
|
|
1965 |
""" |
|
1966 |
HPATH = "node-modify" |
|
1967 |
HTYPE = constants.HTYPE_NODE |
|
1968 |
_OP_REQP = ["node_name"] |
|
1969 |
REQ_BGL = False |
|
1970 |
|
|
1971 |
def CheckArguments(self): |
|
1972 |
node_name = self.cfg.ExpandNodeName(self.op.node_name) |
|
1973 |
if node_name is None: |
|
1974 |
raise errors.OpPrereqError("Invalid node name '%s'" % self.op.node_name) |
|
1975 |
self.op.node_name = node_name |
|
1976 |
if not hasattr(self.op, 'master_candidate'): |
|
1977 |
raise errors.OpPrereqError("Please pass at least one modification") |
|
1978 |
self.op.master_candidate = bool(self.op.master_candidate) |
|
1979 |
|
|
1980 |
def ExpandNames(self): |
|
1981 |
self.needed_locks = {locking.LEVEL_NODE: self.op.node_name} |
|
1982 |
|
|
1983 |
def BuildHooksEnv(self): |
|
1984 |
"""Build hooks env. |
|
1985 |
|
|
1986 |
This runs on the master node. |
|
1987 |
|
|
1988 |
""" |
|
1989 |
env = { |
|
1990 |
"OP_TARGET": self.op.node_name, |
|
1991 |
"MASTER_CANDIDATE": str(self.op.master_candidate), |
|
1992 |
} |
|
1993 |
nl = [self.cfg.GetMasterNode(), |
|
1994 |
self.op.node_name] |
|
1995 |
return env, nl, nl |
|
1996 |
|
|
1997 |
def CheckPrereq(self): |
|
1998 |
"""Check prerequisites. |
|
1999 |
|
|
2000 |
This only checks the instance list against the existing names. |
|
2001 |
|
|
2002 |
""" |
|
2003 |
force = self.force = self.op.force |
|
2004 |
|
|
2005 |
return |
|
2006 |
|
|
2007 |
def Exec(self, feedback_fn): |
|
2008 |
"""Modifies a node. |
|
2009 |
|
|
2010 |
""" |
|
2011 |
node = self.cfg.GetNodeInfo(self.op.node_name) |
|
2012 |
|
|
2013 |
result = [] |
|
2014 |
|
|
2015 |
if self.op.master_candidate is not None: |
|
2016 |
node.master_candidate = self.op.master_candidate |
|
2017 |
result.append(("master_candidate", str(self.op.master_candidate))) |
|
2018 |
|
|
2019 |
# this will trigger configuration file update, if needed |
|
2020 |
self.cfg.Update(node) |
|
2021 |
# this will trigger job queue propagation or cleanup |
|
2022 |
self.context.ReaddNode(node) |
|
2023 |
|
|
2024 |
return result |
|
2025 |
|
|
2026 |
|
|
1962 | 2027 |
class LUQueryClusterInfo(NoHooksLU): |
1963 | 2028 |
"""Query cluster configuration. |
1964 | 2029 |
|
Also available in: Unified diff