On Mon, Dec 20, 2010 at 10:54, Iustin Pop <[email protected]> wrote: > On Sun, Dec 19, 2010 at 11:02:01PM +0000, Balazs Lecz wrote: > > On Fri, Dec 17, 2010 at 13:02, Iustin Pop <[email protected]> wrote: > > > > > This will allow reading this attribute via the Rapi/Luxi backends. > > > --- > > > Ganeti/HTools/Types.hs | 25 +++++++++++++++++++++++++ > > > 1 files changed, 25 insertions(+), 0 deletions(-) > > > > > > diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs > > > index ba3b70d..c86ce1e 100644 > > > --- a/Ganeti/HTools/Types.hs > > > +++ b/Ganeti/HTools/Types.hs > > > @@ -32,6 +32,8 @@ module Ganeti.HTools.Types > > > , Weight > > > , GroupID > > > , AllocPolicy(..) > > > + , apolFromString > > > + , apolToString > > > , RSpec(..) > > > , DynUtil(..) > > > , zeroUtil > > > @@ -60,6 +62,7 @@ module Ganeti.HTools.Types > > > ) where > > > > > > import qualified Data.Map as M > > > +import qualified Text.JSON as JSON > > > > > > -- | The instance index type. > > > type Idx = Int > > > @@ -88,6 +91,28 @@ data AllocPolicy = AllocPreferred > > > | AllocUnallocable > > > deriving (Show, Eq) > > > > > > +-- | Convert a string to an alloc policy > > > +apolFromString :: (Monad m) => String -> m AllocPolicy > > > +apolFromString s = > > > + case s of > > > + "preferred" -> return AllocPreferred > > > + "last_resort" -> return AllocLastResort > > > + "unallocable" -> return AllocUnallocable > > > + o -> fail $ "Invalid alloc policy mode: " ++ o > > > > > > > s/mode/name/? > > Not sure. In theory this should catch new, unknown allocation policies > coming from Ganeti, in other words a new mode. Both are fine, I think. > Let me know which you prefer. > > iustin >
We are just trying to parse a string, which is the name of the allocation policy. In my head "allocation policy" clashes with "mode". "Mode" is a way of operation, while "policy" is a prescription. Anyway, this is highly philosophical and it's just an error message. LGTM
