From: Daniil Leshchev <mele...@gmail.com>

This information is used by Hbal in order to prevent long balancing steps
("--avoid-long-solutions").
---
 src/Ganeti/HTools/Loader.hs | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/Ganeti/HTools/Loader.hs b/src/Ganeti/HTools/Loader.hs
index 2294468..10a364c 100644
--- a/src/Ganeti/HTools/Loader.hs
+++ b/src/Ganeti/HTools/Loader.hs
@@ -326,6 +326,23 @@ addLocationTags ctags node =
   let ntags = Node.nTags node
   in Node.setLocationTags node $ Tags.getLocations ctags ntags
 
+addBandwidthData :: [String]
+                 -> Group.List -> Node.Node -> Node.Node
+addBandwidthData ctags gl node =
+  let grp = Container.find (Node.group node) gl
+      ntags = Node.nTags node
+      gtags = Group.allTags grp
+      bgraph = Tags.getBandwidthGraph ctags
+      alltags = Tags.inheritByPrefixes ctags $
+                Tags.inheritByPrefixes gtags ntags
+      btags = Tags.getBandwidth ctags alltags
+      tnode = Node.setBandwidthTags node btags
+      update nd (src, dst, bndwdth)
+        | Set.member src btags = Node.setBandwidthToLocation nd dst bndwdth
+        | Set.member dst btags = Node.setBandwidthToLocation nd src bndwdth
+        | otherwise = nd
+  in foldl update tnode bgraph
+
 -- | Initializer function that loads the data from a node and instance
 -- list and massages it into the correct format.
 mergeData :: [(String, DynUtil)]  -- ^ Instance utilisation data
@@ -366,8 +383,9 @@ mergeData um extags selinsts exinsts time 
cdata@(ClusterData gl nl il ctags _) =
                            (`Node.buildPeers` il4)) nl3
       il6 = Container.map (disableSplitMoves nl3) il5
       nl5 = Container.map (addMigrationTags ctags) nl4
+      nl6 = Container.map (addBandwidthData ctags gl) nl5
   in if' (null lkp_unknown)
-         (Ok cdata { cdNodes = nl5, cdInstances = il6 })
+         (Ok cdata { cdNodes = nl6, cdInstances = il6 })
          (Bad $ "Unknown instance(s): " ++ show(map lrContent lkp_unknown))
 
 -- | In a cluster description, clear dynamic utilisation information.
-- 
1.9.1

Reply via email to