in do
-- that done, we now add the per-group nl/il to the tuple
all_insts4 <-
- mapM (\(gdx, idxs) -> do
- case lookup gdx gni of
+ mapM (\(gdx, idxs) ->
+ case lookup gdx gni of
Nothing -> fail $ "Can't find group index " ++ show gdx
Just (gnl, gil) -> return (gdx, gnl, gil, idxs))
all_insts3
let convert a = genericConvert "Group" xname a
xuuid <- convert "uuid" uuid
xapol <- convert "alloc_policy" apol
- return $ (xuuid, Group.create xname xuuid xapol)
+ return (xuuid, Group.create xname xuuid xapol)
parseGroup v = fail ("Invalid group query result: " ++ show v)
"mload" -> printf "%5.3f" uM
"dload" -> printf "%5.3f" uD
"nload" -> printf "%5.3f" uN
- "ptags" -> intercalate "," . map (\(k, v) -> printf "%s=%d" k v) .
+ "ptags" -> intercalate "," . map (uncurry (printf "%s=%d")) .
Map.toList $ pTags t
"peermap" -> show $ peers t
_ -> T.unknownField
getFakeGroups :: Result [(String, Group.Group)]
getFakeGroups =
- return $ [(defaultGroupID,
- Group.create "default" defaultGroupID AllocPreferred)]
+ return [(defaultGroupID,
+ Group.create "default" defaultGroupID AllocPreferred)]
-- | Construct an instance from a JSON object.
parseInstance :: NameAssoc
{-
-Copyright (C) 2009, 2010 Google Inc.
+Copyright (C) 2009, 2010, 2011 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
loadGroup :: (Monad m) => [String] -> m (String, Group.Group)
loadGroup [name, gid, apol] = do
xapol <- apolFromString apol
- return $ (gid, Group.create name gid xapol)
+ return (gid, Group.create name gid xapol)
loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'"
hPutStrLn stderr $ "Error: " ++ err
exitWith $ ExitFailure 1
Ok rq -> return rq
- r2 <- if isJust (optDataFile opts) || (not . null . optNodeSim) opts
- then do
- cdata <- loadExternalData opts
- let Request rqt _ = r1
- return $ Request rqt cdata
- else return r1
- return r2
+ (if isJust (optDataFile opts) || (not . null . optNodeSim) opts
+ then do
+ cdata <- loadExternalData opts
+ let Request rqt _ = r1
+ return $ Request rqt cdata
+ else return r1)
-- | Main function.
main :: IO ()
{-
-Copyright (C) 2009, 2010 Google Inc.
+Copyright (C) 2009, 2010, 2011 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
when (length ngroups > 1 && isNothing (optGroup opts)) $ do
hPutStrLn stderr "Found multiple node groups:"
mapM_ (hPutStrLn stderr . (" " ++) . Group.name .
- (flip Container.find gl) . fst) ngroups
+ flip Container.find gl . fst) ngroups
hPutStrLn stderr "Aborting."
exitWith $ ExitFailure 1
Nothing -> do
-- TODO: while this is unlikely to happen, log here the
-- actual group data to help debugging
- hPutStrLn stderr $ "Internal failure, missing group idx"
+ hPutStrLn stderr "Internal failure, missing group idx"
exitWith $ ExitFailure 1
Just cdata -> return (Group.name grp, cdata)
return False
Just master -> runJobSet master fin_nl il cmd_jobs)
else return True
- when (not eval) (exitWith (ExitFailure 1))
+ unless eval (exitWith (ExitFailure 1))
let name = local
input_data <- Luxi.loadData lsock
result <- writeData nlen name opts input_data
- when (not result) $ exitWith $ ExitFailure 2
+ unless result $ exitWith $ ExitFailure 2
#ifndef NO_CURL
- results <- mapM (\ name ->
- do
- input_data <- Rapi.loadData name
- writeData nlen name opts input_data
- ) clusters
- when (not $ all id results) $ exitWith (ExitFailure 2)
+ results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts)
+ clusters
+ unless (all id results) $ exitWith (ExitFailure 2)
#else
when (not $ null clusters) $ do
putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"