From cc0d88e95afa0be2cf4aa563904016c5a067d4cd Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 9 Apr 2010 17:21:24 +0200
Subject: [PATCH] Reuse backend parameters from export

Similar to the previous patches, if we're missing some parameters and
the export has them (either in the new style or old-style), we reuse
them.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 lib/cmdlib.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 984b1d0a5..ea404a7f7 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -6288,6 +6288,18 @@ class LUCreateInstance(LogicalUnit):
         if name not in self.op.hvparams:
           self.op.hvparams[name] = value
 
+    if einfo.has_section(constants.INISECT_BEP):
+      # use the parameters, without overriding
+      for name, value in einfo.items(constants.INISECT_BEP):
+        if name not in self.op.beparams:
+          self.op.beparams[name] = value
+    else:
+      # try to read the parameters old style, from the main section
+      for name in constants.BES_PARAMETERS:
+        if (name not in self.op.beparams and
+            einfo.has_option(constants.INISECT_INS, name)):
+          self.op.beparams[name] = einfo.get(constants.INISECT_INS, name)
+
   def CheckPrereq(self):
     """Check prerequisites.
 
-- 
GitLab