Convert Text.serializeCluster to ClusterData
authorIustin Pop <iustin@google.com>
Tue, 21 Dec 2010 10:37:50 +0000 (11:37 +0100)
committerIustin Pop <iustin@google.com>
Thu, 30 Dec 2010 09:45:11 +0000 (10:45 +0100)
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>

Ganeti/HTools/Loader.hs
Ganeti/HTools/Text.hs
hbal.hs
hscan.hs
hspace.hs

index 42092c2..887a693 100644 (file)
@@ -184,7 +184,7 @@ mergeData :: [(String, DynUtil)]  -- ^ Instance utilisation data
           -> [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) ->
index 11ce84f..1f446ac 100644 (file)
@@ -97,9 +97,8 @@ 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]
-                 -> 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
diff --git a/hbal.hs b/hbal.hs
index 7db7b60..ddbb6bc 100644 (file)
--- a/hbal.hs
+++ b/hbal.hs
@@ -400,7 +400,7 @@ main = do
   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
 
index ccea188..631c061 100644 (file)
--- a/hscan.hs
+++ b/hscan.hs
@@ -93,9 +93,9 @@ fixSlash = map (\x -> if x == '/' then '_' else x)
 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
index 434a77c..76c454e 100644 (file)
--- a/hspace.hs
+++ b/hspace.hs
@@ -305,7 +305,8 @@ main = do
        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"
@@ -339,7 +340,7 @@ main = do
   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"