diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs index 9875d7550a4c56f110e8ea96b43ef1510ddd7438..cf990609bc2ffc7e1f1c8a6ff5f92f474d204519 100644 --- a/Ganeti/HTools/Text.hs +++ b/Ganeti/HTools/Text.hs @@ -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) diff --git a/hbal.hs b/hbal.hs index 408cdb8f9e18c245e912e12cd9b8f19d43064273..a83b7fc36a2f354399fbddc7036f3396d8888f11 100644 --- a/hbal.hs +++ b/hbal.hs @@ -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 diff --git a/hscan.hs b/hscan.hs index 5c8dbda9096ec986fef19cffbeff4a17b4bb11a6..e99efebfd8b5ab4e5dc1c8e1fc911f36669505ba 100644 --- a/hscan.hs +++ b/hscan.hs @@ -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 diff --git a/hspace.hs b/hspace.hs index 103a63088a9650ba5ce038a593346fa762ae9fd7..8410f46585e2f01bbbc81b9b6056e1a12ef63899 100644 --- a/hspace.hs +++ b/hspace.hs @@ -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"