Skip to content
Snippets Groups Projects
Commit 05ccd983 authored by Guido Trotter's avatar Guido Trotter
Browse files

AddNode: Check for node existance

In the "new world" we'll need to setup ganeti-noded via ssh on the node
before calling the AddNode opcode. Before doing it we'll check that the
node is not already in the cluster, if --readd was not passed. This
guarantees we're not going to restart ganeti-noded on a running node.

This patch also incidentally fixes a non-style-guide conformant
docstring.

Reviewed-by: iustinp
parent 5c0527ed
No related branches found
No related tags found
No related merge requests found
......@@ -37,11 +37,28 @@ _LIST_DEF_FIELDS = [
]
def AddNode(opts, args):
"""Add node cli-to-processor bridge."""
"""Add node cli-to-processor bridge.
"""
dns_data = utils.HostInfo(args[0])
node = dns_data.name
if not opts.readd:
op = opcodes.OpQueryNodes(output_fields=['name'], names=[node])
try:
output = SubmitOpCode(op)
except (errors.OpPrereqError, errors.OpExecError):
pass
else:
logger.ToStderr("Node %s already in the cluster (as %s)"
" - please use --readd" % (args[0], output[0][0]))
return 1
logger.ToStderr("-- WARNING -- \n"
"Performing this operation is going to replace the ssh daemon keypair\n"
"on the target machine (%s) with the ones of the current one\n"
"and grant full intra-cluster ssh root access to/from it\n" % args[0])
"and grant full intra-cluster ssh root access to/from it\n" % node)
op = opcodes.OpAddNode(node_name=args[0], secondary_ip=opts.secondary_ip,
readd=opts.readd)
SubmitOpCode(op)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment