From c4c37257a0ad4830d660038123f0815ee200bcc1 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 16 Dec 2010 14:45:54 +0100
Subject: [PATCH] Luxi: read the allocation policy from the cluster

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>
---
 Ganeti/HTools/Luxi.hs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Ganeti/HTools/Luxi.hs b/Ganeti/HTools/Luxi.hs
index 88c22849d..206bcb8c1 100644
--- a/Ganeti/HTools/Luxi.hs
+++ b/Ganeti/HTools/Luxi.hs
@@ -71,7 +71,7 @@ queryClusterInfoMsg = L.QueryClusterInfo
 -- | The input data for node group query.
 queryGroupsMsg :: L.LuxiOp
 queryGroupsMsg =
-  L.QueryGroups [] ["uuid", "name"] False
+  L.QueryGroups [] ["uuid", "name", "alloc_policy"] False
 
 -- | Wraper over callMethod doing node query.
 queryNodes :: L.Client -> IO (Result JSValue)
@@ -159,11 +159,12 @@ getGroups :: JSValue -> Result [(String, Group.Group)]
 getGroups arr = toArray arr >>= mapM parseGroup
 
 parseGroup :: JSValue -> Result (String, Group.Group)
-parseGroup (JSArray [ uuid, name ]) = do
+parseGroup (JSArray [ uuid, name, apol ]) = do
   xname <- annotateResult "Parsing new group" (fromJVal name)
   let convert v = annotateResult ("Node '" ++ xname ++ "'") (fromJVal v)
   xuuid <- convert uuid
-  return $ (xuuid, Group.create xname xuuid AllocPreferred)
+  xapol <- convert apol
+  return $ (xuuid, Group.create xname xuuid xapol)
 
 parseGroup v = fail ("Invalid group query result: " ++ show v)
 
-- 
GitLab