Revision 36c87212
b/man/gnt-instance.sgml | ||
---|---|---|
633 | 633 |
<command>startup</command> command and they influence the |
634 | 634 |
actual instances being rebooted. |
635 | 635 |
</para> |
636 |
|
|
636 |
|
|
637 | 637 |
<para> |
638 | 638 |
Use the <option>--force-multiple</option> to keep |
639 | 639 |
gnt-instance from asking for confirmation when more than one |
... | ... | |
799 | 799 |
<command>failover</command> |
800 | 800 |
<arg>-f</arg> |
801 | 801 |
<arg>--ignore-consistency</arg> |
802 |
<arg choice="req"><replaceable>instance</replaceable></arg> |
|
802 |
<sbr> |
|
803 |
<group choice="opt"> |
|
804 |
<arg>--instance</arg> |
|
805 |
<arg>--primary</arg> |
|
806 |
<arg>--secondary</arg> |
|
807 |
</group> |
|
808 |
<sbr> |
|
809 |
<arg choice="req" rep="repeat"><replaceable>name</replaceable></arg> |
|
803 | 810 |
</cmdsynopsis> |
804 | 811 |
|
805 | 812 |
<para> |
806 |
Failover will fail the instance over its secondary
|
|
813 |
Failover will fail the selected instances to their secondary
|
|
807 | 814 |
node. This works only for instances having a remote raid |
808 | 815 |
disk layout. |
809 | 816 |
</para> |
810 | 817 |
|
811 | 818 |
<para> |
819 |
The selection of which instances to failover is done via the |
|
820 |
following options: |
|
821 |
<variablelist> |
|
822 |
<varlistentry> |
|
823 |
<term><option>--instance</option></term> |
|
824 |
<listitem> |
|
825 |
<simpara>will select the instances given as arguments |
|
826 |
(at least one argument required); this is the default |
|
827 |
selection</simpara> |
|
828 |
</listitem> |
|
829 |
</varlistentry> |
|
830 |
<varlistentry> |
|
831 |
<term><option>--primary</option></term> |
|
832 |
<listitem> |
|
833 |
<simpara>will select all instances whose primary node |
|
834 |
is in the list of nodes passed as arguments (at least |
|
835 |
one node required)</simpara> |
|
836 |
</listitem> |
|
837 |
</varlistentry> |
|
838 |
<varlistentry> |
|
839 |
<term><option>--secondary</option></term> |
|
840 |
<listitem> |
|
841 |
<simpara>will select all instances whose secondary |
|
842 |
node is in the list of nodes passed as arguments (at |
|
843 |
least one node required)</simpara> |
|
844 |
</listitem> |
|
845 |
</varlistentry> |
|
846 |
</variablelist> |
|
847 |
</para> |
|
848 |
|
|
849 |
<para> |
|
812 | 850 |
Normally the failover will check the consistency of the |
813 |
disks before failing over the instance. If you are trying to
|
|
851 |
disks before failing over an instance. If you are trying to
|
|
814 | 852 |
migrate instances off a dead node, this will fail. Use the |
815 | 853 |
<option>--ignore-consistency</option> option for this |
816 | 854 |
purpose. Note that this option can be dangerous as errors in |
... | ... | |
823 | 861 |
Example: |
824 | 862 |
<screen> |
825 | 863 |
# gnt-instance failover instance1.example.com |
864 |
# gnt-instance failover --primary node4.example.com |
|
826 | 865 |
</screen> |
827 | 866 |
</para> |
828 | 867 |
</refsect3> |
b/scripts/gnt-instance | ||
---|---|---|
465 | 465 |
force - whether to failover without asking questions. |
466 | 466 |
|
467 | 467 |
""" |
468 |
instance_name = args[0] |
|
469 |
force = opts.force |
|
468 |
if opts.multi_mode is None: |
|
469 |
opts.multi_mode = _SHUTDOWN_INSTANCES |
|
470 |
inames = _ExpandMultiNames(opts.multi_mode, args) |
|
471 |
if not inames: |
|
472 |
logger.ToStderr("No instances match the selected options") |
|
473 |
return 1 |
|
474 |
multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1 |
|
475 |
if not (opts.force_multi or not multi_on |
|
476 |
or _ConfirmOperation(inames, "failover (including shutdown)")): |
|
477 |
return 1 |
|
470 | 478 |
|
471 |
if not force: |
|
472 |
usertext = ("Failover will happen to image %s." |
|
473 |
" This requires a shutdown of the instance. Continue?" % |
|
474 |
(instance_name,)) |
|
475 |
if not AskUser(usertext): |
|
476 |
return 1 |
|
479 |
result = 0 |
|
480 |
for name in inames: |
|
481 |
op = opcodes.OpFailoverInstance(instance_name=name, |
|
482 |
ignore_consistency=opts.ignore_consistency) |
|
483 |
if multi_on: |
|
484 |
logger.ToStdout("Failing over instance %s" % name) |
|
485 |
try: |
|
486 |
SubmitOpCode(op) |
|
487 |
except errors.OpExecError, err: |
|
488 |
result = 1 |
|
489 |
_, err_msg = FormatError(err) |
|
490 |
logger.ToStderr(err_msg) |
|
477 | 491 |
|
478 |
op = opcodes.OpFailoverInstance(instance_name=instance_name, |
|
479 |
ignore_consistency=opts.ignore_consistency) |
|
480 |
SubmitOpCode(op) |
|
481 |
return 0 |
|
492 |
return result |
|
482 | 493 |
|
483 | 494 |
|
484 | 495 |
def ConnectToInstanceConsole(opts, args): |
... | ... | |
710 | 721 |
'console': (ConnectToInstanceConsole, ARGS_ONE, [DEBUG_OPT], |
711 | 722 |
"<instance>", |
712 | 723 |
"Opens a console on the specified instance"), |
713 |
'failover': (FailoverInstance, ARGS_ONE,
|
|
724 |
'failover': (FailoverInstance, ARGS_ATLEAST(1),
|
|
714 | 725 |
[DEBUG_OPT, FORCE_OPT, |
715 | 726 |
make_option("--ignore-consistency", dest="ignore_consistency", |
716 | 727 |
action="store_true", default=False, |
717 | 728 |
help="Ignore the consistency of the disks on" |
718 | 729 |
" the secondary"), |
730 |
m_pri_node_opt, m_sec_node_opt, m_inst_opt, m_force_multi, |
|
719 | 731 |
], |
720 | 732 |
"[-f] <instance>", |
721 | 733 |
"Stops the instance and starts it on the backup node, using" |
Also available in: Unified diff