Revision 247f77b7

b/htools/Ganeti/HTools/CLI.hs
245 245

  
246 246
oIDisk :: OptType
247 247
oIDisk = Option "" ["disk"]
248
         (ReqArg (\ d opts ->
249
                     let ospec = optISpec opts
250
                         nspec = ospec { rspecDsk = read d }
251
                     in Ok opts { optISpec = nspec }) "DISK")
248
         (ReqArg (\ d opts -> do
249
                    dsk <- annotateResult ("--disk option") (parseUnit d)
250
                    let ospec = optISpec opts
251
                        nspec = ospec { rspecDsk = dsk }
252
                    return $ opts { optISpec = nspec }) "DISK")
252 253
         "disk size for instances"
253 254

  
254 255
oIMem :: OptType
255 256
oIMem = Option "" ["memory"]
256
        (ReqArg (\ m opts ->
257
                     let ospec = optISpec opts
258
                         nspec = ospec { rspecMem = read m }
259
                     in Ok opts { optISpec = nspec }) "MEMORY")
257
        (ReqArg (\ m opts -> do
258
                   mem <- annotateResult ("--memory option") (parseUnit m)
259
                   let ospec = optISpec opts
260
                       nspec = ospec { rspecMem = mem }
261
                   return $ opts { optISpec = nspec }) "MEMORY")
260 262
        "memory size for instances"
261 263

  
262 264
oIVcpus :: OptType
263 265
oIVcpus = Option "" ["vcpus"]
264
          (ReqArg (\ p opts ->
265
                       let ospec = optISpec opts
266
                           nspec = ospec { rspecCpu = read p }
267
                       in Ok opts { optISpec = nspec }) "NUM")
266
          (ReqArg (\ p opts -> do
267
                     vcpus <- tryRead "--vcpus option" p
268
                     let ospec = optISpec opts
269
                         nspec = ospec { rspecCpu = vcpus }
270
                     return $ opts { optISpec = nspec }) "NUM")
268 271
          "number of virtual cpus for instances"
269 272

  
270 273
oLuxiSocket :: OptType
......
384 387
oTieredSpec = Option "" ["tiered-alloc"]
385 388
             (ReqArg (\ inp opts -> do
386 389
                          let sp = sepSplit ',' inp
387
                          prs <- mapM (tryRead "tiered specs") sp
390
                          prs <- mapM (\(fn, val) -> fn val) $
391
                                 zip [ annotateResult "tiered specs memory" .
392
                                       parseUnit
393
                                     , annotateResult "tiered specs disk" .
394
                                       parseUnit
395
                                     , tryRead "tiered specs cpus"
396
                                     ] sp
388 397
                          tspec <-
389 398
                              case prs of
390 399
                                [dsk, ram, cpu] -> return $ RSpec cpu ram dsk
b/htools/Ganeti/HTools/Simu.hs
47 47
      [a, n, d, m, c] -> do
48 48
        apol <- apolFromString a
49 49
        ncount <- tryRead "node count" n
50
        disk <- tryRead "disk size" d
51
        mem <- tryRead "memory size" m
50
        disk <- annotateResult "disk size" (parseUnit d)
51
        mem <- annotateResult "memory size" (parseUnit m)
52 52
        cpu <- tryRead "cpu count" c
53 53
        return (apol, ncount, disk, mem, cpu)
54 54
      es -> fail $ printf
b/man/hspace.rst
186 186
The options that can be passed to the program are as follows:
187 187

  
188 188
--memory *mem*
189
  The memory size of the instances to be placed (defaults to 4GiB).
189
  The memory size of the instances to be placed (defaults to
190
  4GiB). Units can be used (see below for more details).
190 191

  
191 192
--disk *disk*
192
  The disk size of the instances to be placed (defaults to 100GiB).
193
  The disk size of the instances to be placed (defaults to
194
  100GiB). Units can be used.
193 195

  
194 196
--disk-template *template*
195 197
  The disk template for the instance; one of the Ganeti disk templates
......
199 201
  The number of VCPUs of the instances to be placed (defaults to 1).
200 202

  
201 203
--max-cpu=*cpu-ratio*
202
  The maximum virtual to physical cpu ratio, as a floating point
203
  number between zero and one. For example, specifying *cpu-ratio* as
204
  **2.5** means that, for a 4-cpu machine, a maximum of 10 virtual
205
  cpus should be allowed to be in use for primary instances. A value
206
  of one doesn't make sense though, as that means no disk space can be
207
  used on it.
204
  The maximum virtual to physical cpu ratio, as a floating point number
205
  greater than or equal to one. For example, specifying *cpu-ratio* as
206
  **2.5** means that, for a 4-cpu machine, a maximum of 10 virtual cpus
207
  should be allowed to be in use for primary instances. A value of
208
  exactly one means there will be no over-subscription of CPU (except
209
  for the CPU time used by the node itself), and values below one do not
210
  make sense, as that means other resources (e.g. disk) won't be fully
211
  utilised due to CPU restrictions.
208 212

  
209 213
--min-disk=*disk-ratio*
210 214
  The minimum amount of free disk space remaining, as a floating point
......
337 341

  
338 342
  - the allocation policy for this node group
339 343
  - the number of nodes in the cluster
340
  - the disk size of the nodes, in mebibytes
341
  - the memory size of the nodes, in mebibytes
344
  - the disk size of the nodes (default in mebibytes, units can be used)
345
  - the memory size of the nodes (default in mebibytes, units can be used)
342 346
  - the cpu core count for the nodes
343 347

  
344
  An example description would be **preferred,B20,102400,16384,4**
345
  describing a 20-node cluster where each node has 100GiB of disk
348
  An example description would be **preferred,B20,100G,16g,4**
349
  describing a 20-node cluster where each node has 100GB of disk
346 350
  space, 16GiB of memory and 4 CPU cores. Note that all nodes must
347 351
  have the same specs currently.
348 352

  
......
359 363
  allocation. The specification given is similar to the *--simulate*
360 364
  option and it holds:
361 365

  
362
  - the disk size of the instance
363
  - the memory size of the instance
366
  - the disk size of the instance (units can be used)
367
  - the memory size of the instance (units can be used)
364 368
  - the vcpu count for the insance
365 369

  
366
  An example description would be *10240,8192,2* describing an initial
367
  starting specification of 10GiB of disk space, 4GiB of memory and 2
370
  An example description would be *100G,4g,2* describing an initial
371
  starting specification of 100GB of disk space, 4GiB of memory and 2
368 372
  VCPUs.
369 373

  
370 374
  Also note that the normal allocation and the tiered allocation are
......
385 389
-V, --version
386 390
  Just show the program version and exit.
387 391

  
392
UNITS
393
~~~~~
394

  
395
By default, all unit-accepting options use mebibytes. Using the
396
lower-case letters of *m*, *g* and *t* (or their longer equivalents of
397
*mib*, *gib*, *tib*, for which case doesn't matter) explicit binary
398
units can be selected. Units in the SI system can be selected using the
399
upper-case letters of *M*, *G* and *T* (or their longer equivalents of
400
*MB*, *GB*, *TB*, for which case doesn't matter).
401

  
402
More details about the difference between the SI and binary systems can
403
be read in the *units(7)* man page.
404

  
388 405
EXIT STATUS
389 406
-----------
390 407

  

Also available in: Unified diff