Commit cc27265e authored by René Nussbaumer's avatar René Nussbaumer

gnt-instance reboot start instance if not yet started

This patch starts the instance when gnt-instance reboot is invoked on a
instance already stopped.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent effb49b4
......@@ -5231,10 +5231,16 @@ class LUInstanceReboot(LogicalUnit):
ignore_secondaries = self.op.ignore_secondaries
reboot_type = self.op.reboot_type
remote_info = self.rpc.call_instance_info(instance.primary_node,
instance.name,
instance.hypervisor)
remote_info.Raise("Error checking node %s" % instance.primary_node)
instance_running = bool(remote_info.payload)
node_current = instance.primary_node
if reboot_type in [constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD]:
if instance_running and reboot_type in [constants.INSTANCE_REBOOT_SOFT,
constants.INSTANCE_REBOOT_HARD]:
for disk in instance.disks:
self.cfg.SetDiskID(disk, node_current)
result = self.rpc.call_instance_reboot(node_current, instance,
......@@ -5242,10 +5248,14 @@ class LUInstanceReboot(LogicalUnit):
self.op.shutdown_timeout)
result.Raise("Could not reboot instance")
else:
result = self.rpc.call_instance_shutdown(node_current, instance,
self.op.shutdown_timeout)
result.Raise("Could not shutdown instance for full reboot")
_ShutdownInstanceDisks(self, instance)
if instance_running:
result = self.rpc.call_instance_shutdown(node_current, instance,
self.op.shutdown_timeout)
result.Raise("Could not shutdown instance for full reboot")
_ShutdownInstanceDisks(self, instance)
else:
self.LogInfo("Instance %s was already stopped, starting now",
instance.name)
_StartInstanceDisks(self, instance, ignore_secondaries)
result = self.rpc.call_instance_start(node_current, instance, None, None)
msg = result.fail_msg
......
......@@ -34,7 +34,7 @@ import qa_config
import qa_utils
import qa_error
from qa_utils import AssertIn, AssertCommand
from qa_utils import AssertIn, AssertCommand, AssertEqual
def _GetDiskStatePath(disk):
......@@ -104,6 +104,15 @@ def TestInstanceReboot(instance):
for rtype in reboot_types:
AssertCommand(["gnt-instance", "reboot", "--type=%s" % rtype, name])
AssertCommand(["gnt-instance", "shutdown", name])
AssertCommand(["gnt-instance", "reboot", name])
master = qa_config.GetMasterNode()
cmd = ["gnt-instance", "list", "--no-header", "-o", "status", name]
result_output = qa_utils.GetCommandOutput(master["primary"],
utils.ShellQuoteArgs(cmd))
AssertEqual(result_output.strip(), constants.INSTST_RUNNING)
def TestInstanceReinstall(instance):
"""gnt-instance reinstall"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment