Commit c0e31451 authored by Iustin Pop's avatar Iustin Pop
Browse files

Convert Text.serializeCluster to ClusterData


Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parent f4f6eb0b
...@@ -184,7 +184,7 @@ mergeData :: [(String, DynUtil)] -- ^ Instance utilisation data ...@@ -184,7 +184,7 @@ mergeData :: [(String, DynUtil)] -- ^ Instance utilisation data
-> [String] -- ^ Exclusion tags -> [String] -- ^ Exclusion tags
-> [String] -- ^ Untouchable instances -> [String] -- ^ Untouchable instances
-> ClusterData -- ^ Data from backends -> ClusterData -- ^ Data from backends
-> Result ClusterData -> Result ClusterData -- ^ Fixed cluster data
mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) = mergeData um extags exinsts cdata@(ClusterData _ nl il2 tags) =
let il = Container.elems il2 let il = Container.elems il2
il3 = foldl' (\im (name, n_util) -> il3 = foldl' (\im (name, n_util) ->
......
...@@ -97,9 +97,8 @@ serializeInstances nl = ...@@ -97,9 +97,8 @@ serializeInstances nl =
unlines . map (serializeInstance nl) . Container.elems unlines . map (serializeInstance nl) . Container.elems
-- | Generate complete cluster data from node and instance lists -- | Generate complete cluster data from node and instance lists
serializeCluster :: Group.List -> Node.List -> Instance.List -> [String] serializeCluster :: ClusterData -> String
-> String serializeCluster (ClusterData gl nl il ctags) =
serializeCluster gl nl il ctags =
let gdata = serializeGroups gl let gdata = serializeGroups gl
ndata = serializeNodes gl nl ndata = serializeNodes gl nl
idata = serializeInstances nl il idata = serializeInstances nl il
......
...@@ -400,7 +400,7 @@ main = do ...@@ -400,7 +400,7 @@ main = do
when (isJust $ optSaveCluster opts) $ when (isJust $ optSaveCluster opts) $
do do
let out_path = fromJust $ optSaveCluster opts 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 writeFile out_path adata
printf "The cluster state has been written to file '%s'\n" out_path printf "The cluster state has been written to file '%s'\n" out_path
......
...@@ -93,9 +93,9 @@ fixSlash = map (\x -> if x == '/' then '_' else x) ...@@ -93,9 +93,9 @@ fixSlash = map (\x -> if x == '/' then '_' else x)
processData :: Result ClusterData processData :: Result ClusterData
-> Result (Group.List, Node.List, Instance.List, String) -> Result (Group.List, Node.List, Instance.List, String)
processData input_data = do 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 let (_, fix_nl) = checkData nl il
adata = serializeCluster gl nl il ctags adata = serializeCluster cdata
return (gl, fix_nl, il, adata) return (gl, fix_nl, il, adata)
-- | Writes cluster data out -- | Writes cluster data out
......
...@@ -305,7 +305,8 @@ main = do ...@@ -305,7 +305,8 @@ main = do
when (isJust $ optSaveCluster opts) $ when (isJust $ optSaveCluster opts) $
do do
let out_path = (fromJust $ optSaveCluster opts) <.> "tiered" 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 writeFile out_path adata
hPrintf stderr "The cluster state after tiered allocation\ hPrintf stderr "The cluster state after tiered allocation\
\ has been written to file '%s'\n" \ has been written to file '%s'\n"
...@@ -339,7 +340,7 @@ main = do ...@@ -339,7 +340,7 @@ main = do
when (isJust $ optSaveCluster opts) $ when (isJust $ optSaveCluster opts) $
do do
let out_path = (fromJust $ optSaveCluster opts) <.> "alloc" 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 writeFile out_path adata
hPrintf stderr "The cluster state after standard allocation\ hPrintf stderr "The cluster state after standard allocation\
\ has been written to file '%s'\n" \ has been written to file '%s'\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment