+-- | Generas an arbitrary node based on sizing information.
+genNode :: Maybe Int -- ^ Minimum node size in terms of units
+ -> Maybe Int -- ^ Maximum node size (when Nothing, bounded
+ -- just by the max... constants)
+ -> Gen Node.Node
+genNode min_multiplier max_multiplier = do
+ let (base_mem, base_dsk, base_cpu) =
+ case min_multiplier of
+ Just mm -> (mm * Types.unitMem,
+ mm * Types.unitDsk,
+ mm * Types.unitCpu)
+ Nothing -> (0, 0, 0)
+ (top_mem, top_dsk, top_cpu) =
+ case max_multiplier of
+ Just mm -> (mm * Types.unitMem,
+ mm * Types.unitDsk,
+ mm * Types.unitCpu)
+ Nothing -> (maxMem, maxDsk, maxCpu)
+ name <- getFQDN
+ mem_t <- choose (base_mem, top_mem)
+ mem_f <- choose (base_mem, mem_t)
+ mem_n <- choose (0, mem_t - mem_f)
+ dsk_t <- choose (base_dsk, top_dsk)
+ dsk_f <- choose (base_dsk, dsk_t)
+ cpu_t <- choose (base_cpu, top_cpu)
+ offl <- arbitrary
+ let n = Node.create name (fromIntegral mem_t) mem_n mem_f
+ (fromIntegral dsk_t) dsk_f (fromIntegral cpu_t) offl 0
+ return $ Node.buildPeers n Container.empty
+