From c6ccc073fa3dc03a9cdfc6771402fb181783e305 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 13 Jun 2011 11:44:58 +0000 Subject: [PATCH] Loader.updateMovable: evaluate selected instances This also adds docstrings for the function arguments and renames exinst to exinsts, which is how it is called in other functions, since it's a list. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- htools/Ganeti/HTools/Loader.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs index 427287043..9c6badf39 100644 --- a/htools/Ganeti/HTools/Loader.hs +++ b/htools/Ganeti/HTools/Loader.hs @@ -156,10 +156,14 @@ filterExTags tl inst = in inst { Instance.tags = new_tags } -- | Update the movable attribute -updateMovable :: [String] -> Instance.Instance -> Instance.Instance -updateMovable exinst inst = +updateMovable :: [String] -- ^ Selected instances (if not empty) + -> [String] -- ^ Excluded instances + -> Instance.Instance -- ^ Target Instance + -> Instance.Instance -- ^ Target Instance with updated attribute +updateMovable selinsts exinsts inst = if Instance.sNode inst == Node.noSecondary || - Instance.name inst `elem` exinst + Instance.name inst `elem` exinsts || + not (null selinsts || Instance.name inst `elem` selinsts) then Instance.setMovable inst False else inst @@ -205,7 +209,7 @@ mergeData um extags selinsts exinsts cdata@(ClusterData _ nl il2 tags) = ) il2 um allextags = extags ++ extractExTags tags il4 = Container.map (filterExTags allextags . - updateMovable exinsts) il3 + updateMovable selinsts exinsts) il3 nl2 = foldl' fixNodes nl (Container.elems il4) nl3 = Container.map (flip Node.buildPeers il4) nl2 node_names = map Node.name (Container.elems nl) -- GitLab