Commit 3b01286e authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

LUExportInstance: Accept instance already shut down



To remove the instance after an export it needs to be stopped. This can
be achived using the parameter “shutdown”, or by explicitly shutting
down the instance before exporting. The latter would still require the
“shutdown” parameter to be set. To make it more intuitive, this
requirement is changed with this patch. Instances already stopped are
accepted for automatic removal.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent cd04f8c2
......@@ -9618,10 +9618,6 @@ class LUExportInstance(LogicalUnit):
self.x509_key_name = self.op.x509_key_name
self.dest_x509_ca_pem = self.op.destination_x509_ca
if self.op.remove_instance and not self.op.shutdown:
raise errors.OpPrereqError("Can not remove instance without shutting it"
" down before")
if self.op.mode == constants.EXPORT_MODE_REMOTE:
if not self.x509_key_name:
raise errors.OpPrereqError("Missing X509 key name for encryption",
......@@ -9687,6 +9683,11 @@ class LUExportInstance(LogicalUnit):
"Cannot retrieve locked instance %s" % self.op.instance_name
_CheckNodeOnline(self, self.instance.primary_node)
if (self.op.remove_instance and self.instance.admin_up and
not self.op.shutdown):
raise errors.OpPrereqError("Can not remove instance without shutting it"
" down before")
if self.op.mode == constants.EXPORT_MODE_LOCAL:
self.op.target_node = _ExpandNodeName(self.cfg, self.op.target_node)
self.dst_node = self.cfg.GetNodeInfo(self.op.target_node)
......
......@@ -430,15 +430,19 @@ def main():
if (qa_config.TestEnabled('instance-add-plain-disk') and
qa_config.TestEnabled("instance-export")):
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
expnode = qa_config.AcquireNode(exclude=pnode)
try:
RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode)
RunTest(qa_instance.TestBackupList, expnode)
finally:
qa_config.ReleaseNode(expnode)
del expnode
del instance
for shutdown in [False, True]:
instance = RunTest(qa_instance.TestInstanceAddWithPlainDisk, pnode)
expnode = qa_config.AcquireNode(exclude=pnode)
try:
if shutdown:
# Stop instance before exporting and removing it
RunTest(qa_instance.TestInstanceShutdown, instance)
RunTest(qa_instance.TestInstanceExportWithRemove, instance, expnode)
RunTest(qa_instance.TestBackupList, expnode)
finally:
qa_config.ReleaseNode(expnode)
del expnode
del instance
finally:
qa_config.ReleaseNode(pnode)
......
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