diff --git a/htools/Ganeti/HTools/CLI.hs b/htools/Ganeti/HTools/CLI.hs index 405b51be754b31683b68d6536d10e29ba1748834..c953aec7fa67767df6d24a8f76889c81d9534edc 100644 --- a/htools/Ganeti/HTools/CLI.hs +++ b/htools/Ganeti/HTools/CLI.hs @@ -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") diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index 61c4eea5e2b8020f8674a96baa323cc60a6bbba8..c7fcfdea4e40bf26900212f85e5691092dbf6556 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -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 diff --git a/man/hspace.rst b/man/hspace.rst index f674c5b35880ad85aacb9d5459d8b953a2105755..b6b9d84004b78717be0547b23f212e3107c78848 100644 --- a/man/hspace.rst +++ b/man/hspace.rst @@ -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