Start a new module for htools-related tag interpretation and move the definition of exclusion tags there. This module will contain all the tags and tag-prefixes that have a special meaning to htools, so that they can be found at a single place.
Signed-off-by: Klaus Aehlig <[email protected]> --- Makefile.am | 1 + src/Ganeti/HTools/Loader.hs | 9 ++------- src/Ganeti/HTools/Tags.hs | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 src/Ganeti/HTools/Tags.hs diff --git a/Makefile.am b/Makefile.am index f662831..e2826be 100644 --- a/Makefile.am +++ b/Makefile.am @@ -846,6 +846,7 @@ HS_LIB_SRCS = \ src/Ganeti/HTools/Program/Hsqueeze.hs \ src/Ganeti/HTools/Program/Hroller.hs \ src/Ganeti/HTools/Program/Main.hs \ + src/Ganeti/HTools/Tags.hs \ src/Ganeti/HTools/Types.hs \ src/Ganeti/Hypervisor/Xen.hs \ src/Ganeti/Hypervisor/Xen/XmParser.hs \ diff --git a/src/Ganeti/HTools/Loader.hs b/src/Ganeti/HTools/Loader.hs index 4fc2dff..3db7381 100644 --- a/src/Ganeti/HTools/Loader.hs +++ b/src/Ganeti/HTools/Loader.hs @@ -69,16 +69,11 @@ import qualified Ganeti.HTools.Cluster as Cluster import Ganeti.BasicTypes import qualified Ganeti.Constants as C +import qualified Ganeti.HTools.Tags as Tags import Ganeti.HTools.Types import Ganeti.Utils import Ganeti.Types (EvacMode) --- * Constants - --- | The exclusion tag prefix. -exTagsPrefix :: String -exTagsPrefix = "htools:iextags:" - -- * Types {-| The iallocator request type. @@ -256,7 +251,7 @@ longestDomain (x:xs) = -- | Extracts the exclusion tags from the cluster configuration. extractExTags :: [String] -> [String] -extractExTags = filter (not . null) . mapMaybe (chompPrefix exTagsPrefix) +extractExTags = filter (not . null) . mapMaybe (chompPrefix Tags.exTagsPrefix) -- | Extracts the common suffix from node\/instance names. commonSuffix :: Node.List -> Instance.List -> String diff --git a/src/Ganeti/HTools/Tags.hs b/src/Ganeti/HTools/Tags.hs new file mode 100644 index 0000000..b9b252d --- /dev/null +++ b/src/Ganeti/HTools/Tags.hs @@ -0,0 +1,46 @@ +{-| Tags + +This module holds all the tag interpretation done by htools. + +-} + +{- + +Copyright (C) 2014 Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-} + +module Ganeti.HTools.Tags + ( exTagsPrefix + ) where + +-- * Constants + +-- | The exclusion tag prefix. +exTagsPrefix :: String +exTagsPrefix = "htools:iextags:" + -- 2.1.0.rc2.206.gedb03e5
