Commit 716c6be5 authored by Iustin Pop's avatar Iustin Pop
Browse files

Text.hs: serialize cluster tags when writing data



This is the complement to the reading part. Now the live-test works
correctly against clusters with configured exclusion tags.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parent afcd5a0b
......@@ -96,12 +96,14 @@ serializeInstances nl =
unlines . map (serializeInstance nl) . Container.elems
-- | Generate complete cluster data from node and instance lists
serializeCluster :: Group.List -> Node.List -> Instance.List -> String
serializeCluster gl nl il =
serializeCluster :: Group.List -> Node.List -> Instance.List -> [String]
-> String
serializeCluster gl nl il ctags =
let gdata = serializeGroups gl
ndata = serializeNodes gl nl
idata = serializeInstances nl il
in gdata ++ ['\n'] ++ ndata ++ ['\n'] ++ idata
-- note: not using 'unlines' as that adds too many newlines
in intercalate "\n" [gdata, ndata, idata, unlines ctags]
-- | Load a group from a field list.
loadGroup :: (Monad m) => [String] -> m (String, Group.Group)
......
......@@ -391,7 +391,7 @@ main = do
when (isJust $ optSaveCluster opts) $
do
let out_path = fromJust $ optSaveCluster opts
adata = serializeCluster gl fin_nl fin_il
adata = serializeCluster gl fin_nl fin_il ctags
writeFile out_path adata
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)
processData :: Result (Group.List, Node.List, Instance.List, [String])
-> Result (Group.List, Node.List, Instance.List, String)
processData input_data = do
(gl, nl, il, _) <- input_data >>= Loader.mergeData [] [] []
(gl, nl, il, ctags) <- input_data >>= Loader.mergeData [] [] []
let (_, fix_nl) = Loader.checkData nl il
adata = serializeCluster gl nl il
adata = serializeCluster gl nl il ctags
return (gl, fix_nl, il, adata)
-- | Writes cluster data out
......
......@@ -207,7 +207,7 @@ main = do
ispec = optISpec opts
shownodes = optShowNodes opts
(gl, fixed_nl, il, _) <- loadExternalData opts
(gl, fixed_nl, il, ctags) <- loadExternalData opts
printKeys $ map (\(a, fn) -> ("SPEC_" ++ a, fn ispec)) specData
printKeys [ ("SPEC_RQN", printf "%d" (optINodes opts)) ]
......@@ -312,7 +312,7 @@ main = do
when (isJust $ optSaveCluster opts) $
do
let out_path = (fromJust $ optSaveCluster opts) <.> "tiered"
adata = serializeCluster gl trl_nl trl_il
adata = serializeCluster 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"
......@@ -346,7 +346,7 @@ main = do
when (isJust $ optSaveCluster opts) $
do
let out_path = (fromJust $ optSaveCluster opts) <.> "alloc"
adata = serializeCluster gl fin_nl fin_il
adata = serializeCluster 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"
......
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