From fb300fb76fa71004d9aeeb197698fee5e3927dcd Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 2 Apr 2008 18:05:45 +0000 Subject: [PATCH] Improve export and fix export-on-norun bug Currently gnt-backup export chains the ShutdownInstance and StartupInstance opcodes to itself. This works but (a) it's suboptimal, because there's no need to deactivate the instance's disks as we are about to restart it anyway, and (b) doesn't take care of instances which are already down (and should be). This patch takes care of this by just calling the shutdown rpc function instead of the whole opcode, and just starting up the instance if it's configured as up in the first place. Reviewed-by: imsnah --- lib/cmdlib.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 495faa6bb..173f87bb8 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -4151,10 +4151,11 @@ class LUExportInstance(LogicalUnit): instance = self.instance dst_node = self.dst_node src_node = instance.primary_node - # shutdown the instance, unless requested not to do so if self.op.shutdown: - op = opcodes.OpShutdownInstance(instance_name=instance.name) - self.proc.ChainOpCode(op) + # shutdown the instance, but not the disks + if not rpc.call_instance_shutdown(src_node, instance): + raise errors.OpExecError("Could not shutdown instance %s on node %s" % + (instance.name, source_node)) vgname = self.cfg.GetVGName() @@ -4177,10 +4178,10 @@ class LUExportInstance(LogicalUnit): snap_disks.append(new_dev) finally: - if self.op.shutdown: - op = opcodes.OpStartupInstance(instance_name=instance.name, - force=False) - self.proc.ChainOpCode(op) + if self.op.shutdown and instance.status == "up": + if not rpc.call_instance_start(src_node, instance, None): + _ShutdownInstanceDisks(instance, self.cfg) + raise errors.OpExecError("Could not start instance") # TODO: check for size -- GitLab