From 40ed12dddbcba28269ec39e11ac673f811180fc8 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 14 Jan 2008 14:19:11 +0000
Subject: [PATCH] Fix CreateInstance new optional parameters

Some new paramenters of the CreateInstance opcode are optional (namely
kernel_path, initrd_path and hvm_boot_order) but their absence makes the code
crash. Fix this by initializing them to a default value if they're not present.

Reviewed-by: iustinp
---
 lib/cmdlib.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index bb998063e..4c20ce0fa 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2890,6 +2890,10 @@ class LUCreateInstance(LogicalUnit):
     """Check prerequisites.
 
     """
+    for attr in ["kernel_path", "initrd_path", "hvm_boot_order"]:
+      if not hasattr(self.op, attr):
+        setattr(self.op, attr, None)
+
     if self.op.mode not in (constants.INSTANCE_CREATE,
                             constants.INSTANCE_IMPORT):
       raise errors.OpPrereqError("Invalid instance creation mode '%s'" %
-- 
GitLab