From 9abe9caf652d54058816a04a8983863dc6216bd7 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Mon, 1 Jun 2009 16:21:51 +0200 Subject: [PATCH] Fix hspace with plain type instances This also fixes other required node numbers. --- hspace.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hspace.hs b/hspace.hs index 00d629c..9e77ab5 100644 --- a/hspace.hs +++ b/hspace.hs @@ -194,12 +194,17 @@ main = do offline_indices = map Node.idx $ filter (\n -> elem (Node.name n) offline_names) all_nodes + req_nodes = optINodes opts when (length offline_wrong > 0) $ do printf "Error: Wrong node name(s) set as offline: %s\n" (commaJoin offline_wrong) exitWith $ ExitFailure 1 + when (req_nodes /= 1 && req_nodes /= 2) $ do + printf "Error: Invalid required nodes (%d)\n" req_nodes + exitWith $ ExitFailure 1 + let nl = Container.map (\n -> if elem (Node.idx n) offline_indices then Node.setOffline n True else n) fixed_nl @@ -233,8 +238,7 @@ main = do newinst = Instance.create "new" (optIMem opts) (optIDsk opts) "ADMIN_down" (-1) (-1) - let (fin_nl, ixes) = - iterateDepth nl il newinst (optINodes opts) [] + let (fin_nl, ixes) = iterateDepth nl il newinst req_nodes [] allocs = length ixes fin_instances = num_instances + allocs fin_ixes = reverse ixes @@ -245,14 +249,16 @@ main = do printf "Final instances: %d\n" (num_instances + allocs) printf "Final free RAM: %d\n" final_mem printf "Final free disk: %d\n" final_disk - printf "Usage: %.2f\n" (((fromIntegral num_instances)::Double) / + printf "Usage: %.5f\n" (((fromIntegral num_instances)::Double) / (fromIntegral fin_instances)) printf "Allocations: %d\n" allocs when (verbose > 1) $ do putStr . unlines . map (\i -> printf "Inst: %*s %-*s %-*s" ix_namelen (Instance.name i) nmlen (Container.nameOf fin_nl $ Instance.pnode i) - nmlen (Container.nameOf fin_nl $ Instance.snode i)) + nmlen (let sdx = Instance.snode i + in if sdx == Node.noSecondary then "" + else Container.nameOf fin_nl sdx)) $ fin_ixes when (optShowNodes opts) $ -- 1.7.10.4