Re: [PATCH master 17/52] Load cluster ipolicy via Luxi

2012-01-11 Thread René Nussbaumer
On Mon, Jan 9, 2012 at 11:58, Iustin Pop ius...@google.com wrote:
 Also show it in hbal's verbose output (helpful for debugging).
 ---
  htools/Ganeti/HTools/Luxi.hs         |   16 ++--
  htools/Ganeti/HTools/Program/Hbal.hs |    5 +++--
  2 files changed, 13 insertions(+), 8 deletions(-)

LGTM.

René


[PATCH master 17/52] Load cluster ipolicy via Luxi

2012-01-09 Thread Iustin Pop
Also show it in hbal's verbose output (helpful for debugging).
---
 htools/Ganeti/HTools/Luxi.hs |   16 ++--
 htools/Ganeti/HTools/Program/Hbal.hs |5 +++--
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs
index d360390..74dd984 100644
--- a/htools/Ganeti/HTools/Luxi.hs
+++ b/htools/Ganeti/HTools/Luxi.hs
@@ -199,11 +199,15 @@ parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree
 parseNode _ v = fail (Invalid node query result:  ++ show v)
 
 -- | Parses the cluster tags.
-getClusterTags :: JSValue - Result [String]
-getClusterTags v = do
+getClusterData :: JSValue - Result ([String], IPolicy)
+getClusterData (JSObject obj) = do
   let errmsg = Parsing cluster info
-  obj - annotateResult errmsg $ asJSObject v
-  tryFromObj errmsg (fromJSObject obj) tags
+  obj' = fromJSObject obj
+  ctags - tryFromObj errmsg obj' tags
+  cpol - tryFromObj errmsg obj' ipolicy
+  return (ctags, cpol)
+
+getClusterData _ = Bad $ Cannot parse cluster info, not a JSON record
 
 -- | Parses the cluster groups.
 getGroups :: JSValue - Result [(String, Group.Group)]
@@ -248,8 +252,8 @@ 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 - cinfo = getClusterTags
-  return (ClusterData group_idx node_idx inst_idx ctags defIPolicy)
+  (ctags, cpol) - cinfo = getClusterData
+  return (ClusterData group_idx node_idx inst_idx ctags cpol)
 
 -- | Top level function for data loading.
 loadData :: String -- ^ Unix socket to use as source
diff --git a/htools/Ganeti/HTools/Program/Hbal.hs 
b/htools/Ganeti/HTools/Program/Hbal.hs
index 758b890..689e8aa 100644
--- a/htools/Ganeti/HTools/Program/Hbal.hs
+++ b/htools/Ganeti/HTools/Program/Hbal.hs
@@ -351,10 +351,11 @@ main = do
   shownodes = optShowNodes opts
   showinsts = optShowInsts opts
 
-  ini_cdata@(ClusterData gl fixed_nl ilf ctags _) - loadExternalData opts
+  ini_cdata@(ClusterData gl fixed_nl ilf ctags ipol) - loadExternalData opts
 
-  when (verbose  1) $
+  when (verbose  1) $ do
putStrLn $ Loaded cluster tags:  ++ intercalate , ctags
+   putStrLn $ Loaded cluster ipolicy:  ++ show ipol
 
   nlf - setNodeStatus opts fixed_nl
   checkCluster verbose nlf ilf
-- 
1.7.3.1