diff --git a/lib/backend.py b/lib/backend.py index c0b5467649b44a1d35b14e0f1df4cecfab10004e..09a5b889252883003ef11c322a12f923daf0993a 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -845,7 +845,7 @@ def StartInstance(instance, extra_args): running_instances = GetInstanceList([instance.hypervisor]) if instance.name in running_instances: - return True + return (True, "Already running") try: block_devices = _GatherAndLinkBlockDevs(instance) @@ -853,13 +853,13 @@ def StartInstance(instance, extra_args): hyper.StartInstance(instance, block_devices, extra_args) except errors.BlockDeviceError, err: logging.exception("Failed to start instance") - return False + return (False, "Block device error: %s" % str(err)) except errors.HypervisorError, err: logging.exception("Failed to start instance") _RemoveBlockDevLinks(instance.name, instance.disks) - return False + return (False, "Hypervisor error: %s" % str(err)) - return True + return (True, "Instance started successfully") def ShutdownInstance(instance): diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c639dd39b13c394dc823d7f78a174425921018ed..6a58548a745dfb1b5dac55bc07839e62f5ed48ca 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2627,9 +2627,10 @@ class LUStartupInstance(LogicalUnit): _StartInstanceDisks(self, instance, force) result = self.rpc.call_instance_start(node_current, instance, extra_args) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: _ShutdownInstanceDisks(self, instance) - raise errors.OpExecError("Could not start instance") + raise errors.OpExecError("Could not start instance: %s" % msg) class LURebootInstance(LogicalUnit): @@ -2702,9 +2703,11 @@ class LURebootInstance(LogicalUnit): _ShutdownInstanceDisks(self, instance) _StartInstanceDisks(self, instance, ignore_secondaries) result = self.rpc.call_instance_start(node_current, instance, extra_args) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: _ShutdownInstanceDisks(self, instance) - raise errors.OpExecError("Could not start instance for full reboot") + raise errors.OpExecError("Could not start instance for" + " full reboot: %s" % msg) self.cfg.MarkInstanceUp(instance.name) @@ -3373,10 +3376,11 @@ class LUFailoverInstance(LogicalUnit): feedback_fn("* starting the instance on the target node") result = self.rpc.call_instance_start(target_node, instance, None) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: _ShutdownInstanceDisks(self, instance) - raise errors.OpExecError("Could not start instance %s on node %s." % - (instance.name, target_node)) + raise errors.OpExecError("Could not start instance %s on node %s: %s" % + (instance.name, target_node, msg)) class LUMigrateInstance(LogicalUnit): @@ -4537,9 +4541,9 @@ class LUCreateInstance(LogicalUnit): logging.info("Starting instance %s on node %s", instance, pnode_name) feedback_fn("* starting instance...") result = self.rpc.call_instance_start(pnode_name, iobj, None) - result.Raise() - if not result.data: - raise errors.OpExecError("Could not start instance") + msg = result.RemoteFailMsg() + if msg: + raise errors.OpExecError("Could not start instance: %s" % msg) class LUConnectConsole(NoHooksLU): @@ -5905,9 +5909,10 @@ class LUExportInstance(LogicalUnit): finally: if self.op.shutdown and instance.status == "up": result = self.rpc.call_instance_start(src_node, instance, None) - if result.failed or not result.data: + msg = result.RemoteFailMsg() + if msg: _ShutdownInstanceDisks(self, instance) - raise errors.OpExecError("Could not start instance") + raise errors.OpExecError("Could not start instance: %s" % msg) # TODO: check for size