On Thu, Dec 5, 2013 at 1:33 PM, Thomas Thrainer <[email protected]> wrote:
> Hmm, IMHO that's an example for the German word "verschlimmbessern".

Well then :) function dicts are usually the way to make case switches
in Python, but I find that default value a little clunky; let's go for
if/elife then.

diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py
index d3070c4..9665b6f 100644
--- a/lib/cmdlib/instance.py
+++ b/lib/cmdlib/instance.py
@@ -849,11 +849,13 @@ class LUInstanceCreate(LogicalUnit):
       # build the full file storage dir path
       joinargs = []

-      cfg_storage = {
-        constants.DT_FILE: self.cfg.GetFileStorageDir,
-        constants.DT_SHARED_FILE: self.cfg.GetSharedFileStorageDir,
-        constants.DT_GLUSTER: self.cfg.GetGlusterStorageDir,
-      }.get(self.op.disk_template, lambda: None)()
+      cfg_storage = None
+      if self.op.disk_template == constants.DT_FILE:
+        cfg_storage = self.cfg.GetFileStorageDir()
+      elif self.op.disk_template == constants.DT_SHARED_FILE:
+        cfg_storage = self.cfg.GetSharedFileStorageDir()
+      elif self.op.disk_template == constants.DT_GLUSTER:
+        cfg_storage = self.cfg.GetGlusterStorageDir()

       if not cfg_storage:
         raise errors.OpPrereqError(

Reply via email to