From b45222ce71d364c87f57194817dd39731794b987 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 9 Dec 2009 11:29:22 +0100
Subject: [PATCH] rapi, luxi: treat drained nodes as offline

Commit e97f211 changed the iallocator backend to handle drained nodes as
offline. This commit completes that change by making the rapi and luxi
backend do the same (the text backend ignores any '?' values which are
returned by ganeti when nodes have problems, so it doesn't need this
change).
---
 Ganeti/HTools/Luxi.hs | 6 +++---
 Ganeti/HTools/Rapi.hs | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Ganeti/HTools/Luxi.hs b/Ganeti/HTools/Luxi.hs
index 8fe728f0c..1c2fae431 100644
--- a/Ganeti/HTools/Luxi.hs
+++ b/Ganeti/HTools/Luxi.hs
@@ -131,10 +131,10 @@ parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree
   xname <- annotateResult "Parsing new node" (fromJVal name)
   let convert v = annotateResult ("Node '" ++ xname ++ "'") (fromJVal v)
   xoffline <- convert offline
-  node <- (if xoffline
+  xdrained <- convert drained
+  node <- (if xoffline || xdrained
            then return $ Node.create xname 0 0 0 0 0 0 True
            else do
-             xdrained <- convert drained
              xmtotal  <- convert mtotal
              xmnode   <- convert mnode
              xmfree   <- convert mfree
@@ -142,7 +142,7 @@ parseNode (JSArray [ name, mtotal, mnode, mfree, dtotal, dfree
              xdfree   <- convert dfree
              xctotal  <- convert ctotal
              return $ Node.create xname xmtotal xmnode xmfree
-                    xdtotal xdfree xctotal (xoffline || xdrained))
+                    xdtotal xdfree xctotal False)
   return (xname, node)
 
 parseNode v = fail ("Invalid node query result: " ++ show v)
diff --git a/Ganeti/HTools/Rapi.hs b/Ganeti/HTools/Rapi.hs
index 3f6069907..8544723e4 100644
--- a/Ganeti/HTools/Rapi.hs
+++ b/Ganeti/HTools/Rapi.hs
@@ -98,10 +98,10 @@ parseNode a = do
   name <- tryFromObj "Parsing new node" a "name"
   let extract s = tryFromObj ("Node '" ++ name ++ "'") a s
   offline <- extract "offline"
-  node <- (if offline
+  drained <- extract "drained"
+  node <- (if offline || drained
            then return $ Node.create name 0 0 0 0 0 0 True
            else do
-             drained <- extract "drained"
              mtotal  <- extract "mtotal"
              mnode   <- extract "mnode"
              mfree   <- extract "mfree"
@@ -109,7 +109,7 @@ parseNode a = do
              dfree   <- extract "dfree"
              ctotal  <- extract "ctotal"
              return $ Node.create name mtotal mnode mfree
-                    dtotal dfree ctotal (offline || drained))
+                    dtotal dfree ctotal False)
   return (name, node)
 
 -- | Builds the cluster data from an URL.
-- 
GitLab