Revision 247f77b7 htools/Ganeti/HTools/CLI.hs

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

Also available in: Unified diff