From f33c06b8c9ade750573b19fdcb840beb3655594c Mon Sep 17 00:00:00 2001
From: Klaus Aehlig <aehlig@google.com>
Date: Thu, 2 May 2013 13:41:53 +0200
Subject: [PATCH] Make LUXI backed set node tags correctly

Since the htools representation of a node now allows adding
the node tags, populate this field correctly in the LUXI
backend.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 src/Ganeti/HTools/Backend/Luxi.hs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/Ganeti/HTools/Backend/Luxi.hs b/src/Ganeti/HTools/Backend/Luxi.hs
index 5a1246ab2..ac30e12fa 100644
--- a/src/Ganeti/HTools/Backend/Luxi.hs
+++ b/src/Ganeti/HTools/Backend/Luxi.hs
@@ -104,7 +104,7 @@ queryNodesMsg =
   L.Query (Qlang.ItemTypeOpCode Qlang.QRNode)
      ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree",
       "ctotal", "offline", "drained", "vm_capable",
-      "ndp/spindle_count", "group.uuid"] Qlang.EmptyFilter
+      "ndp/spindle_count", "group.uuid", "tags"] Qlang.EmptyFilter
 
 -- | The input data for instance query.
 queryInstancesMsg :: L.LuxiOp
@@ -185,7 +185,8 @@ getNodes ktg arr = extractArray arr >>= mapM (parseNode ktg)
 -- | Construct a node from a JSON object.
 parseNode :: NameAssoc -> [(JSValue, JSValue)] -> Result (String, Node.Node)
 parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree
-              , ctotal, offline, drained, vm_capable, spindles, g_uuid ]
+              , ctotal, offline, drained, vm_capable, spindles, g_uuid 
+              , tags ]
     = do
   xname <- annotateResult "Parsing new node" (fromJValWithStatus name)
   let convert a = genericConvert "Node" xname a
@@ -194,6 +195,7 @@ parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree
   xvm_capable <- convert "vm_capable" vm_capable
   xspindles <- convert "spindles" spindles
   xgdx   <- convert "group.uuid" g_uuid >>= lookupGroup ktg xname
+  xtags <- convert "tags" tags
   node <- if xoffline || xdrained || not xvm_capable
             then return $ Node.create xname 0 0 0 0 0 0 True xspindles xgdx
             else do
@@ -203,8 +205,9 @@ parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree
               xdtotal  <- convert "dtotal" dtotal
               xdfree   <- convert "dfree" dfree
               xctotal  <- convert "ctotal" ctotal
-              return $ Node.create xname xmtotal xmnode xmfree
-                     xdtotal xdfree xctotal False xspindles xgdx
+              return . flip Node.setNodeTags xtags $
+                Node.create xname xmtotal xmnode xmfree xdtotal xdfree
+                            xctotal False xspindles xgdx
   return (xname, node)
 
 parseNode _ v = fail ("Invalid node query result: " ++ show v)
-- 
GitLab