TDiskIndex = TAnd(TNonNegativeInt, lambda val: val < constants.MAX_DISKS)
TReplaceDisksMode = TElemOf(constants.REPLACE_MODES)
TDiskTemplate = TElemOf(constants.DISK_TEMPLATES)
-TNodeEvacMode = TElemOf(constants.NODE_EVAC_MODES)
+TEvacMode = TElemOf(constants.NODE_EVAC_MODES)
TIAllocatorTestDir = TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS)
TIAllocatorMode = TElemOf(constants.VALID_IALLOCATOR_MODES)
MODE = constants.IALLOCATOR_MODE_NODE_EVAC
REQ_PARAMS = [
("instances", _STRING_LIST),
- ("evac_mode", ht.TNodeEvacMode),
+ ("evac_mode", ht.TEvacMode),
]
REQ_RESULT = _NEVAC_RESULT
import Ganeti.HTools.Loader
import Ganeti.HTools.Types
import Ganeti.JSON
+import Ganeti.Types (EvacMode(ChangePrimary, ChangeSecondary))
import Ganeti.Utils
{-# ANN module "HLint: ignore Eta reduce" #-}
import Ganeti.Compat
import qualified Ganeti.OpCodes as OpCodes
import Ganeti.Utils
-import Ganeti.Types (mkNonEmpty)
+import Ganeti.Types (EvacMode(..), mkNonEmpty)
-- * Types
import qualified Ganeti.Constants as C
import Ganeti.HTools.Types
import Ganeti.Utils
+import Ganeti.Types (EvacMode)
-- * Constants
, FailStats
, OpResult
, opToResult
- , EvacMode(..)
, ISpec(..)
, MinMaxISpecs(..)
, IPolicy(..)
-- | Updates the index of the element
setIdx :: a -> Int -> a
--- | The iallocator node-evacuate evac_mode type.
-$(THH.declareSADT "EvacMode"
- [ ("ChangePrimary", 'C.iallocatorNevacPri)
- , ("ChangeSecondary", 'C.iallocatorNevacSec)
- , ("ChangeAll", 'C.iallocatorNevacAll)
- ])
-$(THH.makeJSONInstance ''EvacMode)
-
-- | The repair modes for the auto-repair tool.
$(THH.declareSADT "AutoRepairType"
-- Order is important here: from least destructive to most.
-- * Node evacuation
nodeEvacPri :: String
-nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
+nodeEvacPri = Types.evacModeToRaw ChangePrimary
nodeEvacSec :: String
-nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
+nodeEvacSec = Types.evacModeToRaw ChangeSecondary
nodeEvacAll :: String
-nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
+nodeEvacAll = Types.evacModeToRaw ChangeAll
nodeEvacModes :: FrozenSet String
-nodeEvacModes = ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
+nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
-- * Job status
pEvacMode :: Field
pEvacMode =
withDoc "Node evacuation mode" .
- renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |]
+ renameField "EvacMode" $ simpleField "mode" [t| EvacMode |]
pInstanceName :: Field
pInstanceName =
withDoc "IAllocator evac mode" .
renameField "IAllocatorEvacMode" .
optionalField $
- simpleField "evac_mode" [t| NodeEvacMode |]
+ simpleField "evac_mode" [t| EvacMode |]
pIAllocatorSpindleUse :: Field
pIAllocatorSpindleUse =
, oobStatusToRaw
, StorageType(..)
, storageTypeToRaw
- , NodeEvacMode(..)
- , nodeEvacModeToRaw
+ , EvacMode(..)
+ , evacModeToRaw
, FileDriver(..)
, fileDriverToRaw
, InstCreateMode(..)
addParamsToStorageUnit _ (SURaw StorageRados key) = SURados key
-- | Node evac modes.
-$(THH.declareLADT ''String "NodeEvacMode"
- [ ("NEvacPrimary", "primary-only")
- , ("NEvacSecondary", "secondary-only")
- , ("NEvacAll", "all")
+--
+-- This is part of the 'IAllocator' interface and it is used, for
+-- example, in 'Ganeti.HTools.Loader.RqType'. However, it must reside
+-- in this module, and not in 'Ganeti.HTools.Types', because it is
+-- also used by 'Ganeti.HsConstants'.
+$(THH.declareLADT ''String "EvacMode"
+ [ ("ChangePrimary", "primary-only")
+ , ("ChangeSecondary", "secondary-only")
+ , ("ChangeAll", "all")
])
-$(THH.makeJSONInstance ''NodeEvacMode)
+$(THH.makeJSONInstance ''EvacMode)
-- | The file driver type.
$(THH.declareLADT ''String "FileDriver"
import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Types as Types
+import qualified Ganeti.Types as Types (EvacMode(..))
{-# ANN module "HLint: ignore Use camelCase" #-}
, Types.AllocPolicy(..)
, Types.DiskTemplate(..)
, Types.FailMode(..)
- , Types.EvacMode(..)
, Types.ISpec(..)
, Types.IPolicy(..)
, nullIPolicy
$(genArbitrary ''Types.FailMode)
-$(genArbitrary ''Types.EvacMode)
-
instance Arbitrary a => Arbitrary (Types.OpResult a) where
arbitrary = arbitrary >>= \c ->
if c
prop_IPolicy_serialisation :: Types.IPolicy -> Property
prop_IPolicy_serialisation = testSerialisation
-prop_EvacMode_serialisation :: Types.EvacMode -> Property
-prop_EvacMode_serialisation = testSerialisation
-
prop_opToResult :: Types.OpResult Int -> Property
prop_opToResult op =
case op of
testSuite "HTools/Types"
[ 'prop_ISpec_serialisation
, 'prop_IPolicy_serialisation
- , 'prop_EvacMode_serialisation
, 'prop_opToResult
, 'prop_eitherToResult
, 'case_AutoRepairType_sort
instance Arbitrary StorageType where
arbitrary = elements allStorageTypes
-$(genArbitrary ''NodeEvacMode)
+$(genArbitrary ''EvacMode)
$(genArbitrary ''FileDriver)
prop_StorageType_serialisation = testSerialisation
-- | Test 'NodeEvacMode' serialisation.
-prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property
+prop_NodeEvacMode_serialisation :: EvacMode -> Property
prop_NodeEvacMode_serialisation = testSerialisation
-- | Test 'FileDriver' serialisation.