#
#
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
constants.OOB_POWER_CYCLE])
+_ENV_OVERRIDE = frozenset(["list"])
+
+
NONODE_SETUP_OPT = cli_option("--no-node-setup", default=True,
action="store_false", dest="node_setup",
help=("Do not make initial SSH setup on remote"
bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
+ if opts.disk_state:
+ disk_state = utils.FlatToDict(opts.disk_state)
+ else:
+ disk_state = {}
+
+ hv_state = dict(opts.hv_state)
+
op = opcodes.OpNodeAdd(node_name=args[0], secondary_ip=sip,
readd=opts.readd, group=opts.nodegroup,
vm_capable=opts.vm_capable, ndparams=opts.ndparams,
- master_capable=opts.master_capable)
+ master_capable=opts.master_capable,
+ disk_state=disk_state,
+ hv_state=hv_state)
SubmitOpCode(op, opts=opts)
" --secondary-only options can be passed",
errors.ECODE_INVAL)
elif opts.primary_only:
- mode = constants.IALLOCATOR_NEVAC_PRI
+ mode = constants.NODE_EVAC_PRI
elif opts.secondary_only:
- mode = constants.IALLOCATOR_NEVAC_SEC
+ mode = constants.NODE_EVAC_SEC
else:
- mode = constants.IALLOCATOR_NEVAC_ALL
+ mode = constants.NODE_EVAC_ALL
# Determine affected instances
fields = []
op = opcodes.OpNodeMigrate(node_name=args[0], mode=mode,
iallocator=opts.iallocator,
- target_node=opts.dst_node)
+ target_node=opts.dst_node,
+ allow_runtime_changes=opts.allow_runtime_chgs,
+ ignore_ipolicy=opts.ignore_ipolicy)
result = SubmitOpCode(op, cl=cl, opts=opts)
all_changes = [opts.master_candidate, opts.drained, opts.offline,
opts.master_capable, opts.vm_capable, opts.secondary_ip,
opts.ndparams]
- if all_changes.count(None) == len(all_changes):
+ if (all_changes.count(None) == len(all_changes) and
+ not (opts.hv_state or opts.disk_state)):
ToStderr("Please give at least one of the parameters.")
return 1
+ if opts.disk_state:
+ disk_state = utils.FlatToDict(opts.disk_state)
+ else:
+ disk_state = {}
+
+ hv_state = dict(opts.hv_state)
+
op = opcodes.OpNodeSetParams(node_name=args[0],
master_candidate=opts.master_candidate,
offline=opts.offline,
force=opts.force,
ndparams=opts.ndparams,
auto_promote=opts.auto_promote,
- powered=opts.node_powered)
+ powered=opts.node_powered,
+ hv_state=hv_state,
+ disk_state=disk_state)
# even if here we process the result, we allow submit only
result = SubmitOrSend(op, opts)
AddNode, [ArgHost(min=1, max=1)],
[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],
+ CAPAB_MASTER_OPT, CAPAB_VM_OPT, NODE_PARAMS_OPT, HV_STATE_OPT,
+ DISK_STATE_OPT],
"[-s ip] [--readd] [--no-ssh-key-check] [--force-join]"
" [--no-node-setup] [--verbose]"
" <node_name>",
EvacuateNode, ARGS_ONE_NODE,
[FORCE_OPT, IALLOCATOR_OPT, NEW_SECONDARY_OPT, EARLY_RELEASE_OPT,
PRIORITY_OPT, PRIMARY_ONLY_OPT, SECONDARY_ONLY_OPT],
- "[-f] {-I <iallocator> | -n <dst>} <node>",
- "Relocate the secondary instances from a node"
- " to other nodes"),
+ "[-f] {-I <iallocator> | -n <dst>} [-p | -s] [options...] <node>",
+ "Relocate the primary and/or secondary instances from a node"),
"failover": (
FailoverNode, ARGS_ONE_NODE, [FORCE_OPT, IGNORE_CONSIST_OPT,
IALLOCATOR_OPT, PRIORITY_OPT],
"migrate": (
MigrateNode, ARGS_ONE_NODE,
[FORCE_OPT, NONLIVE_OPT, MIGRATION_MODE_OPT, DST_NODE_OPT,
- IALLOCATOR_OPT, PRIORITY_OPT],
+ IALLOCATOR_OPT, PRIORITY_OPT, IGNORE_IPOLICY_OPT,
+ NORUNTIME_CHGS_OPT],
"[-f] <node>",
"Migrate all the primary instance on a node away from it"
" (only for instances of type drbd)"),
[FORCE_OPT, SUBMIT_OPT, MC_OPT, DRAINED_OPT, OFFLINE_OPT,
CAPAB_MASTER_OPT, CAPAB_VM_OPT, SECONDARY_IP_OPT,
AUTO_PROMOTE_OPT, DRY_RUN_OPT, PRIORITY_OPT, NODE_PARAMS_OPT,
- NODE_POWERED_OPT],
+ NODE_POWERED_OPT, HV_STATE_OPT, DISK_STATE_OPT],
"<node_name>", "Alters the parameters of a node"),
"powercycle": (
PowercycleNode, ARGS_ONE_NODE,
ListTags, ARGS_ONE_NODE, [],
"<node_name>", "List the tags of the given node"),
"add-tags": (
- AddTags, [ArgNode(min=1, max=1), ArgUnknown()], [TAG_SRC_OPT, PRIORITY_OPT],
+ AddTags, [ArgNode(min=1, max=1), ArgUnknown()],
+ [TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT],
"<node_name> tag...", "Add tags to the given node"),
"remove-tags": (
RemoveTags, [ArgNode(min=1, max=1), ArgUnknown()],
- [TAG_SRC_OPT, PRIORITY_OPT],
+ [TAG_SRC_OPT, PRIORITY_OPT, SUBMIT_OPT],
"<node_name> tag...", "Remove tags from the given node"),
"health": (
Health, ARGS_MANY_NODES,
- [NOHDR_OPT, SEP_OPT, SUBMIT_OPT, PRIORITY_OPT, OOB_TIMEOUT_OPT],
+ [NOHDR_OPT, SEP_OPT, PRIORITY_OPT, OOB_TIMEOUT_OPT],
"[<node_name>...]", "List health of node(s) using out-of-band"),
}
+#: dictionary with aliases for commands
+aliases = {
+ "show": "info",
+ }
+
def Main():
- return GenericMain(commands, override={"tag_type": constants.TAG_NODE})
+ return GenericMain(commands, aliases=aliases,
+ override={"tag_type": constants.TAG_NODE},
+ env_override=_ENV_OVERRIDE)