-> [String] -- ^ Exclusion tags
-> [String] -- ^ Untouchable instances
-> ClusterData -- ^ Data from backends
- -> Result ClusterData
+ -> Result ClusterData -- ^ Fixed cluster data
mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) =
let il = Container.elems il2
il3 = foldl' (\im (name, n_util) ->
unlines . map (serializeInstance nl) . Container.elems
-- | Generate complete cluster data from node and instance lists
-serializeCluster :: Group.List -> Node.List -> Instance.List -> [String]
- -> String
-serializeCluster gl nl il ctags =
+serializeCluster :: ClusterData -> String
+serializeCluster (ClusterData gl nl il ctags) =
let gdata = serializeGroups gl
ndata = serializeNodes gl nl
idata = serializeInstances nl il
when (isJust $ optSaveCluster opts) $
do
let out_path = fromJust $ optSaveCluster opts
- adata = serializeCluster gl fin_nl fin_il ctags
+ adata = serializeCluster (ClusterData gl fin_nl fin_il ctags)
writeFile out_path adata
printf "The cluster state has been written to file '%s'\n" out_path
processData :: Result ClusterData
-> Result (Group.List, Node.List, Instance.List, String)
processData input_data = do
- (ClusterData gl nl il ctags) <- input_data >>= mergeData [] [] []
+ cdata@(ClusterData gl nl il _) <- input_data >>= mergeData [] [] []
let (_, fix_nl) = checkData nl il
- adata = serializeCluster gl nl il ctags
+ adata = serializeCluster cdata
return (gl, fix_nl, il, adata)
-- | Writes cluster data out
when (isJust $ optSaveCluster opts) $
do
let out_path = (fromJust $ optSaveCluster opts) <.> "tiered"
- adata = serializeCluster gl trl_nl trl_il ctags
+ adata = serializeCluster
+ (ClusterData gl trl_nl trl_il ctags)
writeFile out_path adata
hPrintf stderr "The cluster state after tiered allocation\
\ has been written to file '%s'\n"
when (isJust $ optSaveCluster opts) $
do
let out_path = (fromJust $ optSaveCluster opts) <.> "alloc"
- adata = serializeCluster gl fin_nl fin_il ctags
+ adata = serializeCluster (ClusterData gl fin_nl fin_il ctags)
writeFile out_path adata
hPrintf stderr "The cluster state after standard allocation\
\ has been written to file '%s'\n"