From 30dd3377da9dca878192ad5db04691e70d58890b Mon Sep 17 00:00:00 2001 From: Klaus Aehlig <aehlig@google.com> Date: Mon, 22 Apr 2013 13:50:26 +0200 Subject: [PATCH] Extend the simulation backend to also simulate a master node 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 | 9 +++++---- test/hs/shelltests/htools-single-group.test | 6 ++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Ganeti/HTools/Backend/Simu.hs b/src/Ganeti/HTools/Backend/Simu.hs index fe779dff6..1725e57f3 100644 --- a/src/Ganeti/HTools/Backend/Simu.hs +++ b/src/Ganeti/HTools/Backend/Simu.hs @@ -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 [] diff --git a/test/hs/shelltests/htools-single-group.test b/test/hs/shelltests/htools-single-group.test index 0f271320e..f8e629cb5 100644 --- a/test/hs/shelltests/htools-single-group.test +++ b/test/hs/shelltests/htools-single-group.test @@ -28,12 +28,10 @@ >>> /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 -- GitLab