cmd.append("--verbose")
if not options.ssh_key_check:
cmd.append("--no-ssh-key-check")
+ if options.force_join:
+ cmd.append("--force-join")
cmd.extend(nodes)
readd = opts.readd
try:
- output = cl.QueryNodes(names=[node], fields=['name', 'sip'],
+ output = cl.QueryNodes(names=[node], fields=['name', 'sip', 'master'],
use_locking=False)
- node_exists, sip = output[0]
+ node_exists, sip, is_master = output[0]
except (errors.OpPrereqError, errors.OpExecError):
node_exists = ""
sip = None
ToStderr("Node %s not in the cluster"
" - please retry without '--readd'", node)
return 1
+ if is_master:
+ ToStderr("Node %s is the master, cannot readd", node)
+ return 1
else:
if node_exists:
ToStderr("Node %s already in the cluster (as %s)"
return GenericList(constants.QR_NODE, selected_fields, args, opts.units,
opts.separator, not opts.no_headers,
- format_override=fmtoverride)
+ format_override=fmtoverride, verbose=opts.verbose)
def ListNodeFields(opts, args):
opcodelist = []
if oob_command == constants.OOB_POWER_OFF:
- opcodelist.append(opcodes.OpSetNodeParams(node_name=node, offline=True,
+ opcodelist.append(opcodes.OpNodeSetParams(node_name=node, offline=True,
auto_promote=opts.auto_promote))
- opcodelist.append(opcodes.OpOobCommand(node_name=node, command=oob_command))
+ opcodelist.append(opcodes.OpOobCommand(node_names=[node],
+ command=oob_command))
cli.SetGenericOpcodeOpts(opcodelist, opts)
result = cli.PollJob(job_id)[-1]
if result:
- if oob_command == constants.OOB_POWER_STATUS:
- text = "The machine is %spowered"
- if result[constants.OOB_POWER_STATUS_POWERED]:
- result = text % ""
+ (_, data_tuple) = result[0]
+ if data_tuple[0] != constants.RS_NORMAL:
+ if data_tuple[0] == constants.RS_UNAVAIL:
+ result = "OOB is not supported"
else:
- result = text % "not "
- ToStderr(result)
+ result = "RPC failed, look out for warning in the output"
+ ToStderr(result)
+ return constants.EXIT_FAILURE
+ else:
+ if oob_command == constants.OOB_POWER_STATUS:
+ text = "The machine is %spowered"
+ if data_tuple[1][constants.OOB_POWER_STATUS_POWERED]:
+ result = text % ""
+ else:
+ result = text % "not "
+ ToStdout(result)
return constants.EXIT_SUCCESS
ToStderr("Please give at least one of the parameters.")
return 1
- op = opcodes.OpSetNodeParams(node_name=args[0],
+ op = opcodes.OpNodeSetParams(node_name=args[0],
master_candidate=opts.master_candidate,
offline=opts.offline,
drained=opts.drained,
commands = {
'add': (
AddNode, [ArgHost(min=1, max=1)],
- [SECONDARY_IP_OPT, READD_OPT, NOSSH_KEYCHECK_OPT, NONODE_SETUP_OPT,
- VERBOSE_OPT, NODEGROUP_OPT, PRIORITY_OPT, CAPAB_MASTER_OPT,
- CAPAB_VM_OPT, NODE_PARAMS_OPT],
- "[-s ip] [--readd] [--no-ssh-key-check] [--no-node-setup] [--verbose] "
+ [SECONDARY_IP_OPT, READD_OPT, NOSSH_KEYCHECK_OPT, NODE_FORCE_JOIN_OPT,
+ NONODE_SETUP_OPT, VERBOSE_OPT, NODEGROUP_OPT, PRIORITY_OPT,
+ CAPAB_MASTER_OPT, CAPAB_VM_OPT, NODE_PARAMS_OPT],
+ "[-s ip] [--readd] [--no-ssh-key-check] [--force-join]"
+ " [--no-node-setup] [--verbose]"
" <node_name>",
"Add a node to the cluster"),
'evacuate': (
"[<node_name>...]", "Show information about the node(s)"),
'list': (
ListNodes, ARGS_MANY_NODES,
- [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT],
+ [NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT, VERBOSE_OPT],
"[nodes...]",
"Lists the nodes in the cluster. The available fields can be shown using"
" the \"list-fields\" command (see the man page for details)."