Skip to content
Snippets Groups Projects
Commit 579d4337 authored by Alexander Schreiber's avatar Alexander Schreiber
Browse files

Patch series for reboot feature, part 3

This patch series implements the reboot command for gnt-instance. It
supports three types of reboot: soft (hypervisor reboot), hard (instance
config rebuild and reboot) and full (full instance shutdown and startup
again).

This patch contains the gnt-instance script and the man page for it.

Reviewed-by: iustinp
parent bf6929a2
No related branches found
No related tags found
No related merge requests found
......@@ -583,6 +583,72 @@
</para>
</refsect3>
<refsect3>
<title>REBOOT</title>
<cmdsynopsis>
<command>reboot</command>
<sbr>
<arg>--extra=<replaceable>PARAMS</replaceable></arg>
<sbr>
<arg>--type=<replaceable>REBOOT-TYPE</replaceable></arg>
<sbr>
<arg>--ignore-secondaries</arg>
<sbr>
<arg>--force-multiple</arg>
<sbr>
<group choice="opt">
<arg>--instance</arg>
<arg>--node</arg>
<arg>--primary</arg>
<arg>--secondary</arg>
<arg>--all</arg>
</group>
<sbr>
<arg choice="opt"
rep="repeat"><replaceable>name</replaceable></arg>
</cmdsynopsis>
<para>
Reboots one or more instances. The type of reboot depends on
the value of <option>--type</option>. A soft reboot does a
hypervisor reboot, a hard reboot does a instance stop,
recreates the hypervisor config for the instance and
starts the instance. A full reboot does the equivalent
of <command>gnt-instance shutdown &amp;&amp; gnt-instance
startup</command>. The default is soft reboot.
</para>
<para>
For the hard reboot the option
<option>--ignore-secondaries</option> ignores errors for the
secondary node while re-assembling the instance disks.
</para>
<para>
The <option>--instance</option>, <option>--node</option>,
<option>--primary</option>, <option>--secondary</option> and
<option>--all</option> options are similar as for the
<command>startup</command> command and they influence the
actual instances being rebooted.
</para>
<para>
Use the <option>--force-multiple</option> to keep
gnt-instance from asking for confirmation when more than one
instance is affected.
</para>
<para>
Example:
<screen>
# gnt-instance reboot instance1.example.com
# gnt-instance reboot --type=full instance1.example.com
</screen>
</para>
</refsect3>
<refsect3>
<title>CONSOLE</title>
<cmdsynopsis>
......
......@@ -346,6 +346,28 @@ def StartupInstance(opts, args):
SubmitOpCode(op)
return 0
def RebootInstance(opts, args):
"""Reboot an instance
Args:
opts - class with options as members
args - list containing a single element, the instance name
"""
if opts.multi_mode is None:
opts.multi_mode = _SHUTDOWN_INSTANCES
inames = _ExpandMultiNames(opts.multi_mode, args)
multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1
if not (opts.force_multi or not multi_on
or _ConfirmOperation(inames, "reboot")):
return 1
for name in inames:
op = opcodes.OpRebootInstance(instance_name=name,
reboot_type=opts.reboot_type,
ignore_secondaries=opts.ignore_secondaries)
SubmitOpCode(op)
return 0
def ShutdownInstance(opts, args):
"""Shutdown an instance.
......@@ -757,6 +779,23 @@ commands = {
m_clust_opt, m_inst_opt,
],
"<instance>", "Starts an instance"),
'reboot': (RebootInstance, ARGS_ANY,
[DEBUG_OPT, m_force_multi,
make_option("-e", "--extra", dest="extra_args",
help="Extra arguments for the instance's kernel",
default=None, type="string", metavar="<PARAMS>"),
make_option("-t", "--type", dest="reboot_type",
help="Type of reboot: soft/hard/full",
default=constants.INSTANCE_REBOOT_SOFT,
type="string", metavar="<REBOOT>"),
make_option("--ignore-secondaries", dest="ignore_secondaries",
default=False, action="store_true",
help="Ignore errors from secondaries"),
m_node_opt, m_pri_node_opt, m_sec_node_opt,
m_clust_opt, m_inst_opt,
],
"<instance>", "Reboots an instance"),
'activate-disks': (ActivateDisks, ARGS_ONE, [DEBUG_OPT],
"<instance>",
"Activate an instance's disks"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment