For the standard specs, hspace currently takes separate options for
the memory, disk and VCPUs. For the tiered specs, which were
introduced later, it takes a single option with all three values
combined.

This patch adds a backward-incompatible change to the standard spec,
basically moving it to the same single option format, which is a bit
more simple (both in the code and on the command line). This is
"needed" for future changes, where the command line will just
overwrite what we get from cluster, instead of setting the starting
point.
---
 htools/Ganeti/HTools/CLI.hs            |   39 ++++++--------------------
 htools/Ganeti/HTools/Program/Hspace.hs |    4 +--
 man/hspace.rst                         |   47 ++++++++++++++-----------------
 3 files changed, 31 insertions(+), 59 deletions(-)

diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs
index 820be57..58ffa22 100644
--- a/htools/Ganeti/HTools/CLI.hs
+++ b/htools/Ganeti/HTools/CLI.hs
@@ -47,9 +47,6 @@ module Ganeti.HTools.CLI
   , oExTags
   , oExecJobs
   , oGroup
-  , oIDisk
-  , oIMem
-  , oIVcpus
   , oInstMoves
   , oLuxiSocket
   , oMachineReadable
@@ -73,6 +70,7 @@ module Ganeti.HTools.CLI
   , oSelInst
   , oShowHelp
   , oShowVer
+  , oStdSpec
   , oTieredSpec
   , oVerbose
   ) where
@@ -263,33 +261,6 @@ oGroup = Option "G" ["group"]
             (ReqArg (\ f o -> Ok o { optGroup = Just f }) "ID")
             "the ID of the group to balance"
 
-oIDisk :: OptType
-oIDisk = Option "" ["disk"]
-         (ReqArg (\ d opts -> do
-                    dsk <- annotateResult "--disk option" (parseUnit d)
-                    let ospec = optISpec opts
-                        nspec = ospec { rspecDsk = dsk }
-                    return $ opts { optISpec = nspec }) "DISK")
-         "disk size for instances"
-
-oIMem :: OptType
-oIMem = Option "" ["memory"]
-        (ReqArg (\ m opts -> do
-                   mem <- annotateResult "--memory option" (parseUnit m)
-                   let ospec = optISpec opts
-                       nspec = ospec { rspecMem = mem }
-                   return $ opts { optISpec = nspec }) "MEMORY")
-        "memory size for instances"
-
-oIVcpus :: OptType
-oIVcpus = Option "" ["vcpus"]
-          (ReqArg (\ p opts -> do
-                     vcpus <- tryRead "--vcpus option" p
-                     let ospec = optISpec opts
-                         nspec = ospec { rspecCpu = vcpus }
-                     return $ opts { optISpec = nspec }) "NUM")
-          "number of virtual cpus for instances"
-
 oLuxiSocket :: OptType
 oLuxiSocket = Option "L" ["luxi"]
               (OptArg ((\ f opts -> Ok opts { optLuxi = Just f }) .
@@ -408,6 +379,14 @@ oShowVer = Option "V" ["version"]
            (NoArg (\ opts -> Ok opts { optShowVer = True}))
            "show the version of the program"
 
+oStdSpec :: OptType
+oStdSpec = Option "" ["standard-alloc"]
+             (ReqArg (\ inp opts -> do
+                        tspec <- parseISpecString "standard" inp
+                        return $ opts { optISpec = tspec } )
+              "STDSPEC")
+             "enable standard specs allocation, given as 'disk,ram,cpu'"
+
 oTieredSpec :: OptType
 oTieredSpec = Option "" ["tiered-alloc"]
              (ReqArg (\ inp opts -> do
diff --git a/htools/Ganeti/HTools/Program/Hspace.hs 
b/htools/Ganeti/HTools/Program/Hspace.hs
index 5211814..63dddc1 100644
--- a/htools/Ganeti/HTools/Program/Hspace.hs
+++ b/htools/Ganeti/HTools/Program/Hspace.hs
@@ -59,13 +59,11 @@ options =
   , oVerbose
   , oQuiet
   , oOfflineNode
-  , oIMem
-  , oIDisk
-  , oIVcpus
   , oMachineReadable
   , oMaxCpu
   , oMaxSolLength
   , oMinDisk
+  , oStdSpec
   , oTieredSpec
   , oSaveCluster
   , oShowVer
diff --git a/man/hspace.rst b/man/hspace.rst
index 6088d55..70f55c0 100644
--- a/man/hspace.rst
+++ b/man/hspace.rst
@@ -29,11 +29,11 @@ Algorithm options:
 
 Request options:
 
-**[--memory** *mem* **]**
-**[--disk** *disk* **]**
 **[--disk-template** *template* **]**
-**[--vcpus** *vcpus* **]**
-**[--tiered-alloc** *spec* **]**
+
+**[--standard-alloc** *disk,ram,cpu*  **]**
+
+**[--tiered-alloc** *disk,ram,cpu* **]**
 
 Output options:
 
@@ -201,21 +201,10 @@ OPTIONS
 
 The options that can be passed to the program are as follows:
 
---memory *mem*
-  The memory size of the instances to be placed (defaults to
-  4GiB). Units can be used (see below for more details).
-
---disk *disk*
-  The disk size of the instances to be placed (defaults to
-  100GiB). Units can be used.
-
 --disk-template *template*
   The disk template for the instance; one of the Ganeti disk templates
   (e.g. plain, drbd, so on) should be passed in.
 
---vcpus *vcpus*
-  The number of VCPUs of the instances to be placed (defaults to 1).
-
 --max-cpu=*cpu-ratio*
   The maximum virtual to physical cpu ratio, as a floating point number
   greater than or equal to one. For example, specifying *cpu-ratio* as
@@ -284,22 +273,28 @@ The options that can be passed to the program are as 
follows:
   overriding the cluster data with a simulated cluster. For details
   about the description, see the man page **htools**(1).
 
---tiered-alloc *spec*
-  Besides the standard, fixed-size allocation, also do a tiered
-  allocation scheme where the algorithm starts from the given
-  specification and allocates until there is no more space; then it
-  decreases the specification and tries the allocation again. The
-  decrease is done on the matric that last failed during
-  allocation. The specification given is similar to the *--simulate*
-  option and it holds:
+--standard-alloc *disk,ram,cpu*
+  This option specifies the instance size for the *standard* allocation
+  mode, where we simply allocate instances of the same, fixed size until
+  the cluster runs out of space.
+
+  The specification given is similar to the *--simulate* option and it
+  holds:
 
   - the disk size of the instance (units can be used)
   - the memory size of the instance (units can be used)
   - the vcpu count for the insance
 
-  An example description would be *100G,4g,2* describing an initial
-  starting specification of 100GB of disk space, 4GiB of memory and 2
-  VCPUs.
+  An example description would be *100G,4g,2* describing an instance
+  specification of 100GB of disk space, 4GiB of memory and 2 VCPUs.
+
+--tiered-alloc *disk,ram,cpu*
+  Besides the standard, fixed-size allocation, also do a tiered
+  allocation scheme where the algorithm starts from the given
+  specification and allocates until there is no more space; then it
+  decreases the specification and tries the allocation again. The
+  decrease is done on the metric that last failed during allocation. The
+  argument should have the same format as for ``-standard-alloc``.
 
   Also note that the normal allocation and the tiered allocation are
   independent, and both start from the initial cluster state; as such,
-- 
1.7.3.1

Reply via email to