From 3b01286e6de5b54648bbb96dafd6deb67babc01a Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 28 Oct 2010 18:03:14 +0200 Subject: [PATCH] LUExportInstance: Accept instance already shut down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cmdlib.py | 9 +++++---- qa/ganeti-qa.py | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index e3fb2292b..f089b160b 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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) diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py index 79a5d6e2b..afcdf18b9 100755 --- a/qa/ganeti-qa.py +++ b/qa/ganeti-qa.py @@ -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) -- GitLab