Re: [PATCH master 16/52] Extend ClusterData with the cluster instance policy

2012-01-11 Thread René Nussbaumer
On Mon, Jan 9, 2012 at 11:58, Iustin Pop  wrote:
> This attribute is always initialised to the default, and is not (yet)
> read/saved in the various backends.
> ---
>  htools/Ganeti/HTools/IAlloc.hs         |    4 ++--
>  htools/Ganeti/HTools/Loader.hs         |    4 +++-
>  htools/Ganeti/HTools/Luxi.hs           |    2 +-
>  htools/Ganeti/HTools/Program/Hbal.hs   |    4 ++--
>  htools/Ganeti/HTools/Program/Hscan.hs  |    4 ++--
>  htools/Ganeti/HTools/Program/Hspace.hs |    4 ++--
>  htools/Ganeti/HTools/QC.hs             |    2 +-
>  htools/Ganeti/HTools/Rapi.hs           |    2 +-
>  htools/Ganeti/HTools/Simu.hs           |    2 +-
>  htools/Ganeti/HTools/Text.hs           |    4 ++--
>  10 files changed, 17 insertions(+), 15 deletions(-)

LGTM.

René


[PATCH master 16/52] Extend ClusterData with the cluster instance policy

2012-01-09 Thread Iustin Pop
This attribute is always initialised to the default, and is not (yet)
read/saved in the various backends.
---
 htools/Ganeti/HTools/IAlloc.hs |4 ++--
 htools/Ganeti/HTools/Loader.hs |4 +++-
 htools/Ganeti/HTools/Luxi.hs   |2 +-
 htools/Ganeti/HTools/Program/Hbal.hs   |4 ++--
 htools/Ganeti/HTools/Program/Hscan.hs  |4 ++--
 htools/Ganeti/HTools/Program/Hspace.hs |4 ++--
 htools/Ganeti/HTools/QC.hs |2 +-
 htools/Ganeti/HTools/Rapi.hs   |2 +-
 htools/Ganeti/HTools/Simu.hs   |2 +-
 htools/Ganeti/HTools/Text.hs   |4 ++--
 10 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs
index 26b7ea6..cbec6a9 100644
--- a/htools/Ganeti/HTools/IAlloc.hs
+++ b/htools/Ganeti/HTools/IAlloc.hs
@@ -158,7 +158,7 @@ parseData body = do
   let (kti, il) = assignIndices iobj
   -- cluster tags
   ctags <- extrObj "cluster_tags"
-  cdata1 <- mergeData [] [] [] [] (ClusterData gl nl il ctags)
+  cdata1 <- mergeData [] [] [] [] (ClusterData gl nl il ctags defIPolicy)
   let (msgs, fix_nl) = checkData (cdNodes cdata1) (cdInstances cdata1)
   cdata = cdata1 { cdNodes = fix_nl }
   map_n = cdNodes cdata
@@ -307,7 +307,7 @@ formatRelocate (nl, il, ndxs) =
 -- | Process a request and return new node lists.
 processRequest :: Request -> Result IAllocResult
 processRequest request =
-  let Request rqtype (ClusterData gl nl il _) = request
+  let Request rqtype (ClusterData gl nl il _ _) = request
   in case rqtype of
Allocate xi reqn ->
  Cluster.tryMGAlloc gl nl il xi reqn >>= formatAllocate il
diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs
index a9c9e0e..7d76038 100644
--- a/htools/Ganeti/HTools/Loader.hs
+++ b/htools/Ganeti/HTools/Loader.hs
@@ -90,6 +90,7 @@ data ClusterData = ClusterData
   , cdNodes :: Node.List -- ^ The node list
   , cdInstances :: Instance.List -- ^ The instance list
   , cdTags  :: [String]  -- ^ The cluster tags
+  , cdIPolicy   :: IPolicy   -- ^ The cluster instance policy
   } deriving (Show, Read)
 
 -- | The priority of a match in a lookup result.
@@ -116,6 +117,7 @@ instance Ord LookupResult where
 -- | An empty cluster.
 emptyCluster :: ClusterData
 emptyCluster = ClusterData Container.empty Container.empty Container.empty []
+ defIPolicy
 
 -- * Functions
 
@@ -267,7 +269,7 @@ mergeData :: [(String, DynUtil)]  -- ^ Instance utilisation 
data
   -> [String] -- ^ Excluded instances
   -> ClusterData  -- ^ Data from backends
   -> Result ClusterData   -- ^ Fixed cluster data
-mergeData um extags selinsts exinsts cdata@(ClusterData _ nl il2 tags) =
+mergeData um extags selinsts exinsts cdata@(ClusterData _ nl il2 tags _) =
   let il = Container.elems il2
   il3 = foldl' (\im (name, n_util) ->
 case Container.findByName im name of
diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs
index 744aa05..d360390 100644
--- a/htools/Ganeti/HTools/Luxi.hs
+++ b/htools/Ganeti/HTools/Luxi.hs
@@ -249,7 +249,7 @@ parseData (groups, nodes, instances, cinfo) = do
   inst_data <- instances >>= getInstances node_names
   let (_, inst_idx) = assignIndices inst_data
   ctags <- cinfo >>= getClusterTags
-  return (ClusterData group_idx node_idx inst_idx ctags)
+  return (ClusterData group_idx node_idx inst_idx ctags defIPolicy)
 
 -- | Top level function for data loading.
 loadData :: String -- ^ Unix socket to use as source
diff --git a/htools/Ganeti/HTools/Program/Hbal.hs 
b/htools/Ganeti/HTools/Program/Hbal.hs
index e702733..758b890 100644
--- a/htools/Ganeti/HTools/Program/Hbal.hs
+++ b/htools/Ganeti/HTools/Program/Hbal.hs
@@ -351,7 +351,7 @@ main = do
   shownodes = optShowNodes opts
   showinsts = optShowInsts opts
 
-  ini_cdata@(ClusterData gl fixed_nl ilf ctags) <- loadExternalData opts
+  ini_cdata@(ClusterData gl fixed_nl ilf ctags _) <- loadExternalData opts
 
   when (verbose > 1) $
putStrLn $ "Loaded cluster tags: " ++ intercalate "," ctags
@@ -412,7 +412,7 @@ main = do
saveBalanceCommands opts $ Cluster.formatCmds cmd_jobs
 
   maybeSaveData (optSaveCluster opts) "balanced" "after balancing"
-(ClusterData gl fin_nl fin_il ctags)
+ini_cdata { cdNodes = fin_nl, cdInstances = fin_il }
 
   maybePrintInsts showinsts "Final" (Cluster.printInsts fin_nl fin_il)
 
diff --git a/htools/Ganeti/HTools/Program/Hscan.hs 
b/htools/Ganeti/HTools/Program/Hscan.hs
index acdf7e8..cac708f 100644
--- a/htools/Ganeti/HTools/Program/Hscan.hs
+++ b/htools/Ganeti/HTools/Program/Hscan.hs
@@ -82,7 +82,7 @@ fixSlash = map (\x -> if x == '/' then '_' else x)
 -- | Generates serialized data from loader input.
 processData :: ClusterData -> Result ClusterData
 processData input_data = do
-  cdata@(ClusterData _ nl il _) <- mergeData [] [] [] [