This is very useful for testing/benchmarking.
---
 htools/Ganeti/HTools/CLI.hs            |    5 +++--
 htools/Ganeti/HTools/Program/Hspace.hs |    8 ++++++--
 man/hspace.rst                         |    5 +++++
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs
index d5fdc69..11344d1 100644
--- a/htools/Ganeti/HTools/CLI.hs
+++ b/htools/Ganeti/HTools/CLI.hs
@@ -298,8 +298,9 @@ oMaxCpu = Option "" ["max-cpu"]
 oMaxSolLength :: OptType
 oMaxSolLength = Option "l" ["max-length"]
                 (ReqArg (\ i opts -> Ok opts { optMaxLength = read i }) "N")
-                "cap the solution at this many moves (useful for very\
-                \ unbalanced clusters)"
+                "cap the solution at this many balancing or allocation \
+                \ rounds (useful for very unbalanced clusters or empty \
+                \ clusters)"
 
 oMinDisk :: OptType
 oMinDisk = Option "" ["min-disk"]
diff --git a/htools/Ganeti/HTools/Program/Hspace.hs 
b/htools/Ganeti/HTools/Program/Hspace.hs
index f78262f..932dc27 100644
--- a/htools/Ganeti/HTools/Program/Hspace.hs
+++ b/htools/Ganeti/HTools/Program/Hspace.hs
@@ -65,6 +65,7 @@ options =
     , oIVcpus
     , oMachineReadable
     , oMaxCpu
+    , oMaxSolLength
     , oMinDisk
     , oTieredSpec
     , oSaveCluster
@@ -427,6 +428,9 @@ main = do
 
 
   let reqinst = iofspec ispec
+      alloclimit = if optMaxLength opts == -1
+                   then Nothing
+                   else Just (optMaxLength opts)
 
   allocnodes <- exitifbad $ Cluster.genAllocNodes gl nl req_nodes True
 
@@ -438,7 +442,7 @@ main = do
        (treason, trl_nl, trl_il, trl_ixes, _) <-
            if stop_allocation
            then return result_noalloc
-           else exitifbad (Cluster.tieredAlloc nl il Nothing (iofspec tspec)
+           else exitifbad (Cluster.tieredAlloc nl il alloclimit (iofspec tspec)
                                   allocnodes [] [])
        let spec_map' = tieredSpecMap trl_ixes
            treason' = sortReasons treason
@@ -461,7 +465,7 @@ main = do
   (ereason, fin_nl, fin_il, ixes, _) <-
       if stop_allocation
       then return result_noalloc
-      else exitifbad (Cluster.iterateAlloc nl il Nothing
+      else exitifbad (Cluster.iterateAlloc nl il alloclimit
                       reqinst allocnodes [] [])
 
   let allocs = length ixes
diff --git a/man/hspace.rst b/man/hspace.rst
index d08ae79..6088d55 100644
--- a/man/hspace.rst
+++ b/man/hspace.rst
@@ -231,6 +231,11 @@ The options that can be passed to the program are as 
follows:
   number. For example, specifying *disk-ratio* as **0.25** means that
   at least one quarter of disk space should be left free on nodes.
 
+-l *rounds*, --max-length=*rounds*
+  Restrict the number of instance allocations to this length. This is
+  not very useful in practice, but can be used for testing hspace
+  itself, or to limit the runtime for very big clusters.
+
 -p, --print-nodes
   Prints the before and after node status, in a format designed to allow
   the user to understand the node's most important parameters. See the
-- 
1.7.3.1

Reply via email to