Commit e77bc89b authored by Iustin Pop's avatar Iustin Pop
Browse files

Load cluster ipolicy via Luxi



Also show it in hbal's verbose output (helpful for debugging).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 71375ef7
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment