Commit 09872d39 authored by Klaus Aehlig's avatar Klaus Aehlig

Move htools tag constants to a separate module

In this way, we can export some of those constants via
Ganeti/Constants.hs to the python world while still keeping
all the special htools prefixes togehter in an HTools module.
(Note that Ganeti/Constants.hs cannot depend on
Ganeti/HTools/Tags.hs as this would cause a cylic dependency.)
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 2259e9b2
......@@ -144,6 +144,7 @@ HS_DIRS = \
src/Ganeti/HTools/Backend \
src/Ganeti/HTools/Cluster \
src/Ganeti/HTools/Program \
src/Ganeti/HTools/Tags \
src/Ganeti/Hypervisor \
src/Ganeti/Hypervisor/Xen \
src/Ganeti/JQScheduler \
......@@ -932,6 +933,7 @@ HS_LIB_SRCS = \
src/Ganeti/HTools/Program/Hroller.hs \
src/Ganeti/HTools/Program/Main.hs \
src/Ganeti/HTools/Tags.hs \
src/Ganeti/HTools/Tags/Constants.hs \
src/Ganeti/HTools/Types.hs \
src/Ganeti/Hypervisor/Xen.hs \
src/Ganeti/Hypervisor/Xen/XmParser.hs \
......
......@@ -71,6 +71,7 @@ import qualified Ganeti.HTools.Cluster.Moves as Moves
import Ganeti.BasicTypes
import qualified Ganeti.HTools.Tags as Tags
import qualified Ganeti.HTools.Tags.Constants as TagsC
import Ganeti.HTools.Types
import Ganeti.Utils
import Ganeti.Types (EvacMode)
......@@ -249,8 +250,8 @@ setArPolicy ctags gl nl il time =
getArPolicy :: [String] -> ClockTime -> Maybe AutoRepairPolicy
getArPolicy tags time =
let enabled = mapMaybe (autoRepairTypeFromRaw <=<
chompPrefix Tags.autoRepairTagEnabled) tags
suspended = mapMaybe (chompPrefix Tags.autoRepairTagSuspended) tags
chompPrefix TagsC.autoRepairTagEnabled) tags
suspended = mapMaybe (chompPrefix TagsC.autoRepairTagSuspended) tags
futureTs = filter (> time) . map (flip TOD 0) $
mapMaybe (tryRead "auto-repair suspend time") suspended
in
......@@ -275,7 +276,7 @@ longestDomain (x:xs) =
-- | Extracts the exclusion tags from the cluster configuration.
extractExTags :: [String] -> [String]
extractExTags = filter (not . null) . mapMaybe (chompPrefix Tags.exTagsPrefix)
extractExTags = filter (not . null) . mapMaybe (chompPrefix TagsC.exTagsPrefix)
-- | Extracts the common suffix from node\/instance names.
commonSuffix :: Node.List -> Instance.List -> String
......
......@@ -63,7 +63,7 @@ import qualified Ganeti.Path as Path
import Ganeti.HTools.CLI
import Ganeti.HTools.Loader
import Ganeti.HTools.ExtLoader
import qualified Ganeti.HTools.Tags as Tags
import qualified Ganeti.HTools.Tags.Constants as Tags
import Ganeti.HTools.Types
import qualified Ganeti.HTools.Container as Container
import qualified Ganeti.HTools.Instance as Instance
......
......@@ -58,7 +58,8 @@ import Ganeti.HTools.ExtLoader
import qualified Ganeti.HTools.Instance as Instance
import Ganeti.HTools.Loader
import qualified Ganeti.HTools.Node as Node
import Ganeti.HTools.Tags (hasStandbyTag, standbyAuto)
import Ganeti.HTools.Tags (hasStandbyTag)
import Ganeti.HTools.Tags.Constants (standbyAuto)
import Ganeti.HTools.Types
import Ganeti.JQueue (currentTimestamp, reasonTrailTimestamp)
import Ganeti.JQueue.Objects (Timestamp)
......
......@@ -6,7 +6,7 @@ This module holds all the tag interpretation done by htools.
{-
Copyright (C) 2014 Google Inc.
Copyright (C) 2014, 2015 Google Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
......@@ -35,14 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-}
module Ganeti.HTools.Tags
( exTagsPrefix
, standbyAuto
, hasStandbyTag
, autoRepairTagPrefix
, autoRepairTagEnabled
, autoRepairTagPending
, autoRepairTagResult
, autoRepairTagSuspended
( hasStandbyTag
, getMigRestrictions
, getRecvMigRestrictions
, getLocations
......@@ -54,51 +47,9 @@ import Data.Maybe (mapMaybe)
import qualified Data.Set as S
import qualified Ganeti.HTools.Node as Node
-- * Constants
-- | The exclusion tag prefix. Instance tags starting with this prefix
-- describe a service provided by the instance. Instances providing the
-- same service at not places on the same node.
exTagsPrefix :: String
exTagsPrefix = "htools:iextags:"
-- | The tag-prefix indicating that hsqueeze should consider a node
-- as being standby.
standbyPrefix :: String
standbyPrefix = "htools:standby:"
-- | The prefix for migration tags
migrationPrefix :: String
migrationPrefix = "htools:migration:"
-- | Prefix of tags allowing migration
allowMigrationPrefix :: String
allowMigrationPrefix = "htools:allowmigration:"
-- | The prefix for location tags.
locationPrefix :: String
locationPrefix = "htools:nlocation:"
-- | The tag to be added to nodes that were shutdown by hsqueeze.
standbyAuto :: String
standbyAuto = "htools:standby:auto"
-- | Auto-repair tag prefix
autoRepairTagPrefix :: String
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
autoRepairTagEnabled :: String
autoRepairTagEnabled = autoRepairTagPrefix
autoRepairTagPending :: String
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
autoRepairTagResult :: String
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
autoRepairTagSuspended :: String
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
import Ganeti.HTools.Tags.Constants ( standbyPrefix
, migrationPrefix, allowMigrationPrefix
, locationPrefix )
-- * Predicates
......
{-| Tag constants
This module holds all the special tag prefixes honored
by Ganeti's htools. The module itself does not depend
on anything Ganeti specific so that it can be imported
anywhere.
-}
{-
Copyright (C) 2014, 2015 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.Constants
( exTagsPrefix
, standbyPrefix
, migrationPrefix
, allowMigrationPrefix
, locationPrefix
, standbyAuto
, autoRepairTagPrefix
, autoRepairTagEnabled
, autoRepairTagPending
, autoRepairTagResult
, autoRepairTagSuspended
) where
-- | The exclusion tag prefix. Instance tags starting with this prefix
-- describe a service provided by the instance. Instances providing the
-- same service at not places on the same node.
exTagsPrefix :: String
exTagsPrefix = "htools:iextags:"
-- | The tag-prefix indicating that hsqueeze should consider a node
-- as being standby.
standbyPrefix :: String
standbyPrefix = "htools:standby:"
-- | The prefix for migration tags
migrationPrefix :: String
migrationPrefix = "htools:migration:"
-- | Prefix of tags allowing migration
allowMigrationPrefix :: String
allowMigrationPrefix = "htools:allowmigration:"
-- | The prefix for location tags.
locationPrefix :: String
locationPrefix = "htools:nlocation:"
-- | The tag to be added to nodes that were shutdown by hsqueeze.
standbyAuto :: String
standbyAuto = "htools:standby:auto"
-- | Auto-repair tag prefix
autoRepairTagPrefix :: String
autoRepairTagPrefix = "ganeti:watcher:autorepair:"
autoRepairTagEnabled :: String
autoRepairTagEnabled = autoRepairTagPrefix
autoRepairTagPending :: String
autoRepairTagPending = autoRepairTagPrefix ++ "pending:"
autoRepairTagResult :: String
autoRepairTagResult = autoRepairTagPrefix ++ "result:"
autoRepairTagSuspended :: String
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:"
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