diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 983b30e6772bb8910beebb43564eeb4d8bec77b4..e9e423afda5379deeabad98cb5fa976a7caae722 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -563,7 +563,7 @@ checkInstanceMove nodes_idx disk_moves inst_moves ini_tbl target = osdx = Instance.sNode target bad_nodes = [opdx, osdx] nodes = filter (`notElem` bad_nodes) nodes_idx - mir_type = templateMirrorType $ Instance.diskTemplate target + mir_type = Instance.mirrorType target use_secondary = elem osdx nodes_idx && inst_moves aft_failover = if mir_type == MirrorInternal && use_secondary -- if drbd and allowed to failover @@ -970,7 +970,7 @@ evacOneNodeOnly :: Node.List -- ^ The node list (cluster-wide) -- for allocation -> Result (Node.List, Instance.List, [OpCodes.OpCode]) evacOneNodeOnly nl il inst gdx avail_nodes = do - op_fn <- case templateMirrorType (Instance.diskTemplate inst) of + op_fn <- case Instance.mirrorType inst of MirrorNone -> Bad "Can't relocate/evacuate non-mirrored instances" MirrorInternal -> Ok ReplaceSecondary MirrorExternal -> Ok FailoverToAny diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index 3d1762689959732602df59de12781e7057d2d5b1..ae349054e29e18f931626561b6abe48bf57287d4 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -270,7 +270,7 @@ processRelocate gl nl il idx 1 exndx = do let orig = Container.find idx il sorig = Instance.sNode orig porig = Instance.pNode orig - mir_type = templateMirrorType $ Instance.diskTemplate orig + mir_type = Instance.mirrorType orig (exp_node, node_type, reloc_type) <- case mir_type of MirrorNone -> fail "Can't relocate non-mirrored instances" diff --git a/htools/Ganeti/HTools/Instance.hs b/htools/Ganeti/HTools/Instance.hs index 269f3209c8d617c443d62cf100d44052594e5bf7..42871b393e93b48bc655270ac677af493a983967 100644 --- a/htools/Ganeti/HTools/Instance.hs +++ b/htools/Ganeti/HTools/Instance.hs @@ -54,6 +54,7 @@ module Ganeti.HTools.Instance , requiredNodes , allNodes , usesLocalStorage + , mirrorType ) where import qualified Ganeti.HTools.Types as T @@ -304,3 +305,7 @@ usesLocalStorage = (`elem` localStorageTemplates) . diskTemplate -- | Checks whether a given disk template supported moves. supportsMoves :: T.DiskTemplate -> Bool supportsMoves = (`elem` movableDiskTemplates) + +-- | A simple wrapper over 'T.templateMirrorType'. +mirrorType :: Instance -> T.MirrorType +mirrorType = T.templateMirrorType . diskTemplate diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index a57ed4bd96d5efd6ff6ef5acb7d0e9d30ea5f6e1..35225def5911b0fd1b1249cc29eca10b4abc379c 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -237,8 +237,7 @@ genUniquesList cnt = -- | Checks if an instance is mirrored. isMirrored :: Instance.Instance -> Bool -isMirrored = - (/= Types.MirrorNone) . Types.templateMirrorType . Instance.diskTemplate +isMirrored = (/= Types.MirrorNone) . Instance.mirrorType -- | Returns the possible change node types for a disk template. evacModeOptions :: Types.MirrorType -> [Types.EvacMode] @@ -1297,8 +1296,8 @@ prop_ClusterAllocEvacuate = conjoin $ map (\mode -> check_EvacMode defGroup inst' $ Cluster.tryNodeEvac defGroupList nl il mode [Instance.idx inst']) . - evacModeOptions . Types.templateMirrorType . - Instance.diskTemplate $ inst' + evacModeOptions . + Instance.mirrorType $ inst' -- | Checks that on a 4-8 node cluster with two node groups, once we -- allocate an instance on the first node group, we can also change