"""
instance = args[0]
+ (pnode, snode) = SplitNodeOption(opts.node)
+
op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem,
disk_size=opts.size, swap_size=opts.swap,
disk_template=opts.disk_template,
mode=constants.INSTANCE_CREATE,
- os_type=opts.os, pnode=opts.node,
- snode=opts.snode, vcpus=opts.vcpus,
+ os_type=opts.os, pnode=pnode,
+ snode=snode, vcpus=opts.vcpus,
ip=opts.ip, bridge=opts.bridge,
start=opts.start, ip_check=opts.ip_check,
wait_for_sync=opts.wait_for_sync)
force - whether to failover without asking questions.
"""
- if opts.multi_mode is None:
- opts.multi_mode = _SHUTDOWN_INSTANCES
- inames = _ExpandMultiNames(opts.multi_mode, args)
- if not inames:
- raise errors.OpPrereqError("Selection filter does not match any instances")
- multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
- if not (opts.force_multi or not multi_on
- or _ConfirmOperation(inames, "failover (including shutdown)")):
- return 1
+ instance_name = args[0]
+ force = opts.force
- result = 0
- for name in inames:
- op = opcodes.OpFailoverInstance(instance_name=name,
- ignore_consistency=opts.ignore_consistency)
- if multi_on:
- logger.ToStdout("Failing over instance %s" % name)
- try:
- SubmitOpCode(op)
- except errors.OpExecError, err:
- result = 1
- _, err_msg = FormatError(err)
- logger.ToStderr(err_msg)
+ if not force:
+ usertext = ("Failover will happen to image %s."
+ " This requires a shutdown of the instance. Continue?" %
+ (instance_name,))
+ if not AskUser(usertext):
+ return 1
- return result
+ op = opcodes.OpFailoverInstance(instance_name=instance_name,
+ ignore_consistency=opts.ignore_consistency)
+ SubmitOpCode(op)
+ return 0
def ConnectToInstanceConsole(opts, args):
if not status:
buf.write("not active\n")
else:
- (path, major, minor, syncp, estt, degr) = status
+ (path, major, minor, syncp, estt, degr, ldisk) = status
buf.write("%s (%d:%d)" % (path, major, minor))
if dtype in (constants.LD_MD_R1, constants.LD_DRBD7, constants.LD_DRBD8):
if syncp is not None:
degr_text = "*DEGRADED*"
else:
degr_text = "ok"
- buf.write(" %s, status %s" % (sync_text, degr_text))
+ if ldisk:
+ ldisk_text = " *MISSING DISK*"
+ else:
+ ldisk_text = ""
+ buf.write(" %s, status %s%s" % (sync_text, degr_text, ldisk_text))
+ elif dtype == constants.LD_LV:
+ if ldisk:
+ ldisk_text = " *FAILED* (failed drive?)"
+ else:
+ ldisk_text = ""
+ buf.write(ldisk_text)
buf.write("\n")
if dev["iv_name"] is not None:
# this is defined separately due to readability only
add_opts = [
DEBUG_OPT,
- node_opt,
+ make_option("-n", "--node", dest="node",
+ help="Target node and optional secondary node",
+ metavar="<pnode>[:<snode>]"),
cli_option("-s", "--os-size", dest="size", help="Disk size, in MiB unless"
" a suffix is used",
default=20 * 1024, type="unit", metavar="<size>"),
default='none', type="string", metavar="<ADDRESS>"),
make_option("--no-wait-for-sync", dest="wait_for_sync", default=True,
action="store_false", help="Don't wait for sync (DANGEROUS!)"),
- make_option("--secondary-node", dest="snode",
- help="Secondary node for remote_raid1 disk layout",
- metavar="<node>"),
make_option("-b", "--bridge", dest="bridge",
help="Bridge to connect this instance to",
default=None, metavar="<bridge>"),
'console': (ConnectToInstanceConsole, ARGS_ONE, [DEBUG_OPT],
"<instance>",
"Opens a console on the specified instance"),
- 'failover': (FailoverInstance, ARGS_ATLEAST(1),
+ 'failover': (FailoverInstance, ARGS_ONE,
[DEBUG_OPT, FORCE_OPT,
make_option("--ignore-consistency", dest="ignore_consistency",
action="store_true", default=False,
help="Ignore the consistency of the disks on"
" the secondary"),
- m_pri_node_opt, m_sec_node_opt, m_inst_opt, m_force_multi,
],
"[-f] <instance>",
"Stops the instance and starts it on the backup node, using"