diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml index af3e26d0a345438f4a276a4cac2a139e553d6e58..ce9eb30403123a5ffeca4b86d263ec5a10db2761 100644 --- a/man/gnt-instance.sgml +++ b/man/gnt-instance.sgml @@ -798,56 +798,18 @@ node1.example.com:sdb:/dev/md1 <command>failover</command> <arg>-f</arg> <arg>--ignore-consistency</arg> - <sbr> - <group choice="opt"> - <arg>--instance</arg> - <arg>--primary</arg> - <arg>--secondary</arg> - </group> - <sbr> - <arg choice="req" rep="repeat"><replaceable>name</replaceable></arg> + <arg choice="req"><replaceable>instance</replaceable></arg> </cmdsynopsis> <para> - Failover will fail the selected instances to their secondary + Failover will fail the instance over its secondary node. This works only for instances having a remote raid disk layout. </para> - <para> - The selection of which instances to failover is done via the - following options: - <variablelist> - <varlistentry> - <term><option>--instance</option></term> - <listitem> - <simpara>will select the instances given as arguments - (at least one argument required); this is the default - selection</simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><option>--primary</option></term> - <listitem> - <simpara>will select all instances whose primary node - is in the list of nodes passed as arguments (at least - one node required)</simpara> - </listitem> - </varlistentry> - <varlistentry> - <term><option>--secondary</option></term> - <listitem> - <simpara>will select all instances whose secondary - node is in the list of nodes passed as arguments (at - least one node required)</simpara> - </listitem> - </varlistentry> - </variablelist> - </para> - <para> Normally the failover will check the consistency of the - disks before failing over an instance. If you are trying to + disks before failing over the instance. If you are trying to migrate instances off a dead node, this will fail. Use the <option>--ignore-consistency</option> option for this purpose. Note that this option can be dangerous as errors in @@ -860,7 +822,6 @@ node1.example.com:sdb:/dev/md1 Example: <screen> # gnt-instance failover instance1.example.com -# gnt-instance failover --primary node4.example.com </screen> </para> </refsect3> diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 231ea19a61479823b935fd051635c482dd49d7d9..ce0df75676cb322925e437c5c342f3531a1a18be 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -471,30 +471,20 @@ def FailoverInstance(opts, args): 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): @@ -726,13 +716,12 @@ commands = { '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"