On Fri, Dec 6, 2013 at 1:05 PM, Santi Raffa <[email protected]> wrote:
> 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. > Yeah, and relying on an exception kind of feels bad here, as that's a normal case, not an exceptional one... LGTM, thanks. > > 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( > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
