Commit 5fbbd028 authored by Guido Trotter's avatar Guido Trotter
Browse files

Add nodegroup option to AddNode


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 36e247e1
......@@ -99,6 +99,7 @@ __all__ = [
"NIC_PARAMS_OPT",
"NODE_LIST_OPT",
"NODE_PLACEMENT_OPT",
"NODEGROUP_OPT",
"NODRBD_STORAGE_OPT",
"NOHDR_OPT",
"NOIPCHECK_OPT",
......@@ -737,6 +738,13 @@ NODE_LIST_OPT = cli_option("-n", "--node", dest="nodes", default=[],
" times, if not given defaults to all nodes)",
completion_suggest=OPT_COMPL_ONE_NODE)
NODEGROUP_OPT = cli_option("-g", "--nodegroup",
dest="nodegroup",
help="Node group (name or uuid)",
metavar="<nodegroup>",
default=None, type="string",
completion_suggest=OPT_COMPL_ONE_NODEGROUP)
SINGLE_NODE_OPT = cli_option("-n", "--node", dest="node", help="Target node",
metavar="<node>",
completion_suggest=OPT_COMPL_ONE_NODE)
......
......@@ -3668,6 +3668,7 @@ class LUAddNode(LogicalUnit):
("primary_ip", None, _NoType),
("secondary_ip", None, _TMaybeString),
("readd", False, _TBool),
("nodegroup", None, _TMaybeString)
]
def CheckArguments(self):
......@@ -3676,6 +3677,9 @@ class LUAddNode(LogicalUnit):
self.hostname = netutils.GetHostname(name=self.op.node_name,
family=self.primary_ip_family)
self.op.node_name = self.hostname.name
if self.op.readd and self.op.nodegroup:
raise errors.OpPrereqError("Cannot pass a nodegroup when a node is"
" being readded", errors.ECODE_INVAL)
def BuildHooksEnv(self):
"""Build hooks env.
......@@ -3790,8 +3794,7 @@ class LUAddNode(LogicalUnit):
self.new_node = self.cfg.GetNodeInfo(node)
assert self.new_node is not None, "Can't retrieve locked node %s" % node
else:
# TODO: process an arbitrary non-default nodegroup
nodegroup = cfg.LookupNodeGroup(None)
nodegroup = cfg.LookupNodeGroup(self.op.nodegroup)
self.new_node = objects.Node(name=node,
primary_ip=primary_ip,
secondary_ip=secondary_ip,
......
......@@ -363,7 +363,7 @@ class OpAddNode(OpCode):
"""
OP_ID = "OP_NODE_ADD"
OP_DSC_FIELD = "node_name"
__slots__ = ["node_name", "primary_ip", "secondary_ip", "readd"]
__slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "nodegroup"]
class OpQueryNodes(OpCode):
......
......@@ -64,6 +64,7 @@
<command>add</command>
<arg>--readd</arg>
<arg>-s <replaceable>secondary_ip</replaceable></arg>
<arg>-g <replaceable>nodegroup</replaceable></arg>
<arg choice="req"><replaceable>nodename</replaceable></arg>
</cmdsynopsis>
......@@ -103,11 +104,18 @@
before re-adding it.
</para>
<para>
The <option>-g</option> is used to add the new node into a specific
node group, specified by uuid or name. If only one node group exists
you can skip this option, otherwise it's mandatory.
</para>
<para>
Example:
<screen>
# gnt-node add node5.example.com
# gnt-node add -s 192.0.2.5 node5.example.com
# gnt-node add -g group2 -s 192.0.2.9 node9.group2.example.com
</screen>
</para>
</refsect2>
......
......@@ -214,7 +214,7 @@ def AddNode(opts, args):
bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
op = opcodes.OpAddNode(node_name=args[0], secondary_ip=sip,
readd=opts.readd)
readd=opts.readd, nodegroup=opts.nodegroup)
SubmitOpCode(op, opts=opts)
......@@ -674,7 +674,7 @@ commands = {
'add': (
AddNode, [ArgHost(min=1, max=1)],
[SECONDARY_IP_OPT, READD_OPT, NOSSH_KEYCHECK_OPT, NONODE_SETUP_OPT,
VERBOSE_OPT],
VERBOSE_OPT, NODEGROUP_OPT],
"[-s ip] [--readd] [--no-ssh-key-check] [--no-node-setup] [--verbose] "
" <node_name>",
"Add a node to the cluster"),
......
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