X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/f4c0b8c56c299484c28d65575dcddd11d2e16ada..017a0c3d6c9dbfe65c81612ccc388a40ed3e81fc:/Ganeti/HTools/CLI.hs diff --git a/Ganeti/HTools/CLI.hs b/Ganeti/HTools/CLI.hs index 4fd0ed0..bc2dad0 100644 --- a/Ganeti/HTools/CLI.hs +++ b/Ganeti/HTools/CLI.hs @@ -8,7 +8,7 @@ and this is more IO oriented. {- -Copyright (C) 2009 Google Inc. +Copyright (C) 2009, 2010 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,6 +41,7 @@ module Ganeti.HTools.CLI , oExInst , oExTags , oExecJobs + , oGroup , oIDisk , oIMem , oINodes @@ -49,6 +50,8 @@ module Ganeti.HTools.CLI , oMaxCpu , oMaxSolLength , oMinDisk + , oMinGain + , oMinGainLim , oMinScore , oNoHeaders , oNodeSim @@ -60,6 +63,7 @@ module Ganeti.HTools.CLI , oPrintNodes , oQuiet , oRapiMaster + , oSaveCluster , oShowHelp , oShowVer , oTieredSpec @@ -92,6 +96,7 @@ data Options = Options , optExInst :: [String] -- ^ Instances to be excluded , optExTags :: Maybe [String] -- ^ Tags to use for exclusion , optExecJobs :: Bool -- ^ Execute the commands via Luxi + , optGroup :: Maybe GroupID -- ^ The UUID of the group to process , optINodes :: Int -- ^ Nodes required for an instance , optISpec :: RSpec -- ^ Requested instance specs , optLuxi :: Maybe FilePath -- ^ Collect data from Luxi @@ -99,12 +104,15 @@ data Options = Options , optMaxLength :: Int -- ^ Stop after this many steps , optMcpu :: Double -- ^ Max cpu ratio for nodes , optMdsk :: Double -- ^ Max disk usage ratio for nodes + , optMinGain :: Score -- ^ Min gain we aim for in a step + , optMinGainLim :: Score -- ^ Limit below which we apply mingain , optMinScore :: Score -- ^ The minimum score we aim for , optNoHeaders :: Bool -- ^ Do not show a header line - , optNodeSim :: Maybe String -- ^ Cluster simulation mode + , optNodeSim :: [String] -- ^ Cluster simulation mode , optOffline :: [String] -- ^ Names of offline nodes , optOneline :: Bool -- ^ Switch output to a single line , optOutPath :: FilePath -- ^ Path to the output directory + , optSaveCluster :: Maybe FilePath -- ^ Save cluster state to this file , optShowCmds :: Maybe FilePath -- ^ Whether to show the command list , optShowHelp :: Bool -- ^ Just show the help , optShowInsts :: Bool -- ^ Whether to show the instance map @@ -124,6 +132,7 @@ defaultOptions = Options , optExInst = [] , optExTags = Nothing , optExecJobs = False + , optGroup = Nothing , optINodes = 2 , optISpec = RSpec 1 4096 102400 , optLuxi = Nothing @@ -131,12 +140,15 @@ defaultOptions = Options , optMaxLength = -1 , optMcpu = defVcpuRatio , optMdsk = defReservedDiskRatio + , optMinGain = 1e-2 + , optMinGainLim = 1e-1 , optMinScore = 1e-9 , optNoHeaders = False - , optNodeSim = Nothing + , optNodeSim = [] , optOffline = [] , optOneline = False , optOutPath = "." + , optSaveCluster = Nothing , optShowCmds = Nothing , optShowHelp = False , optShowInsts = False @@ -187,6 +199,11 @@ oExecJobs = Option "X" ["exec"] "execute the suggested moves via Luxi (only available when using\ \ it for data gathering)" +oGroup :: OptType +oGroup = Option "G" ["group"] + (ReqArg (\ f o -> Ok o { optGroup = Just f }) "ID") + "the ID of the group to balance" + oIDisk :: OptType oIDisk = Option "" ["disk"] (ReqArg (\ d opts -> @@ -239,10 +256,20 @@ oMinDisk = Option "" ["min-disk"] (ReqArg (\ n opts -> Ok opts { optMdsk = read n }) "RATIO") "minimum free disk space for nodes (between 0 and 1) [0]" +oMinGain :: OptType +oMinGain = Option "g" ["min-gain"] + (ReqArg (\ g opts -> Ok opts { optMinGain = read g }) "DELTA") + "minimum gain to aim for in a balancing step before giving up" + +oMinGainLim :: OptType +oMinGainLim = Option "" ["min-gain-limit"] + (ReqArg (\ g opts -> Ok opts { optMinGainLim = read g }) "SCORE") + "minimum cluster score for which we start checking the min-gain" + oMinScore :: OptType oMinScore = Option "e" ["min-score"] (ReqArg (\ e opts -> Ok opts { optMinScore = read e }) "EPSILON") - " mininum score to aim for" + "mininum score to aim for" oNoHeaders :: OptType oNoHeaders = Option "" ["no-headers"] @@ -251,7 +278,7 @@ oNoHeaders = Option "" ["no-headers"] oNodeSim :: OptType oNodeSim = Option "" ["simulate"] - (ReqArg (\ f o -> Ok o { optNodeSim = Just f }) "SPEC") + (ReqArg (\ f o -> Ok o { optNodeSim = f:optNodeSim o }) "SPEC") "simulate an empty cluster, given as 'num_nodes,disk,ram,cpu'" oOfflineNode :: OptType @@ -286,7 +313,10 @@ oPrintInsts = Option "" ["print-instances"] oPrintNodes :: OptType oPrintNodes = Option "p" ["print-nodes"] (OptArg ((\ f opts -> - let splitted = sepSplit ',' f + let (prefix, realf) = case f of + '+':rest -> (["+"], rest) + _ -> ([], f) + splitted = prefix ++ sepSplit ',' realf in Ok opts { optShowNodes = Just splitted }) . fromMaybe []) "FIELDS") "print the final node list" @@ -301,6 +331,11 @@ oRapiMaster = Option "m" ["master"] (ReqArg (\ m opts -> Ok opts { optMaster = m }) "ADDRESS") "collect data via RAPI at the given ADDRESS" +oSaveCluster :: OptType +oSaveCluster = Option "S" ["save"] + (ReqArg (\ f opts -> Ok opts { optSaveCluster = Just f }) "FILE") + "Save cluster state at the end of the processing to FILE" + oShowHelp :: OptType oShowHelp = Option "h" ["help"] (NoArg (\ opts -> Ok opts { optShowHelp = True})) @@ -319,7 +354,8 @@ oTieredSpec = Option "" ["tiered-alloc"] tspec <- case prs of [dsk, ram, cpu] -> return $ RSpec cpu ram dsk - _ -> Bad $ "Invalid specification: " ++ inp + _ -> Bad $ "Invalid specification: " ++ inp ++ + ", expected disk,ram,cpu" return $ opts { optTieredSpec = Just tspec } ) "TSPEC") "enable tiered specs allocation, given as 'disk,ram,cpu'"