Revision d067f40b
b/lib/ht.py | ||
---|---|---|
537 | 537 |
TDiskIndex = TAnd(TNonNegativeInt, lambda val: val < constants.MAX_DISKS) |
538 | 538 |
TReplaceDisksMode = TElemOf(constants.REPLACE_MODES) |
539 | 539 |
TDiskTemplate = TElemOf(constants.DISK_TEMPLATES) |
540 |
TNodeEvacMode = TElemOf(constants.NODE_EVAC_MODES)
|
|
540 |
TEvacMode = TElemOf(constants.NODE_EVAC_MODES) |
|
541 | 541 |
TIAllocatorTestDir = TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS) |
542 | 542 |
TIAllocatorMode = TElemOf(constants.VALID_IALLOCATOR_MODES) |
543 | 543 |
|
b/lib/masterd/iallocator.py | ||
---|---|---|
336 | 336 |
MODE = constants.IALLOCATOR_MODE_NODE_EVAC |
337 | 337 |
REQ_PARAMS = [ |
338 | 338 |
("instances", _STRING_LIST), |
339 |
("evac_mode", ht.TNodeEvacMode),
|
|
339 |
("evac_mode", ht.TEvacMode), |
|
340 | 340 |
] |
341 | 341 |
REQ_RESULT = _NEVAC_RESULT |
342 | 342 |
|
b/src/Ganeti/HTools/Backend/IAlloc.hs | ||
---|---|---|
50 | 50 |
import Ganeti.HTools.Loader |
51 | 51 |
import Ganeti.HTools.Types |
52 | 52 |
import Ganeti.JSON |
53 |
import Ganeti.Types (EvacMode(ChangePrimary, ChangeSecondary)) |
|
53 | 54 |
import Ganeti.Utils |
54 | 55 |
|
55 | 56 |
{-# ANN module "HLint: ignore Eta reduce" #-} |
b/src/Ganeti/HTools/Cluster.hs | ||
---|---|---|
94 | 94 |
import Ganeti.Compat |
95 | 95 |
import qualified Ganeti.OpCodes as OpCodes |
96 | 96 |
import Ganeti.Utils |
97 |
import Ganeti.Types (mkNonEmpty) |
|
97 |
import Ganeti.Types (EvacMode(..), mkNonEmpty)
|
|
98 | 98 |
|
99 | 99 |
-- * Types |
100 | 100 |
|
b/src/Ganeti/HTools/Loader.hs | ||
---|---|---|
60 | 60 |
import qualified Ganeti.Constants as C |
61 | 61 |
import Ganeti.HTools.Types |
62 | 62 |
import Ganeti.Utils |
63 |
import Ganeti.Types (EvacMode) |
|
63 | 64 |
|
64 | 65 |
-- * Constants |
65 | 66 |
|
b/src/Ganeti/HTools/Types.hs | ||
---|---|---|
69 | 69 |
, FailStats |
70 | 70 |
, OpResult |
71 | 71 |
, opToResult |
72 |
, EvacMode(..) |
|
73 | 72 |
, ISpec(..) |
74 | 73 |
, MinMaxISpecs(..) |
75 | 74 |
, IPolicy(..) |
... | ... | |
378 | 377 |
-- | Updates the index of the element |
379 | 378 |
setIdx :: a -> Int -> a |
380 | 379 |
|
381 |
-- | The iallocator node-evacuate evac_mode type. |
|
382 |
$(THH.declareSADT "EvacMode" |
|
383 |
[ ("ChangePrimary", 'C.iallocatorNevacPri) |
|
384 |
, ("ChangeSecondary", 'C.iallocatorNevacSec) |
|
385 |
, ("ChangeAll", 'C.iallocatorNevacAll) |
|
386 |
]) |
|
387 |
$(THH.makeJSONInstance ''EvacMode) |
|
388 |
|
|
389 | 380 |
-- | The repair modes for the auto-repair tool. |
390 | 381 |
$(THH.declareSADT "AutoRepairType" |
391 | 382 |
-- Order is important here: from least destructive to most. |
b/src/Ganeti/HsConstants.hs | ||
---|---|---|
1100 | 1100 |
-- * Node evacuation |
1101 | 1101 |
|
1102 | 1102 |
nodeEvacPri :: String |
1103 |
nodeEvacPri = Types.nodeEvacModeToRaw NEvacPrimary
|
|
1103 |
nodeEvacPri = Types.evacModeToRaw ChangePrimary
|
|
1104 | 1104 |
|
1105 | 1105 |
nodeEvacSec :: String |
1106 |
nodeEvacSec = Types.nodeEvacModeToRaw NEvacSecondary
|
|
1106 |
nodeEvacSec = Types.evacModeToRaw ChangeSecondary
|
|
1107 | 1107 |
|
1108 | 1108 |
nodeEvacAll :: String |
1109 |
nodeEvacAll = Types.nodeEvacModeToRaw NEvacAll
|
|
1109 |
nodeEvacAll = Types.evacModeToRaw ChangeAll
|
|
1110 | 1110 |
|
1111 | 1111 |
nodeEvacModes :: FrozenSet String |
1112 |
nodeEvacModes = ConstantUtils.mkSet $ map Types.nodeEvacModeToRaw [minBound..]
|
|
1112 |
nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
|
|
1113 | 1113 |
|
1114 | 1114 |
-- * Job status |
1115 | 1115 |
|
b/src/Ganeti/OpParams.hs | ||
---|---|---|
940 | 940 |
pEvacMode :: Field |
941 | 941 |
pEvacMode = |
942 | 942 |
withDoc "Node evacuation mode" . |
943 |
renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |]
|
|
943 |
renameField "EvacMode" $ simpleField "mode" [t| EvacMode |] |
|
944 | 944 |
|
945 | 945 |
pInstanceName :: Field |
946 | 946 |
pInstanceName = |
... | ... | |
1485 | 1485 |
withDoc "IAllocator evac mode" . |
1486 | 1486 |
renameField "IAllocatorEvacMode" . |
1487 | 1487 |
optionalField $ |
1488 |
simpleField "evac_mode" [t| NodeEvacMode |]
|
|
1488 |
simpleField "evac_mode" [t| EvacMode |] |
|
1489 | 1489 |
|
1490 | 1490 |
pIAllocatorSpindleUse :: Field |
1491 | 1491 |
pIAllocatorSpindleUse = |
b/src/Ganeti/Types.hs | ||
---|---|---|
82 | 82 |
, oobStatusToRaw |
83 | 83 |
, StorageType(..) |
84 | 84 |
, storageTypeToRaw |
85 |
, NodeEvacMode(..)
|
|
86 |
, nodeEvacModeToRaw
|
|
85 |
, EvacMode(..) |
|
86 |
, evacModeToRaw
|
|
87 | 87 |
, FileDriver(..) |
88 | 88 |
, fileDriverToRaw |
89 | 89 |
, InstCreateMode(..) |
... | ... | |
512 | 512 |
addParamsToStorageUnit _ (SURaw StorageRados key) = SURados key |
513 | 513 |
|
514 | 514 |
-- | Node evac modes. |
515 |
$(THH.declareLADT ''String "NodeEvacMode" |
|
516 |
[ ("NEvacPrimary", "primary-only") |
|
517 |
, ("NEvacSecondary", "secondary-only") |
|
518 |
, ("NEvacAll", "all") |
|
515 |
-- |
|
516 |
-- This is part of the 'IAllocator' interface and it is used, for |
|
517 |
-- example, in 'Ganeti.HTools.Loader.RqType'. However, it must reside |
|
518 |
-- in this module, and not in 'Ganeti.HTools.Types', because it is |
|
519 |
-- also used by 'Ganeti.HsConstants'. |
|
520 |
$(THH.declareLADT ''String "EvacMode" |
|
521 |
[ ("ChangePrimary", "primary-only") |
|
522 |
, ("ChangeSecondary", "secondary-only") |
|
523 |
, ("ChangeAll", "all") |
|
519 | 524 |
]) |
520 |
$(THH.makeJSONInstance ''NodeEvacMode)
|
|
525 |
$(THH.makeJSONInstance ''EvacMode) |
|
521 | 526 |
|
522 | 527 |
-- | The file driver type. |
523 | 528 |
$(THH.declareLADT ''String "FileDriver" |
b/test/hs/Test/Ganeti/HTools/Cluster.hs | ||
---|---|---|
48 | 48 |
import qualified Ganeti.HTools.Instance as Instance |
49 | 49 |
import qualified Ganeti.HTools.Node as Node |
50 | 50 |
import qualified Ganeti.HTools.Types as Types |
51 |
import qualified Ganeti.Types as Types (EvacMode(..)) |
|
51 | 52 |
|
52 | 53 |
{-# ANN module "HLint: ignore Use camelCase" #-} |
53 | 54 |
|
b/test/hs/Test/Ganeti/HTools/Types.hs | ||
---|---|---|
31 | 31 |
, Types.AllocPolicy(..) |
32 | 32 |
, Types.DiskTemplate(..) |
33 | 33 |
, Types.FailMode(..) |
34 |
, Types.EvacMode(..) |
|
35 | 34 |
, Types.ISpec(..) |
36 | 35 |
, Types.IPolicy(..) |
37 | 36 |
, nullIPolicy |
... | ... | |
61 | 60 |
|
62 | 61 |
$(genArbitrary ''Types.FailMode) |
63 | 62 |
|
64 |
$(genArbitrary ''Types.EvacMode) |
|
65 |
|
|
66 | 63 |
instance Arbitrary a => Arbitrary (Types.OpResult a) where |
67 | 64 |
arbitrary = arbitrary >>= \c -> |
68 | 65 |
if c |
... | ... | |
155 | 152 |
prop_IPolicy_serialisation :: Types.IPolicy -> Property |
156 | 153 |
prop_IPolicy_serialisation = testSerialisation |
157 | 154 |
|
158 |
prop_EvacMode_serialisation :: Types.EvacMode -> Property |
|
159 |
prop_EvacMode_serialisation = testSerialisation |
|
160 |
|
|
161 | 155 |
prop_opToResult :: Types.OpResult Int -> Property |
162 | 156 |
prop_opToResult op = |
163 | 157 |
case op of |
... | ... | |
200 | 194 |
testSuite "HTools/Types" |
201 | 195 |
[ 'prop_ISpec_serialisation |
202 | 196 |
, 'prop_IPolicy_serialisation |
203 |
, 'prop_EvacMode_serialisation |
|
204 | 197 |
, 'prop_opToResult |
205 | 198 |
, 'prop_eitherToResult |
206 | 199 |
, 'case_AutoRepairType_sort |
b/test/hs/Test/Ganeti/Types.hs | ||
---|---|---|
115 | 115 |
instance Arbitrary StorageType where |
116 | 116 |
arbitrary = elements allStorageTypes |
117 | 117 |
|
118 |
$(genArbitrary ''NodeEvacMode)
|
|
118 |
$(genArbitrary ''EvacMode) |
|
119 | 119 |
|
120 | 120 |
$(genArbitrary ''FileDriver) |
121 | 121 |
|
... | ... | |
269 | 269 |
prop_StorageType_serialisation = testSerialisation |
270 | 270 |
|
271 | 271 |
-- | Test 'NodeEvacMode' serialisation. |
272 |
prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property
|
|
272 |
prop_NodeEvacMode_serialisation :: EvacMode -> Property |
|
273 | 273 |
prop_NodeEvacMode_serialisation = testSerialisation |
274 | 274 |
|
275 | 275 |
-- | Test 'FileDriver' serialisation. |
Also available in: Unified diff