Commit f0753837 authored by René Nussbaumer's avatar René Nussbaumer

hspace: Make use of the spindle_use

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 5850e990
......@@ -44,6 +44,7 @@ module Ganeti.HTools.CLI
, oDataFile
, oDiskMoves
, oDiskTemplate
, oSpindleUse
, oDynuFile
, oEvacMode
, oExInst
......@@ -113,6 +114,7 @@ data Options = Options
, optDiskMoves :: Bool -- ^ Allow disk moves
, optInstMoves :: Bool -- ^ Allow instance moves
, optDiskTemplate :: Maybe DiskTemplate -- ^ Override for the disk template
, optSpindleUse :: Maybe Int -- ^ Override for the spindle usage
, optDynuFile :: Maybe FilePath -- ^ Optional file with dynamic use data
, optEvacMode :: Bool -- ^ Enable evacuation mode
, optExInst :: [String] -- ^ Instances to be excluded
......@@ -154,6 +156,7 @@ defaultOptions = Options
, optDiskMoves = True
, optInstMoves = True
, optDiskTemplate = Nothing
, optSpindleUse = Nothing
, optDynuFile = Nothing
, optEvacMode = False
, optExInst = []
......@@ -228,6 +231,17 @@ oDiskTemplate = Option "" ["disk-template"]
return $ opts { optDiskTemplate = Just dt })
"TEMPLATE") "select the desired disk template"
oSpindleUse :: OptType
oSpindleUse = Option "" ["spindle-use"]
(ReqArg (\ n opts -> do
su <- tryRead "parsing spindle-use" n
when (su < 0) $
fail "Invalid value of the spindle-use\
\ (expected >= 0)"
return $ opts { optSpindleUse = Just su })
"SPINDLES") "select how many virtual spindle instances use\
\ [default read from cluster]"
oSelInst :: OptType
oSelInst = Option "" ["select-instances"]
(ReqArg (\ f opts -> Ok opts { optSelInst = sepSplit ',' f }) "INSTS")
......
......@@ -53,6 +53,7 @@ options =
[ oPrintNodes
, oDataFile
, oDiskTemplate
, oSpindleUse
, oNodeSim
, oRapiMaster
, oLuxiSocket
......@@ -386,10 +387,10 @@ runAllocation cdata stop_allocation actual_result spec dt mode opts = do
return (sortReasons reasons, new_nl, length new_ixes, tieredSpecMap new_ixes)
-- | Create an instance from a given spec.
instFromSpec :: RSpec -> DiskTemplate -> Instance.Instance
instFromSpec spx disk_template =
instFromSpec :: RSpec -> DiskTemplate -> Int -> Instance.Instance
instFromSpec spx disk_template su =
Instance.create "new" (rspecMem spx) (rspecDsk spx)
(rspecCpu spx) Running [] True (-1) (-1) disk_template 1
(rspecCpu spx) Running [] True (-1) (-1) disk_template su
-- | Main function.
main :: Options -> [String] -> IO ()
......@@ -418,6 +419,8 @@ main opts args = do
disk_template = fromMaybe cluster_disk_template (optDiskTemplate opts)
req_nodes = Instance.requiredNodes disk_template
csf = commonSuffix fixed_nl il
su = fromMaybe (iSpecSpindleUse $ iPolicyStdSpec ipol)
(optSpindleUse opts)
when (not (null csf) && verbose > 1) $
hPrintf stderr "Note: Stripping common suffix of '%s' from names\n" csf
......@@ -447,7 +450,7 @@ main opts args = do
(treason, trl_nl, _, spec_map) <-
runAllocation cdata stop_allocation
(Cluster.tieredAlloc nl il alloclimit
(instFromSpec tspec disk_template) allocnodes [] [])
(instFromSpec tspec disk_template su) allocnodes [] [])
tspec disk_template SpecTiered opts
printTiered machine_r spec_map nl trl_nl treason
......@@ -460,7 +463,7 @@ main opts args = do
(sreason, fin_nl, allocs, _) <-
runAllocation cdata stop_allocation
(Cluster.iterateAlloc nl il alloclimit
(instFromSpec ispec disk_template) allocnodes [] [])
(instFromSpec ispec disk_template su) allocnodes [] [])
ispec disk_template SpecNormal opts
printResults machine_r nl fin_nl num_instances allocs sreason
......
......@@ -207,6 +207,11 @@ The options that can be passed to the program are as follows:
one of the Ganeti disk templates (e.g. plain, drbd, so on) should be
passed in.
\--spindle-use *spindles*
Override the spindle use for the instance read from the cluster. The
value can be 0 (for example for instances that use very low I/O), but not
negative. For shared storage the value is ignored.
\--max-cpu=*cpu-ratio*
The maximum virtual to physical cpu ratio, as a floating point number
greater than or equal to one. For example, specifying *cpu-ratio* as
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment