-}
-module Ganeti.HTools.Program.Hspace (main, options) where
+module Ganeti.HTools.Program.Hspace
+ (main
+ , options
+ , arguments
+ ) where
import Control.Monad
import Data.Char (toUpper, toLower)
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
-import Ganeti.HTools.Utils
+import Ganeti.BasicTypes
+import Ganeti.Common
import Ganeti.HTools.Types
import Ganeti.HTools.CLI
import Ganeti.HTools.ExtLoader
import Ganeti.HTools.Loader
+import Ganeti.Utils
-- | Options list and functions.
-options :: [OptType]
-options =
- [ oPrintNodes
- , oDataFile
- , oDiskTemplate
- , oSpindleUse
- , oNodeSim
- , oRapiMaster
- , oLuxiSocket
- , oIAllocSrc
- , oVerbose
- , oQuiet
- , oOfflineNode
- , oMachineReadable
- , oMaxCpu
- , oMaxSolLength
- , oMinDisk
- , oStdSpec
- , oTieredSpec
- , oSaveCluster
- , oShowVer
- , oShowHelp
- ]
+options :: IO [OptType]
+options = do
+ luxi <- oLuxiSocket
+ return
+ [ oPrintNodes
+ , oDataFile
+ , oDiskTemplate
+ , oSpindleUse
+ , oNodeSim
+ , oRapiMaster
+ , luxi
+ , oIAllocSrc
+ , oVerbose
+ , oQuiet
+ , oOfflineNode
+ , oMachineReadable
+ , oMaxCpu
+ , oMaxSolLength
+ , oMinDisk
+ , oStdSpec
+ , oTieredSpec
+ , oSaveCluster
+ ]
+
+-- | The list of arguments supported by the program.
+arguments :: [ArgCompletion]
+arguments = []
-- | The allocation phase we're in (initial, after tiered allocs, or
-- after regular allocation).
cpuEff = effFn Cluster.csIcpu (fromIntegral . Cluster.csVcpu)
-- | Holds data for converting a 'Cluster.CStats' structure into
--- detailed statictics.
+-- detailed statistics.
statsData :: [(String, Cluster.CStats -> String)]
statsData = [ ("SCORE", printf "%.8f" . Cluster.csScore)
, ("INST_CNT", printf "%d" . Cluster.csNinst)
-- | Create an instance from a given spec.
instFromSpec :: RSpec -> DiskTemplate -> Int -> Instance.Instance
-instFromSpec spx disk_template su =
+instFromSpec spx =
Instance.create "new" (rspecMem spx) (rspecDsk spx)
- (rspecCpu spx) Running [] True (-1) (-1) disk_template su
+ (rspecCpu spx) Running [] True (-1) (-1)
-- | Main function.
main :: Options -> [String] -> IO ()
main opts args = do
- exitUnless (null args) "this program doesn't take any arguments"
+ exitUnless (null args) "This program doesn't take any arguments."
let verbose = optVerbose opts
machine_r = optMachineReadable opts