398 |
398 |
Instance.create "new" (rspecMem spx) (rspecDsk spx) [rspecDsk spx]
|
399 |
399 |
(rspecCpu spx) Running [] True (-1) (-1)
|
400 |
400 |
|
|
401 |
combineTiered :: Maybe Int -> Cluster.AllocNodes -> Cluster.AllocResult ->
|
|
402 |
Instance.Instance -> Result Cluster.AllocResult
|
|
403 |
combineTiered limit allocnodes result inst = do
|
|
404 |
let (_, nl, il, ixes, cstats) = result
|
|
405 |
ixes_cnt = length ixes
|
|
406 |
(stop, newlimit) = case limit of
|
|
407 |
Nothing -> (False, Nothing)
|
|
408 |
Just n -> (n <= ixes_cnt, Just (n - ixes_cnt))
|
|
409 |
if stop
|
|
410 |
then return result
|
|
411 |
else Cluster.tieredAlloc nl il newlimit inst allocnodes ixes cstats
|
|
412 |
|
401 |
413 |
-- | Main function.
|
402 |
414 |
main :: Options -> [String] -> IO ()
|
403 |
415 |
main opts args = do
|
... | ... | |
447 |
459 |
-- Run the tiered allocation
|
448 |
460 |
|
449 |
461 |
let minmaxes = iPolicyMinMaxISpecs ipol
|
450 |
|
-- TODO: Go through all min/max specs pairs
|
451 |
|
tspec <- case minmaxes of
|
452 |
|
[] -> exitErr "Empty list of specs received from the cluster"
|
453 |
|
minmax:_ -> return $ fromMaybe
|
454 |
|
(rspecFromISpec (minMaxISpecsMaxSpec minmax))
|
455 |
|
(optTieredSpec opts)
|
|
462 |
tspecs = case optTieredSpec opts of
|
|
463 |
Nothing -> map (rspecFromISpec . minMaxISpecsMaxSpec)
|
|
464 |
minmaxes
|
|
465 |
Just t -> [t]
|
|
466 |
tinsts = map (\ts -> instFromSpec ts disk_template su) tspecs
|
|
467 |
tspec <- case tspecs of
|
|
468 |
[] -> exitErr "Empty list of specs received from the cluster"
|
|
469 |
t:_ -> return t
|
456 |
470 |
|
457 |
471 |
(treason, trl_nl, _, spec_map) <-
|
458 |
472 |
runAllocation cdata stop_allocation
|
459 |
|
(Cluster.tieredAlloc nl il alloclimit
|
460 |
|
(instFromSpec tspec disk_template su) allocnodes [] [])
|
|
473 |
(foldM (combineTiered alloclimit allocnodes) ([], nl, il, [], []) tinsts)
|
461 |
474 |
tspec disk_template SpecTiered opts
|
462 |
475 |
|
463 |
476 |
printTiered machine_r spec_map nl trl_nl treason
|