- node_data <- getNodes name
- inst_data <- getInstances name
- (if isLeft(node_data)
- then putStrLn $ fromLeft node_data
- else if isLeft(inst_data)
- then putStrLn $ fromLeft inst_data
- else do
- let ndata = fromRight node_data
- idata = fromRight inst_data
- (nl, il, csf, ktn, kti) =
- Cluster.loadData ndata idata
- (_, fix_nl) = Cluster.checkData nl il ktn kti
- putStrLn $ printCluster fix_nl il ktn kti
- when (optShowNodes opts) $ do
- putStr $ Cluster.printNodes ktn fix_nl
- let ndata = serializeNodes nl csf ktn
- idata = serializeInstances il csf ktn kti
- oname = odir </> name
- writeFile (oname <.> "nodes") ndata
- writeFile (oname <.> "instances") idata)
+ input_data <- Rapi.loadData name
+ let ldresult = input_data >>= Loader.mergeData
+ (case ldresult of
+ Bad err -> printf "\nError: failed to load data. \
+ \Details:\n%s\n" err
+ Ok x -> do
+ let (nl, il, csf) = x
+ (_, fix_nl) = Loader.checkData nl il
+ putStrLn $ printCluster fix_nl il
+ when (optShowNodes opts) $ do
+ putStr $ Cluster.printNodes fix_nl
+ let ndata = serializeNodes csf nl
+ idata = serializeInstances csf nl il
+ oname = odir </> (fixSlash name)
+ writeFile (oname <.> "nodes") ndata
+ writeFile (oname <.> "instances") idata)