Revision f688711c

b/hscan.hs
30 30
import Data.List
31 31
import Data.Maybe (isJust, fromJust, fromMaybe)
32 32
import Monad
33
#ifdef NO_CURL
34 33
import System (exitWith, ExitCode(..))
35
#endif
36 34
import System.IO
37 35
import System.FilePath
38 36
import qualified System
......
139 137
          -> String
140 138
          -> Options
141 139
          -> Result (Node.List, Instance.List, String)
142
          -> IO ()
140
          -> IO Bool
143 141
writeData _ name _ (Bad err) =
144
    printf "\nError for %s: failed to load data. Details:\n%s\n" name err
142
  printf "\nError for %s: failed to load data. Details:\n%s\n" name err >>
143
  return False
145 144

  
146 145
writeData nlen name opts (Ok (nl, il, adata)) = do
147 146
  printf "%-*s " nlen name :: IO ()
......
154 153
  when (isJust shownodes) $
155 154
       putStr $ Cluster.printNodes nl (fromJust shownodes)
156 155
  writeFile (oname <.> "data") adata
157

  
156
  return True
158 157

  
159 158
-- | Main function.
160 159
main :: IO ()
......
176 175
         let lsock = fromMaybe defaultLuxiSocket (optLuxi opts)
177 176
         let name = local
178 177
         input_data <- Luxi.loadData lsock
179
         writeData nlen name opts (processData input_data)
178
         result <- writeData nlen name opts (processData input_data)
179
         when (not result) $ exitWith $ ExitFailure 2
180 180

  
181 181
#ifndef NO_CURL
182
  mapM_ (\ name ->
183
            do
184
              input_data <- Rapi.loadData name
185
              writeData nlen name opts (processData input_data)
186
        ) clusters
182
  results <- mapM (\ name ->
183
                    do
184
                      input_data <- Rapi.loadData name
185
                      writeData nlen name opts (processData input_data)
186
                  ) clusters
187
  when (not $ all id results) $ exitWith (ExitFailure 2)
187 188
#else
188 189
  when (not $ null clusters) $ do
189 190
    putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"

Also available in: Unified diff