Commit 489fcbe9 authored by Iustin Pop's avatar Iustin Pop
Browse files

Switch the instance_reboot rpc to (status, data)

This small patch changes the return type from this RPC call to include
status information and renames the backend method to match the RPC call

Reviewed-by: ultrotter
parent aed77cea
......@@ -446,7 +446,7 @@ class NodeHttpServer(http.server.HttpServer):
instance = objects.Instance.FromDict(params[0])
reboot_type = params[1]
extra_args = params[2]
return backend.RebootInstance(instance, reboot_type, extra_args)
return backend.InstanceReboot(instance, reboot_type, extra_args)
def perspective_instance_info(params):
......@@ -939,7 +939,7 @@ def ShutdownInstance(instance):
return True
def RebootInstance(instance, reboot_type, extra_args):
def InstanceReboot(instance, reboot_type, extra_args):
"""Reboot an instance.
@type instance: L{objects.Instance}
......@@ -961,27 +961,30 @@ def RebootInstance(instance, reboot_type, extra_args):
running_instances = GetInstanceList([instance.hypervisor])
if not in running_instances:
logging.error("Cannot reboot instance that is not running")
return False
msg = "Cannot reboot instance %s that is not running" %
return (False, msg)
hyper = hypervisor.GetHypervisor(instance.hypervisor)
if reboot_type == constants.INSTANCE_REBOOT_SOFT:
except errors.HypervisorError, err:
logging.exception("Failed to soft reboot instance")
return False
msg = "Failed to soft reboot instance %s: %s" % (, err)
return (False, msg)
elif reboot_type == constants.INSTANCE_REBOOT_HARD:
StartInstance(instance, extra_args)
except errors.HypervisorError, err:
logging.exception("Failed to hard reboot instance")
return False
msg = "Failed to hard reboot instance %s: %s" % (, err)
return (False, msg)
raise errors.ParameterError("reboot_type invalid")
return (False, "Invalid reboot_type received: %s" % (reboot_type,))
return True
return (True, "Reboot successful")
def MigrationInfo(instance):
......@@ -2792,8 +2792,9 @@ class LURebootInstance(LogicalUnit):
result = self.rpc.call_instance_reboot(node_current, instance,
reboot_type, extra_args)
if result.failed or not
raise errors.OpExecError("Could not reboot instance")
msg = result.RemoteFailMsg()
if msg:
raise errors.OpExecError("Could not reboot instance: %s" % msg)
if not self.rpc.call_instance_shutdown(node_current, instance):
raise errors.OpExecError("could not shutdown instance for full reboot")
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