From c9a9b853326289bb3f01ade10aa74cdfdf93f42d Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 7 Jul 2011 13:35:48 +0200
Subject: [PATCH] htools: generalise and rename availableLocalNodes

Currently this function works in the context of an instance, computing
its local group nodes. We can use generalise it to take a group index
argument, so that it's not bound to an instance, and we rename it
accordingly.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htools/Ganeti/HTools/Cluster.hs | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index ce5afc979..eae9742fe 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -1033,15 +1033,14 @@ evacDrbdSecondaryInner nl inst gdx accu ndx =
                    then accu
                    else new_accu
 
--- | Computes the local nodes of a given instance which are available
--- for allocation.
-availableLocalNodes :: Node.List
-                    -> [(Gdx, [Ndx])]
-                    -> IntSet.IntSet
-                    -> Instance.Instance
-                    -> Result [Ndx]
-availableLocalNodes nl group_nodes excl_ndx inst = do
-  let gdx = instancePriGroup nl inst
+-- | Computes the nodes in a given group which are available for
+-- allocation.
+availableGroupNodes :: [(Gdx, [Ndx])] -- ^ Group index/node index assoc list
+                    -> IntSet.IntSet  -- ^ Nodes that are excluded
+                    -> Gdx            -- ^ The group for which we
+                                      -- query the nodes
+                    -> Result [Ndx]   -- ^ List of available node indices
+availableGroupNodes group_nodes excl_ndx gdx = do
   local_nodes <- maybe (Bad $ "Can't find group with index " ++ show gdx)
                  Ok (lookup gdx group_nodes)
   let avail_nodes = filter (not . flip IntSet.member excl_ndx) local_nodes
@@ -1076,7 +1075,8 @@ tryNodeEvac _ ini_nl ini_il mode idxs =
         (_, _, esol) =
             foldl' (\state@(nl, il, _) inst ->
                         updateEvacSolution state inst $
-                        availableLocalNodes nl group_ndx excl_ndx inst >>=
+                        availableGroupNodes group_ndx
+                          excl_ndx (instancePriGroup nl inst) >>=
                         nodeEvacInstance nl il mode inst
                    )
             (ini_nl, ini_il, emptyEvacSolution)
-- 
GitLab