Extend the simulation backend to also simulate a master node
authorKlaus Aehlig <aehlig@google.com>
Mon, 22 Apr 2013 11:50:26 +0000 (13:50 +0200)
committerKlaus Aehlig <aehlig@google.com>
Mon, 22 Apr 2013 16:43:33 +0000 (18:43 +0200)
In a simulated cluster as created by the simulation backend to
the htools, make the first node of the first node group the master
node. In this way, hools (like hroller) that require a master node
can also be used on simulated clusters, e.g., for testing.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

src/Ganeti/HTools/Backend/Simu.hs
test/hs/shelltests/htools-single-group.test

index fe779df..1725e57 100644 (file)
@@ -78,10 +78,11 @@ createGroup grpIndex spec = do
   (apol, ncount, disk, mem, cpu, spindles) <- parseDesc spec $
                                               sepSplit ',' spec
   let nodes = map (\idx ->
-                     Node.create (printf "node-%02d-%03d" grpIndex idx)
-                           (fromIntegral mem) 0 mem
-                           (fromIntegral disk) disk
-                           (fromIntegral cpu) False spindles grpIndex
+                    flip Node.setMaster (grpIndex == 1 && idx == 1) $
+                    Node.create (printf "node-%02d-%03d" grpIndex idx)
+                      (fromIntegral mem) 0 mem
+                      (fromIntegral disk) disk
+                      (fromIntegral cpu) False spindles grpIndex
                   ) [1..ncount]
       grp = Group.create (printf "group-%02d" grpIndex)
             (printf "fake-uuid-%02d" grpIndex) apol defIPolicy []
index 0f27132..f8e629c 100644 (file)
 >>> /HCHECK_INIT_CLUSTER_NEED_REBALANCE=0/
 >>>= 0
 
-# FIXME: remove option -f once the text backend supports indicating
-#        the master node
 # hroller should be able to print the solution
-./test/hs/hroller -f -t$T/simu-onegroup.tiered
+./test/hs/hroller -t$T/simu-onegroup.tiered
 >>>= 0
 
 # hroller should be able to print the solution, in verbose mode as well
-./test/hs/hroller -f -t$T/simu-onegroup.tiered -v -v
+./test/hs/hroller -t$T/simu-onegroup.tiered -v -v
 >>>= 0