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

Luxi: read the node uuid from the cluster


This makes the code incompatible with Ganeti pre-2.4.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parent a68004b7
No related branches found
No related tags found
No related merge requests found
...@@ -37,8 +37,7 @@ import Ganeti.HTools.Loader ...@@ -37,8 +37,7 @@ import Ganeti.HTools.Loader
import Ganeti.HTools.Types import Ganeti.HTools.Types
import qualified Ganeti.HTools.Node as Node import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance import qualified Ganeti.HTools.Instance as Instance
import Ganeti.HTools.Utils (fromJVal, annotateResult, tryFromObj, asJSObject, import Ganeti.HTools.Utils (fromJVal, annotateResult, tryFromObj, asJSObject)
defaultUUID)
-- * Utility functions -- * Utility functions
...@@ -55,7 +54,8 @@ toArray v = ...@@ -55,7 +54,8 @@ toArray v =
queryNodesMsg :: L.LuxiOp queryNodesMsg :: L.LuxiOp
queryNodesMsg = queryNodesMsg =
L.QueryNodes [] ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree", L.QueryNodes [] ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree",
"ctotal", "offline", "drained", "vm_capable"] False "ctotal", "offline", "drained", "vm_capable",
"group.uuid"] False
-- | The input data for instance query. -- | The input data for instance query.
queryInstancesMsg :: L.LuxiOp queryInstancesMsg :: L.LuxiOp
...@@ -116,15 +116,16 @@ getNodes arr = toArray arr >>= mapM parseNode ...@@ -116,15 +116,16 @@ getNodes arr = toArray arr >>= mapM parseNode
-- | Construct a node from a JSON object. -- | Construct a node from a JSON object.
parseNode :: JSValue -> Result (String, Node.Node) parseNode :: JSValue -> Result (String, Node.Node)
parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree
, ctotal, offline, drained, vm_capable ]) , ctotal, offline, drained, vm_capable, g_uuid ])
= do = do
xname <- annotateResult "Parsing new node" (fromJVal name) xname <- annotateResult "Parsing new node" (fromJVal name)
let convert v = annotateResult ("Node '" ++ xname ++ "'") (fromJVal v) let convert v = annotateResult ("Node '" ++ xname ++ "'") (fromJVal v)
xoffline <- convert offline xoffline <- convert offline
xdrained <- convert drained xdrained <- convert drained
xvm_capable <- convert vm_capable xvm_capable <- convert vm_capable
xguuid <- convert g_uuid
node <- (if xoffline || xdrained || not xvm_capable node <- (if xoffline || xdrained || not xvm_capable
then return $ Node.create xname 0 0 0 0 0 0 True defaultUUID then return $ Node.create xname 0 0 0 0 0 0 True xguuid
else do else do
xmtotal <- convert mtotal xmtotal <- convert mtotal
xmnode <- convert mnode xmnode <- convert mnode
...@@ -133,7 +134,7 @@ parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree ...@@ -133,7 +134,7 @@ parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree
xdfree <- convert dfree xdfree <- convert dfree
xctotal <- convert ctotal xctotal <- convert ctotal
return $ Node.create xname xmtotal xmnode xmfree return $ Node.create xname xmtotal xmnode xmfree
xdtotal xdfree xctotal False defaultUUID) xdtotal xdfree xctotal False xguuid)
return (xname, node) return (xname, node)
parseNode v = fail ("Invalid node query result: " ++ show v) parseNode v = fail ("Invalid node query result: " ++ show v)
......
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