{ optDataFile :: Maybe FilePath -- ^ Path to the cluster data file
, optDiskMoves :: Bool -- ^ Allow disk moves
, optInstMoves :: Bool -- ^ Allow instance moves
- , optDiskTemplate :: DiskTemplate -- ^ The requested disk template
+ , optDiskTemplate :: Maybe DiskTemplate -- ^ Override for the disk template
, optDynuFile :: Maybe FilePath -- ^ Optional file with dynamic use data
, optEvacMode :: Bool -- ^ Enable evacuation mode
, optExInst :: [String] -- ^ Instances to be excluded
{ optDataFile = Nothing
, optDiskMoves = True
, optInstMoves = True
- , optDiskTemplate = DTDrbd8
+ , optDiskTemplate = Nothing
, optDynuFile = Nothing
, optEvacMode = False
, optExInst = []
oDiskTemplate = Option "" ["disk-template"]
(ReqArg (\ t opts -> do
dt <- diskTemplateFromRaw t
- return $ opts { optDiskTemplate = dt }) "TEMPLATE")
- "select the desired disk template"
+ return $ opts { optDiskTemplate = Just dt })
+ "TEMPLATE") "select the desired disk template"
oSelInst :: OptType
oSelInst = Option "" ["select-instances"]
-> Maybe Cluster.AllocResult -- ^ Optional stop-allocation
-> Result Cluster.AllocResult -- ^ Allocation result
-> RSpec -- ^ Requested instance spec
+ -> DiskTemplate -- ^ Requested disk template
-> SpecType -- ^ Allocation type
-> Options -- ^ CLI options
-> IO (FailStats, Node.List, Int, [(RSpec, Int)])
-runAllocation cdata stop_allocation actual_result spec mode opts = do
+runAllocation cdata stop_allocation actual_result spec dt mode opts = do
(reasons, new_nl, new_il, new_ixes, _) <-
case stop_allocation of
Just result_noalloc -> return result_noalloc
descr = name ++ " allocation"
ldescr = "after " ++ map toLower descr
- printISpec (optMachineReadable opts) spec mode (optDiskTemplate opts)
+ printISpec (optMachineReadable opts) spec mode dt
printAllocationMap (optVerbose opts) descr new_nl new_ixes
exitWith $ ExitFailure 1
let verbose = optVerbose opts
- disk_template = optDiskTemplate opts
- req_nodes = Instance.requiredNodes disk_template
machine_r = optMachineReadable opts
orig_cdata@(ClusterData gl fixed_nl il _ ipol) <- loadExternalData opts
nl <- setNodeStatus opts fixed_nl
+ cluster_disk_template <-
+ case iPolicyDiskTemplates ipol of
+ first_templ:_ -> return first_templ
+ _ -> do
+ _ <- hPutStrLn stderr $ "Error: null list of disk templates\
+ \ received from cluster!"
+ exitWith $ ExitFailure 1
+
let num_instances = Container.size il
all_nodes = Container.elems fixed_nl
cdata = orig_cdata { cdNodes = fixed_nl }
+ disk_template = fromMaybe cluster_disk_template (optDiskTemplate opts)
+ req_nodes = Instance.requiredNodes disk_template
csf = commonSuffix fixed_nl il
when (not (null csf) && verbose > 1) $
runAllocation cdata stop_allocation
(Cluster.tieredAlloc nl il alloclimit
(instFromSpec tspec disk_template) allocnodes [] [])
- tspec SpecTiered opts
+ tspec disk_template SpecTiered opts
printTiered machine_r spec_map (optMcpu opts) nl trl_nl treason
runAllocation cdata stop_allocation
(Cluster.iterateAlloc nl il alloclimit
(instFromSpec ispec disk_template) allocnodes [] [])
- ispec SpecNormal opts
+ ispec disk_template SpecNormal opts
printResults machine_r nl fin_nl num_instances allocs sreason
The options that can be passed to the program are as follows:
--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.
+ Overrides the disk template for the instance read from the cluster;
+ one of the Ganeti disk templates (e.g. plain, drbd, so on) should be
+ passed in.
--max-cpu=*cpu-ratio*
The maximum virtual to physical cpu ratio, as a floating point number