Revision 06fb841e

b/Ganeti/HTools/Cluster.hs
854 854
findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance]
855 855
findSplitInstances nl il =
856 856
  filter (not . isOk . instanceGroup nl) (Container.elems il)
857
  where isOk x = case x of
858
          Bad _ -> False
859
          _ -> True
860 857

  
861 858
-- | Splits a cluster into the component node groups
862 859
splitCluster :: Node.List -> Instance.List ->
b/Ganeti/HTools/QC.hs
85 85
isFailure (Types.OpFail _) = True
86 86
isFailure _ = False
87 87

  
88
-- | Simple checker for whether Result is fail or pass
89
isOk :: Types.Result a -> Bool
90
isOk (Types.Ok _ ) = True
91
isOk _ = False
92

  
93
isBad :: Types.Result a  -> Bool
94
isBad = not . isOk
95

  
96 88
-- | Update an instance to be smaller than a node
97 89
setInstanceSmallerThanNode node inst =
98 90
    inst { Instance.mem = Node.availMem node `div` 2
......
388 380

  
389 381
prop_Instance_shrinkMF inst =
390 382
    Instance.mem inst < 2 * Types.unitMem ==>
391
        isBad $ Instance.shrinkByType inst Types.FailMem
383
        Types.isBad $ Instance.shrinkByType inst Types.FailMem
392 384

  
393 385
prop_Instance_shrinkCG inst =
394 386
    Instance.vcpus inst >= 2 * Types.unitCpu ==>
......
399 391

  
400 392
prop_Instance_shrinkCF inst =
401 393
    Instance.vcpus inst < 2 * Types.unitCpu ==>
402
        isBad $ Instance.shrinkByType inst Types.FailCPU
394
        Types.isBad $ Instance.shrinkByType inst Types.FailCPU
403 395

  
404 396
prop_Instance_shrinkDG inst =
405 397
    Instance.dsk inst >= 2 * Types.unitDsk ==>
......
410 402

  
411 403
prop_Instance_shrinkDF inst =
412 404
    Instance.dsk inst < 2 * Types.unitDsk ==>
413
        isBad $ Instance.shrinkByType inst Types.FailDisk
405
        Types.isBad $ Instance.shrinkByType inst Types.FailDisk
414 406

  
415 407
prop_Instance_setMovable inst m =
416 408
    Instance.movable inst' == m
b/Ganeti/HTools/Types.hs
47 47
    , MoveJob
48 48
    , JobSet
49 49
    , Result(..)
50
    , isOk
51
    , isBad
50 52
    , Element(..)
51 53
    , FailMode(..)
52 54
    , FailStats
......
178 180
    return = Ok
179 181
    fail = Bad
180 182

  
183
-- | Simple checker for whether Result is OK
184
isOk :: Result a -> Bool
185
isOk (Ok _) = True
186
isOk _ = False
187

  
188
-- | Simple checker for whether Result is a failure
189
isBad :: Result a  -> Bool
190
isBad = not . isOk
191

  
181 192
-- | Reason for an operation's falure
182 193
data FailMode = FailMem  -- ^ Failed due to not enough RAM
183 194
              | FailDisk -- ^ Failed due to not enough disk

Also available in: Unified diff