[Pkg-ganeti-devel] [ganeti] 26/165: Add a function computing the allocation vector

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 d75b363482e2479b4a766afbab7b7156f9f52c98
Author: Klaus Aehlig <aehlig at google.com>
Date:   Fri Jan 23 16:22:56 2015 +0100

    Add a function computing the allocation vector
    
    ...that is, for each test instance the number of copies of
    it that can additionally be placed on a given node.
    
    Signed-off-by: Klaus Aehlig <aehlig at google.com>
    Reviewed-by: Petr Pudlak <pudlak at google.com>
---
 src/Ganeti/HTools/Dedicated.hs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/Ganeti/HTools/Dedicated.hs b/src/Ganeti/HTools/Dedicated.hs
index 1ce6b32..d42f880 100644
--- a/src/Ganeti/HTools/Dedicated.hs
+++ b/src/Ganeti/HTools/Dedicated.hs
@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 module Ganeti.HTools.Dedicated
   ( isDedicated
   , testInstances
+  , allocationVector
   ) where
 
 import Control.Applicative (liftA2)
@@ -44,6 +45,7 @@ import qualified Data.IntMap as IntMap
 import qualified Data.IntSet as IntSet
 import Data.List (sortBy)
 
+import Ganeti.BasicTypes (iterateOk)
 import qualified Ganeti.HTools.Group as Group
 import qualified Ganeti.HTools.Instance as Instance
 import qualified Ganeti.HTools.Loader as Loader
@@ -87,3 +89,9 @@ testInstances =
   . sortBy (flip compare `on` T.iSpecDiskSize)
   . map T.minMaxISpecsMinSpec
   . T.iPolicyMinMaxISpecs
+
+-- | Given the test instances, compute the allocations vector of a node
+allocationVector :: [Instance.Instance] -> Node.Node -> [Int]
+allocationVector insts node =
+  map (\ inst -> length $ iterateOk (`Node.addPri` inst) node) insts
+

-- 
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