Revision d5072e4c

b/htools/Ganeti/HTools/Cluster.hs
830 830
    in do
831 831
      -- that done, we now add the per-group nl/il to the tuple
832 832
      all_insts4 <-
833
          mapM (\(gdx, idxs) -> do
834
                  case lookup gdx gni of
833
          mapM (\(gdx, idxs) ->
834
                case lookup gdx gni of
835 835
                    Nothing -> fail $ "Can't find group index " ++ show gdx
836 836
                    Just (gnl, gil) -> return (gdx, gnl, gil, idxs))
837 837
          all_insts3
b/htools/Ganeti/HTools/Luxi.hs
177 177
  let convert a = genericConvert "Group" xname a
178 178
  xuuid <- convert "uuid" uuid
179 179
  xapol <- convert "alloc_policy" apol
180
  return $ (xuuid, Group.create xname xuuid xapol)
180
  return (xuuid, Group.create xname xuuid xapol)
181 181

  
182 182
parseGroup v = fail ("Invalid group query result: " ++ show v)
183 183

  
b/htools/Ganeti/HTools/Node.hs
494 494
      "mload" -> printf "%5.3f" uM
495 495
      "dload" -> printf "%5.3f" uD
496 496
      "nload" -> printf "%5.3f" uN
497
      "ptags" -> intercalate "," . map (\(k, v) -> printf "%s=%d" k v) .
497
      "ptags" -> intercalate "," . map (uncurry (printf "%s=%d")) .
498 498
                 Map.toList $ pTags t
499 499
      "peermap" -> show $ peers t
500 500
      _ -> T.unknownField
b/htools/Ganeti/HTools/Rapi.hs
89 89

  
90 90
getFakeGroups :: Result [(String, Group.Group)]
91 91
getFakeGroups =
92
  return $ [(defaultGroupID,
93
             Group.create "default" defaultGroupID AllocPreferred)]
92
  return [(defaultGroupID,
93
           Group.create "default" defaultGroupID AllocPreferred)]
94 94

  
95 95
-- | Construct an instance from a JSON object.
96 96
parseInstance :: NameAssoc
b/htools/Ganeti/HTools/Text.hs
7 7

  
8 8
{-
9 9

  
10
Copyright (C) 2009, 2010 Google Inc.
10
Copyright (C) 2009, 2010, 2011 Google Inc.
11 11

  
12 12
This program is free software; you can redistribute it and/or modify
13 13
it under the terms of the GNU General Public License as published by
......
109 109
loadGroup :: (Monad m) => [String] -> m (String, Group.Group)
110 110
loadGroup [name, gid, apol] = do
111 111
  xapol <- apolFromString apol
112
  return $ (gid, Group.create name gid xapol)
112
  return (gid, Group.create name gid xapol)
113 113

  
114 114
loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'"
115 115

  
b/htools/hail.hs
88 88
            hPutStrLn stderr $ "Error: " ++ err
89 89
            exitWith $ ExitFailure 1
90 90
          Ok rq -> return rq
91
  r2 <- if isJust (optDataFile opts) ||  (not . null . optNodeSim) opts
92
        then  do
93
          cdata <- loadExternalData opts
94
          let Request rqt _ = r1
95
          return $ Request rqt cdata
96
        else return r1
97
  return r2
91
  (if isJust (optDataFile opts) ||  (not . null . optNodeSim) opts
92
   then do
93
     cdata <- loadExternalData opts
94
     let Request rqt _ = r1
95
     return $ Request rqt cdata
96
   else return r1)
98 97

  
99 98
-- | Main function.
100 99
main :: IO ()
b/htools/hbal.hs
4 4

  
5 5
{-
6 6

  
7
Copyright (C) 2009, 2010 Google Inc.
7
Copyright (C) 2009, 2010, 2011 Google Inc.
8 8

  
9 9
This program is free software; you can redistribute it and/or modify
10 10
it under the terms of the GNU General Public License as published by
......
280 280
  when (length ngroups > 1 && isNothing (optGroup opts)) $ do
281 281
    hPutStrLn stderr "Found multiple node groups:"
282 282
    mapM_ (hPutStrLn stderr . ("  " ++) . Group.name .
283
           (flip Container.find gl) . fst) ngroups
283
           flip Container.find gl . fst) ngroups
284 284
    hPutStrLn stderr "Aborting."
285 285
    exitWith $ ExitFailure 1
286 286

  
......
307 307
            Nothing -> do
308 308
              -- TODO: while this is unlikely to happen, log here the
309 309
              -- actual group data to help debugging
310
              hPutStrLn stderr $ "Internal failure, missing group idx"
310
              hPutStrLn stderr "Internal failure, missing group idx"
311 311
              exitWith $ ExitFailure 1
312 312
            Just cdata -> return (Group.name grp, cdata)
313 313

  
......
417 417
                return False
418 418
              Just master -> runJobSet master fin_nl il cmd_jobs)
419 419
      else return True
420
  when (not eval) (exitWith (ExitFailure 1))
420
  unless eval (exitWith (ExitFailure 1))
b/htools/hscan.hs
153 153
         let name = local
154 154
         input_data <- Luxi.loadData lsock
155 155
         result <- writeData nlen name opts input_data
156
         when (not result) $ exitWith $ ExitFailure 2
156
         unless result $ exitWith $ ExitFailure 2
157 157

  
158 158
#ifndef NO_CURL
159
  results <- mapM (\ name ->
160
                    do
161
                      input_data <- Rapi.loadData name
162
                      writeData nlen name opts input_data
163
                  ) clusters
164
  when (not $ all id results) $ exitWith (ExitFailure 2)
159
  results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts)
160
             clusters
161
  unless (all id results) $ exitWith (ExitFailure 2)
165 162
#else
166 163
  when (not $ null clusters) $ do
167 164
    putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"

Also available in: Unified diff