[Pkg-ganeti-devel] [ganeti] 35/165: Export sorting, filtering, and formating multi-group allocs
Apollon Oikonomopoulos
apoikos at moszumanska.debian.org
Tue Aug 11 13:53:10 UTC 2015
This is an automated email from the git hooks/post-receive script.
apoikos pushed a commit to branch master
in repository ganeti.
commit 1f550cdc94cc562cb3ab49f14f962781d9b3ad2c
Author: Klaus Aehlig <aehlig at google.com>
Date: Wed Jan 28 14:42:44 2015 +0100
Export sorting, filtering, and formating multi-group allocs
...so that other allocation strategies can reuse those
primitives. While there, generalize them to be parametric
in the metric.
Signed-off-by: Klaus Aehlig <aehlig at google.com>
Reviewed-by: Petr Pudlak <pudlak at google.com>
---
src/Ganeti/HTools/Backend/IAlloc.hs | 4 +++-
src/Ganeti/HTools/Cluster.hs | 11 +++++++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/Ganeti/HTools/Backend/IAlloc.hs b/src/Ganeti/HTools/Backend/IAlloc.hs
index dab10de..8c45603 100644
--- a/src/Ganeti/HTools/Backend/IAlloc.hs
+++ b/src/Ganeti/HTools/Backend/IAlloc.hs
@@ -39,6 +39,7 @@ module Ganeti.HTools.Backend.IAlloc
, loadData
, formatAllocate
, formatIAllocResult
+ , formatMultiAlloc
) where
import Data.Either ()
@@ -302,7 +303,8 @@ formatAllocate il as = do
return (info, showJSON $ map Node.name nodes, nl, il')
-- | Convert multi allocation results into the result format.
-formatMultiAlloc :: (Node.List, Instance.List, Cluster.AllocSolutionList)
+formatMultiAlloc :: ( Node.List, Instance.List
+ , Cluster.GenericAllocSolutionList a)
-> Result IAllocResult
formatMultiAlloc (fin_nl, fin_il, ars) =
let rars = reverse ars
diff --git a/src/Ganeti/HTools/Cluster.hs b/src/Ganeti/HTools/Cluster.hs
index c90a5a4..351d81b 100644
--- a/src/Ganeti/HTools/Cluster.hs
+++ b/src/Ganeti/HTools/Cluster.hs
@@ -85,6 +85,8 @@ module Ganeti.HTools.Cluster
, tryAlloc
, tryGroupAlloc
, tryMGAlloc
+ , filterMGResults
+ , sortMGResults
, tryNodeEvac
, tryChangeGroup
, collapseFailures
@@ -957,8 +959,8 @@ solutionDescription (grp, result) =
-- | From a list of possibly bad and possibly empty solutions, filter
-- only the groups with a valid result. Note that the result will be
-- reversed compared to the original list.
-filterMGResults :: [(Group.Group, Result AllocSolution)]
- -> [(Group.Group, AllocSolution)]
+filterMGResults :: [(Group.Group, Result (GenericAllocSolution a))]
+ -> [(Group.Group, GenericAllocSolution a)]
filterMGResults = foldl' fn []
where unallocable = not . Group.isAllocable
fn accu (grp, rasol) =
@@ -969,8 +971,9 @@ filterMGResults = foldl' fn []
| otherwise -> (grp, sol):accu
-- | Sort multigroup results based on policy and score.
-sortMGResults :: [(Group.Group, AllocSolution)]
- -> [(Group.Group, AllocSolution)]
+sortMGResults :: Ord a
+ => [(Group.Group, GenericAllocSolution a)]
+ -> [(Group.Group, GenericAllocSolution a)]
sortMGResults sols =
let extractScore (_, _, _, x) = x
solScore (grp, sol) = (Group.allocPolicy grp,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git
More information about the Pkg-ganeti-devel
mailing list