Revision 9fdd3d0f

b/htools/Ganeti/HTools/CLI.hs
107 107
  { optDataFile    :: Maybe FilePath -- ^ Path to the cluster data file
108 108
  , optDiskMoves   :: Bool           -- ^ Allow disk moves
109 109
  , optInstMoves   :: Bool           -- ^ Allow instance moves
110
  , optDiskTemplate :: DiskTemplate  -- ^ The requested disk template
110
  , optDiskTemplate :: Maybe DiskTemplate  -- ^ Override for the disk template
111 111
  , optDynuFile    :: Maybe FilePath -- ^ Optional file with dynamic use data
112 112
  , optEvacMode    :: Bool           -- ^ Enable evacuation mode
113 113
  , optExInst      :: [String]       -- ^ Instances to be excluded
......
146 146
  { optDataFile    = Nothing
147 147
  , optDiskMoves   = True
148 148
  , optInstMoves   = True
149
  , optDiskTemplate = DTDrbd8
149
  , optDiskTemplate = Nothing
150 150
  , optDynuFile    = Nothing
151 151
  , optEvacMode    = False
152 152
  , optExInst      = []
......
214 214
oDiskTemplate = Option "" ["disk-template"]
215 215
                (ReqArg (\ t opts -> do
216 216
                           dt <- diskTemplateFromRaw t
217
                           return $ opts { optDiskTemplate = dt }) "TEMPLATE")
218
                "select the desired disk template"
217
                           return $ opts { optDiskTemplate = Just dt })
218
                 "TEMPLATE") "select the desired disk template"
219 219

  
220 220
oSelInst :: OptType
221 221
oSelInst = Option "" ["select-instances"]
b/htools/Ganeti/HTools/Program/Hspace.hs
358 358
              -> Maybe Cluster.AllocResult  -- ^ Optional stop-allocation
359 359
              -> Result Cluster.AllocResult -- ^ Allocation result
360 360
              -> RSpec                      -- ^ Requested instance spec
361
              -> DiskTemplate               -- ^ Requested disk template
361 362
              -> SpecType                   -- ^ Allocation type
362 363
              -> Options                    -- ^ CLI options
363 364
              -> IO (FailStats, Node.List, Int, [(RSpec, Int)])
364
runAllocation cdata stop_allocation actual_result spec mode opts = do
365
runAllocation cdata stop_allocation actual_result spec dt mode opts = do
365 366
  (reasons, new_nl, new_il, new_ixes, _) <-
366 367
      case stop_allocation of
367 368
        Just result_noalloc -> return result_noalloc
......
371 372
      descr = name ++ " allocation"
372 373
      ldescr = "after " ++ map toLower descr
373 374

  
374
  printISpec (optMachineReadable opts) spec mode (optDiskTemplate opts)
375
  printISpec (optMachineReadable opts) spec mode dt
375 376

  
376 377
  printAllocationMap (optVerbose opts) descr new_nl new_ixes
377 378

  
......
399 400
         exitWith $ ExitFailure 1
400 401

  
401 402
  let verbose = optVerbose opts
402
      disk_template = optDiskTemplate opts
403
      req_nodes = Instance.requiredNodes disk_template
404 403
      machine_r = optMachineReadable opts
405 404

  
406 405
  orig_cdata@(ClusterData gl fixed_nl il _ ipol) <- loadExternalData opts
407 406
  nl <- setNodeStatus opts fixed_nl
408 407

  
408
  cluster_disk_template <-
409
    case iPolicyDiskTemplates ipol of
410
      first_templ:_ -> return first_templ
411
      _ -> do
412
         _ <- hPutStrLn stderr $ "Error: null list of disk templates\
413
                               \ received from cluster!"
414
         exitWith $ ExitFailure 1
415

  
409 416
  let num_instances = Container.size il
410 417
      all_nodes = Container.elems fixed_nl
411 418
      cdata = orig_cdata { cdNodes = fixed_nl }
419
      disk_template = fromMaybe cluster_disk_template (optDiskTemplate opts)
420
      req_nodes = Instance.requiredNodes disk_template
412 421
      csf = commonSuffix fixed_nl il
413 422

  
414 423
  when (not (null csf) && verbose > 1) $
......
440 449
    runAllocation cdata stop_allocation
441 450
       (Cluster.tieredAlloc nl il alloclimit
442 451
        (instFromSpec tspec disk_template) allocnodes [] [])
443
       tspec SpecTiered opts
452
       tspec disk_template SpecTiered opts
444 453

  
445 454
  printTiered machine_r spec_map (optMcpu opts) nl trl_nl treason
446 455

  
......
453 462
      runAllocation cdata stop_allocation
454 463
            (Cluster.iterateAlloc nl il alloclimit
455 464
             (instFromSpec ispec disk_template) allocnodes [] [])
456
            ispec SpecNormal opts
465
            ispec disk_template SpecNormal opts
457 466

  
458 467
  printResults machine_r nl fin_nl num_instances allocs sreason
459 468

  
b/man/hspace.rst
203 203
The options that can be passed to the program are as follows:
204 204

  
205 205
--disk-template *template*
206
  The disk template for the instance; one of the Ganeti disk templates
207
  (e.g. plain, drbd, so on) should be passed in.
206
  Overrides the disk template for the instance read from the cluster;
207
  one of the Ganeti disk templates (e.g. plain, drbd, so on) should be
208
  passed in.
208 209

  
209 210
--max-cpu=*cpu-ratio*
210 211
  The maximum virtual to physical cpu ratio, as a floating point number

Also available in: Unified diff