Commit f5e67f55 authored by Iustin Pop's avatar Iustin Pop
Browse files

Configure exclusion tags via the cluster tags

This patch adds reading of the exclusion tags from the cluster tags: any
tags starting with htools:iextags: will convert their suffix into an
exclusion tags prefix. In other words, "htools:iextags:service" will
cause any "service:X" tag to become an exclusion group.
parent f3d53161
......@@ -48,6 +48,12 @@ import qualified Ganeti.HTools.Node as Node
import Ganeti.HTools.Types
-- * Constants
-- | The exclusion tag prefix
exTagsPrefix :: String
exTagsPrefix = "htools:iextags:"
-- * Types
{-| The request type.
......@@ -136,6 +142,12 @@ longestDomain (x:xs) =
stripSuffix :: Int -> String -> String
stripSuffix sflen name = take (length name - sflen) name
-- | Extracts the exclusion tags from the cluster configuration
extractExTags :: [String] -> [String]
extractExTags =
map (drop (length exTagsPrefix)) .
filter (isPrefixOf exTagsPrefix)
-- | Initializer function that loads the data from a node and instance
-- list and massages it into the correct format.
mergeData :: [(String, DynUtil)] -- ^ Instance utilisation data
......@@ -152,7 +164,8 @@ mergeData um extags (nl, il, tags) =
let new_i = inst { Instance.util = n_util }
in Container.add (Instance.idx inst) new_i im
) il2 um
il4 = Container.map (filterExTags extags) il3
allextags = extags ++ extractExTags tags
il4 = Container.map (filterExTags allextags) il3
nl2 = foldl' fixNodes nl (Container.elems il4)
nl3 = Container.fromAssocList
(map (\ (k, v) -> (k, Node.buildPeers v il4)) nl2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment