This small patch actually reads the allocation policy from the
IAllocator message.
---
 Ganeti/HTools/IAlloc.hs |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Ganeti/HTools/IAlloc.hs b/Ganeti/HTools/IAlloc.hs
index 228b408..548e427 100644
--- a/Ganeti/HTools/IAlloc.hs
+++ b/Ganeti/HTools/IAlloc.hs
@@ -104,8 +104,10 @@ parseGroup :: String              -- ^ The group UUID
            -> [(String, JSValue)] -- ^ The JSON object
            -> Result (String, Group.Group)
 parseGroup u a = do
-  name <- fromObj a "name"
-  return (u, Group.create name u AllocPreferred)
+  let extract x = tryFromObj ("invalid data for group '" ++ u ++ "'") a x
+  name <- extract "name"
+  apol <- extract "alloc_policy"
+  return (u, Group.create name u apol)
 
 -- | Top-level parser.
 parseData :: String         -- ^ The JSON message as received from Ganeti
-- 
1.7.3.1

Reply via email to