Revision 1e4b5230

b/Ganeti/HTools/Node.hs
48 48
    , addSec
49 49
    -- * Stats
50 50
    , availDisk
51
    , conflictingPrimaries
51 52
    -- * Formatting
52 53
    , defaultFields
53 54
    , showHeader
......
60 61

  
61 62
import Data.List
62 63
import qualified Data.Map as Map
64
import qualified Data.Foldable as Foldable
63 65
import Text.Printf (printf)
64 66

  
65 67
import qualified Ganeti.HTools.Container as Container
......
158 160
rejectAddTags :: TagMap -> [String] -> Bool
159 161
rejectAddTags t = any (flip Map.member t)
160 162

  
163
-- | Check how many primary instances have conflicting tags. The
164
-- algorithm to compute this is to sum the count of all tags, then
165
-- subtract the size of the tag map (since each tag has at least one,
166
-- non-conflicting instance); this is equivalent to summing the
167
-- values in the tag map minus one.
168
conflictingPrimaries :: Node -> Int
169
conflictingPrimaries (Node { pTags = t }) = Foldable.sum t - Map.size t
170

  
161 171
-- * Initialization functions
162 172

  
163 173
-- | Create a new node.

Also available in: Unified diff