Skip to content
Snippets Groups Projects
Commit ea017cbc authored by Iustin Pop's avatar Iustin Pop
Browse files

Read cluster tags in the RAPI backend

This also shows them in hbal in verbose mode.
parent 94e05c32
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,7 @@ import Network.Curl.Types ()
import Network.Curl.Code
import Data.List
import Control.Monad
import Text.JSON (JSObject, JSValue, fromJSObject)
import Text.JSON (JSObject, JSValue, fromJSObject, decodeStrict)
import Text.Printf (printf)
import Ganeti.HTools.Utils
......@@ -119,9 +119,11 @@ loadData master = do -- IO monad
let url = formatHost master
node_body <- getUrl $ printf "%s/2/nodes?bulk=1" url
inst_body <- getUrl $ printf "%s/2/instances?bulk=1" url
tags_body <- getUrl $ printf "%s/2/tags" url
return $ do -- Result monad
node_data <- node_body >>= getNodes
let (node_names, node_idx) = assignIndices node_data
inst_data <- inst_body >>= getInstances node_names
let (_, inst_idx) = assignIndices inst_data
return (node_idx, inst_idx, [])
tags_data <- tags_body >>= (fromJResult . decodeStrict)
return (node_idx, inst_idx, tags_data)
......@@ -187,7 +187,7 @@ main = do
verbose = optVerbose opts
shownodes = optShowNodes opts
(fixed_nl, il, _, csf) <- loadExternalData opts
(fixed_nl, il, ctags, csf) <- loadExternalData opts
let offline_names = optOffline opts
all_nodes = Container.elems fixed_nl
......@@ -210,6 +210,9 @@ main = do
nl = Container.map (flip Node.setMdsk m_dsk . flip Node.setMcpu m_cpu)
nm
when (not oneline && verbose > 1) $
putStrLn $ "Loaded cluster tags: " ++ intercalate "," ctags
when (Container.size il == 0) $ do
(if oneline then putStrLn $ formatOneline 0 0 0
else printf "Cluster is empty, exiting.\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment