From 371f046c3db6e9ba4e1b24301643c3bd7bb18189 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 19 Feb 2010 18:39:22 +0100
Subject: [PATCH] Fix bug in LUExportInstance
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If remove_instance isn't passed to the Opcode, it'll be None.  When
generating the hooks environment, the error β€œint() argument must be a
string or a number” was raised. It should now behave as any other
boolean hook env variable.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 142a01201..b721cd46d 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -8097,7 +8097,8 @@ class LUExportInstance(LogicalUnit):
       "EXPORT_NODE": self.op.target_node,
       "EXPORT_DO_SHUTDOWN": self.op.shutdown,
       "SHUTDOWN_TIMEOUT": self.shutdown_timeout,
-      "REMOVE_INSTANCE": int(self.remove_instance),
+      # TODO: Generic function for boolean env variables
+      "REMOVE_INSTANCE": str(bool(self.remove_instance)),
       }
     env.update(_BuildInstanceHookEnvByObject(self, self.instance))
     nl = [self.cfg.GetMasterNode(), self.instance.primary_node,
-- 
GitLab