Skip to content
Snippets Groups Projects
Commit 1e4b5230 authored by Iustin Pop's avatar Iustin Pop
Browse files

Node: add function for conflicting primary count

parent b2999982
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ module Ganeti.HTools.Node
, addSec
-- * Stats
, availDisk
, conflictingPrimaries
-- * Formatting
, defaultFields
, showHeader
......@@ -60,6 +61,7 @@ module Ganeti.HTools.Node
import Data.List
import qualified Data.Map as Map
import qualified Data.Foldable as Foldable
import Text.Printf (printf)
import qualified Ganeti.HTools.Container as Container
......@@ -158,6 +160,14 @@ delTags = foldl' delTag
rejectAddTags :: TagMap -> [String] -> Bool
rejectAddTags t = any (flip Map.member t)
-- | Check how many primary instances have conflicting tags. The
-- algorithm to compute this is to sum the count of all tags, then
-- subtract the size of the tag map (since each tag has at least one,
-- non-conflicting instance); this is equivalent to summing the
-- values in the tag map minus one.
conflictingPrimaries :: Node -> Int
conflictingPrimaries (Node { pTags = t }) = Foldable.sum t - Map.size t
-- * Initialization functions
-- | Create a new node.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment