Print idx <-> uuid mappings in machine readable mode
authorAgata Murawska <agatamurawska@google.com>
Tue, 26 Jun 2012 15:14:07 +0000 (17:14 +0200)
committerAgata Murawska <agatamurawska@google.com>
Wed, 27 Jun 2012 14:17:49 +0000 (16:17 +0200)
As per Iustin Pop's suggestion, we are printing group mappings
from group idx (known only to htools) to group uuid, which identifies
the group uniquely. This is required because group uuid and name
may contain characters such as '-' which are not valid parts of
bash variable name.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

htools/Ganeti/HTools/Program/Hcheck.hs

index f5d73db..e3ab1b1 100644 (file)
@@ -132,6 +132,14 @@ printBool True True = "1"
 printBool True False = "0"
 printBool False b = show b
 
+-- | Print mapping from group idx to group uuid (only in machine readable mode).
+printGroupsMappings :: Group.List -> IO ()
+printGroupsMappings gl = do
+    let extract_vals = \g -> (printf "GROUP_UUID_%d" $ Group.idx g :: String,
+                              printf "%s" $ Group.uuid g :: String)
+        printpairs = map extract_vals (Container.elems gl)
+    printKeysHTC printpairs
+
 -- | Print all the statistics on a group level.
 printGroupStats :: Int -> Bool -> Phase -> Group.Group -> [Int] -> Double -> IO ()
 printGroupStats _ True phase grp stats score = do
@@ -246,6 +254,7 @@ main opts args = do
   let splitinstances = Cluster.findSplitInstances nlf ilf
       splitcluster = Cluster.splitCluster nlf ilf
 
+  when machineread $ printGroupsMappings gl
 
   groupsstats <- mapM (perGroupChecks verbose machineread Initial gl) splitcluster
   let clusterstats = map sum (transpose groupsstats) :: [Int]