From f40fe08c55e915b6b0ab69f161e36fa0c025fdd8 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig <aehlig@google.com> Date: Tue, 16 Apr 2013 14:19:36 +0200 Subject: [PATCH] In Luxi, set the master correctly The cluster data contains the information about the master node. Use this information to set the isMaster bit correctly. Signed-off-by: Klaus Aehlig <aehlig@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- src/Ganeti/HTools/Backend/Luxi.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Ganeti/HTools/Backend/Luxi.hs b/src/Ganeti/HTools/Backend/Luxi.hs index eca265e06..5a1246ab2 100644 --- a/src/Ganeti/HTools/Backend/Luxi.hs +++ b/src/Ganeti/HTools/Backend/Luxi.hs @@ -210,13 +210,14 @@ parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree parseNode _ v = fail ("Invalid node query result: " ++ show v) -- | Parses the cluster tags. -getClusterData :: JSValue -> Result ([String], IPolicy) +getClusterData :: JSValue -> Result ([String], IPolicy, String) getClusterData (JSObject obj) = do let errmsg = "Parsing cluster info" obj' = fromJSObject obj ctags <- tryFromObj errmsg obj' "tags" cpol <- tryFromObj errmsg obj' "ipolicy" - return (ctags, cpol) + master <- tryFromObj errmsg obj' "master" + return (ctags, cpol, master) getClusterData _ = Bad "Cannot parse cluster info, not a JSON record" @@ -265,8 +266,9 @@ parseData (groups, nodes, instances, cinfo) = do let (node_names, node_idx) = assignIndices node_data inst_data <- instances >>= getInstances node_names let (_, inst_idx) = assignIndices inst_data - (ctags, cpol) <- cinfo >>= getClusterData - return (ClusterData group_idx node_idx inst_idx ctags cpol) + (ctags, cpol, master) <- cinfo >>= getClusterData + node_idx' <- setMaster node_names node_idx master + return (ClusterData group_idx node_idx' inst_idx ctags cpol) -- | Top level function for data loading. loadData :: String -- ^ Unix socket to use as source -- GitLab