From f5e67f55054cb553251b3aa33151877068b1336b Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 1 Dec 2009 13:49:49 +0100 Subject: [PATCH] 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. --- Ganeti/HTools/Loader.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs index 385015eae..49e752f40 100644 --- a/Ganeti/HTools/Loader.hs +++ b/Ganeti/HTools/Loader.hs @@ -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) -- GitLab