On Wed, Dec 1, 2010 at 14:47, Iustin Pop <[email protected]> wrote:
> Actually, this just moves the functions from the QC module to Types, and
> removes a duplicate entry from Cluster.
> ---
> Ganeti/HTools/Cluster.hs | 3 ---
> Ganeti/HTools/QC.hs | 14 +++-----------
> Ganeti/HTools/Types.hs | 11 +++++++++++
> 3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/Ganeti/HTools/Cluster.hs b/Ganeti/HTools/Cluster.hs
> index 1ad304d..7172cff 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 b4ab4b0..206d86e 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 7a0c6db..96c6f0f 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
> --
> 1.7.2.3
>
>
LGTM