Commit fb300fb7 authored by Guido Trotter's avatar Guido Trotter
Browse files

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
parent 2d3e73c4
......@@ -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
......
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