Revision 596470db
b/src/Ganeti/Query/Network.hs | ||
---|---|---|
158 | 158 |
-- simply iterating over the reservations string. |
159 | 159 |
getReservations :: Maybe Ip4Network -> String -> [Ip4Address] |
160 | 160 |
getReservations Nothing = \_ -> [] |
161 |
getReservations (Just $ Ip4Network net _) =
|
|
161 |
getReservations (Just (Ip4Network net _)) =
|
|
162 | 162 |
reverse . |
163 | 163 |
fst . |
164 | 164 |
foldl' (\(accu, addr) c -> |
b/test/hs/Test/Ganeti/Objects.hs | ||
---|---|---|
242 | 242 |
mac_prefix <- genMaybe genName |
243 | 243 |
net <- arbitrary |
244 | 244 |
net6 <- genMaybe genIp6Net |
245 |
gateway <- genMaybe arbitrary |
|
246 |
gateway6 <- genMaybe genIp6Addr |
|
247 |
res <- liftM Just (genBitString $ netmask2NumHosts netmask) |
|
248 |
ext_res <- liftM Just (genBitString $ netmask2NumHosts netmask) |
|
249 | 245 |
uuid <- arbitrary |
250 |
let n = Network name mac_prefix (Just $ Ip4Network net netmask) net6 gateway |
|
251 |
gateway6 res ext_res uuid 0 Set.empty |
|
246 |
res <- liftM Just (genBitString $ netmask2NumHosts netmask) |
|
247 |
ext_res <- liftM Just (genZeroedBitString $ netmask2NumHosts netmask) |
|
248 |
let n = Network name mac_prefix (Just $ Ip4Network net netmask) net6 Nothing |
|
249 |
Nothing res ext_res uuid 0 Set.empty |
|
252 | 250 |
return n |
253 | 251 |
|
254 | 252 |
-- | Generate an arbitrary string consisting of '0' and '1' of the given length. |
255 | 253 |
genBitString :: Int -> Gen String |
256 | 254 |
genBitString len = vectorOf len (elements "01") |
257 | 255 |
|
256 |
genZeroedBitString :: Int -> Gen String |
|
257 |
genZeroedBitString len = vectorOf len (elements "0") |
|
258 |
|
|
258 | 259 |
-- | Generate an arbitrary string consisting of '0' and '1' of the maximum given |
259 | 260 |
-- length. |
260 | 261 |
genBitStringMaxLen :: Int -> Gen String |
... | ... | |
375 | 376 |
\for net in decoded:\n\ |
376 | 377 |
\ a = network.Network(net)\n\ |
377 | 378 |
\ if net.network:\n\ |
378 |
\ encoded.append((a._GetFreeCount(), a._GetReservedCount(), \\\n\ |
|
379 |
\ encoded.append((a._GetFreeCount(), \\\n\ |
|
380 |
\ a._GetReservedCount(), \\\n\ |
|
379 | 381 |
\ net.ToDict()))\n\ |
380 | 382 |
\ else:\n\ |
381 | 383 |
\ encoded.append((-1, -1, \\\n\ |
b/test/hs/Test/Ganeti/TestCommon.hs | ||
---|---|---|
42 | 42 |
, genName |
43 | 43 |
, genFQDN |
44 | 44 |
, genMaybe |
45 |
, genNothing |
|
45 | 46 |
, genTags |
46 | 47 |
, genFields |
47 | 48 |
, genUniquesList |
... | ... | |
188 | 189 |
genMaybe :: Gen a -> Gen (Maybe a) |
189 | 190 |
genMaybe subgen = frequency [ (1, pure Nothing), (3, Just <$> subgen) ] |
190 | 191 |
|
192 |
genNothing :: a -> Maybe a |
|
193 |
genNothing _ = Nothing |
|
194 |
|
|
191 | 195 |
-- | Defines a tag type. |
192 | 196 |
newtype TagChar = TagChar { tagGetChar :: Char } |
193 | 197 |
|
Also available in: Unified diff