If the file driver of an instance with file based storage is not specified, the
default one is automatically added by the UpgradeConfig function.

Fixes Issue 571.

Signed-off-by: Michele Tartara <[email protected]>
---
 lib/cmdlib/instance.py | 2 +-
 lib/constants.py       | 1 +
 lib/objects.py         | 4 ++++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py
index adf8d59..e922800 100644
--- a/lib/cmdlib/instance.py
+++ b/lib/cmdlib/instance.py
@@ -408,7 +408,7 @@ class LUInstanceCreate(LogicalUnit):
     if (not self.op.file_driver and
         self.op.disk_template in [constants.DT_FILE,
                                   constants.DT_SHARED_FILE]):
-      self.op.file_driver = constants.FD_LOOP
+      self.op.file_driver = constants.FD_DEFAULT
 
     if self.op.disk_template == constants.DT_FILE:
       opcodes.RequireFileStorage()
diff --git a/lib/constants.py b/lib/constants.py
index dd4b777..d8b6063 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -615,6 +615,7 @@ RBD_CMD = "rbd"
 # file backend driver
 FD_LOOP = "loop"
 FD_BLKTAP = "blktap"
+FD_DEFAULT = FD_LOOP
 
 # the set of drbd-like disk types
 LDS_DRBD = compat.UniqueFrozenset([LD_DRBD8])
diff --git a/lib/objects.py b/lib/objects.py
index ad9f1d7..1c8de13 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -831,6 +831,10 @@ class Disk(ConfigObject):
     self.params = {}
     # add here config upgrade for this disk
 
+    # If the file driver is empty, fill it up with the default value
+    if self.dev_type == constants.LD_FILE and self.physical_id[0] is None:
+      self.physical_id[0] = constants.FD_DEFAULT
+
   @staticmethod
   def ComputeLDParams(disk_template, disk_params):
     """Computes Logical Disk parameters from Disk Template parameters.
-- 
1.8.5.1

Reply via email to