diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs index 1ad304d7011837d53525d808d8959272270608c4..7172cff076ea51b43fba8a60394a4af67c043a32 100644 --- a/Ganeti/HTools/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -854,9 +854,6 @@ instanceGroup nl i = findSplitInstances :: Node.List -> Instance.List -> [Instance.Instance] findSplitInstances nl il = filter (not . isOk . instanceGroup nl) (Container.elems il) - where isOk x = case x of - Bad _ -> False - _ -> True -- | Splits a cluster into the component node groups splitCluster :: Node.List -> Instance.List -> diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index b4ab4b0d6d48dce0f0182ae6ac87056ba35afcb0..206d86ed17c4eed2af16ba686ac2af12be9085e7 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -85,14 +85,6 @@ isFailure :: Types.OpResult a -> Bool isFailure (Types.OpFail _) = True isFailure _ = False --- | Simple checker for whether Result is fail or pass -isOk :: Types.Result a -> Bool -isOk (Types.Ok _ ) = True -isOk _ = False - -isBad :: Types.Result a -> Bool -isBad = not . isOk - -- | Update an instance to be smaller than a node setInstanceSmallerThanNode node inst = inst { Instance.mem = Node.availMem node `div` 2 @@ -388,7 +380,7 @@ prop_Instance_shrinkMG inst = prop_Instance_shrinkMF inst = Instance.mem inst < 2 * Types.unitMem ==> - isBad $ Instance.shrinkByType inst Types.FailMem + Types.isBad $ Instance.shrinkByType inst Types.FailMem prop_Instance_shrinkCG inst = Instance.vcpus inst >= 2 * Types.unitCpu ==> @@ -399,7 +391,7 @@ prop_Instance_shrinkCG inst = prop_Instance_shrinkCF inst = Instance.vcpus inst < 2 * Types.unitCpu ==> - isBad $ Instance.shrinkByType inst Types.FailCPU + Types.isBad $ Instance.shrinkByType inst Types.FailCPU prop_Instance_shrinkDG inst = Instance.dsk inst >= 2 * Types.unitDsk ==> @@ -410,7 +402,7 @@ prop_Instance_shrinkDG inst = prop_Instance_shrinkDF inst = Instance.dsk inst < 2 * Types.unitDsk ==> - isBad $ Instance.shrinkByType inst Types.FailDisk + Types.isBad $ Instance.shrinkByType inst Types.FailDisk prop_Instance_setMovable inst m = Instance.movable inst' == m diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs index 7a0c6db90eef67b8b6f36117ab9c3ae9a12a14f4..96c6f0f7e7b78a3bac3b37f005f95b92a2e54a32 100644 --- a/Ganeti/HTools/Types.hs +++ b/Ganeti/HTools/Types.hs @@ -47,6 +47,8 @@ module Ganeti.HTools.Types , MoveJob , JobSet , Result(..) + , isOk + , isBad , Element(..) , FailMode(..) , FailStats @@ -178,6 +180,15 @@ instance Monad Result where return = Ok fail = Bad +-- | Simple checker for whether Result is OK +isOk :: Result a -> Bool +isOk (Ok _) = True +isOk _ = False + +-- | Simple checker for whether Result is a failure +isBad :: Result a -> Bool +isBad = not . isOk + -- | Reason for an operation's falure data FailMode = FailMem -- ^ Failed due to not enough RAM | FailDisk -- ^ Failed due to not enough disk