import Control.Monad
import Data.Maybe (fromMaybe, isJust)
import System.IO
-import System.Exit
import qualified Ganeti.HTools.Cluster as Cluster
import Ganeti.Common
import Ganeti.HTools.CLI
-import Ganeti.HTools.IAlloc
+import Ganeti.HTools.Backend.IAlloc
import Ganeti.HTools.Loader (Request(..), ClusterData(..))
import Ganeti.HTools.ExtLoader (maybeSaveData, loadExternalData)
+import Ganeti.Utils
-- | Options list and functions.
-options :: [OptType]
+options :: IO [OptType]
options =
- [ oPrintNodes
- , oSaveCluster
- , oDataFile
- , oNodeSim
- , oVerbose
- ]
+ return
+ [ oPrintNodes
+ , oSaveCluster
+ , oDataFile
+ , oNodeSim
+ , oVerbose
+ ]
-- | The list of arguments supported by the program.
arguments :: [ArgCompletion]
wrapReadRequest :: Options -> [String] -> IO Request
wrapReadRequest opts args = do
- when (null args) $ do
- hPutStrLn stderr "Error: this program needs an input file."
- exitWith $ ExitFailure 1
+ when (null args) $ exitErr "This program needs an input file."
r1 <- readRequest (head args)
if isJust (optDataFile opts) || (not . null . optNodeSim) opts