htools: fix corner case in prop_Text_Load_Instance
[ganeti-local] / htools / Ganeti / HTools / CLI.hs
index b000a00..33cacd9 100644 (file)
@@ -8,7 +8,7 @@ and this is more IO oriented.
 
 {-
 
-Copyright (C) 2009, 2010 Google Inc.
+Copyright (C) 2009, 2010, 2011 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
@@ -38,6 +38,8 @@ module Ganeti.HTools.CLI
     -- * The options
     , oDataFile
     , oDiskMoves
+    , oSelInst
+    , oInstMoves
     , oDynuFile
     , oEvacMode
     , oExInst
@@ -65,6 +67,7 @@ module Ganeti.HTools.CLI
     , oPrintNodes
     , oQuiet
     , oRapiMaster
+    , oReplay
     , oSaveCluster
     , oShowHelp
     , oShowVer
@@ -72,9 +75,9 @@ module Ganeti.HTools.CLI
     , oVerbose
     ) where
 
+import Control.Monad
 import Data.Maybe (fromMaybe)
 import qualified Data.Version
-import Monad
 import System.Console.GetOpt
 import System.IO
 import System.Info
@@ -82,23 +85,26 @@ import System
 import Text.Printf (printf)
 
 import qualified Ganeti.HTools.Version as Version(version)
+import qualified Ganeti.Constants as C
 import Ganeti.HTools.Types
 import Ganeti.HTools.Utils
 
 -- | The default value for the luxi socket
 defaultLuxiSocket :: FilePath
-defaultLuxiSocket = "/var/run/ganeti/socket/ganeti-master"
+defaultLuxiSocket = C.masterSocket
 
 -- | Command line options structure.
 data Options = Options
     { optDataFile    :: Maybe FilePath -- ^ Path to the cluster data file
     , optDiskMoves   :: Bool           -- ^ Allow disk moves
+    , optInstMoves   :: Bool           -- ^ Allow instance moves
     , optDynuFile    :: Maybe FilePath -- ^ Optional file with dynamic use data
     , optEvacMode    :: Bool           -- ^ Enable evacuation mode
     , 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
+    , optSelInst     :: [String]       -- ^ Instances to be excluded
     , optINodes      :: Int            -- ^ Nodes required for an instance
     , optISpec       :: RSpec          -- ^ Requested instance specs
     , optLuxi        :: Maybe FilePath -- ^ Collect data from Luxi
@@ -121,6 +127,7 @@ data Options = Options
     , optShowNodes   :: Maybe [String] -- ^ Whether to show node status
     , optShowVer     :: Bool           -- ^ Just show the program version
     , optTieredSpec  :: Maybe RSpec    -- ^ Requested specs for tiered mode
+    , optReplay      :: Maybe String   -- ^ Unittests: RNG state
     , optVerbose     :: Int            -- ^ Verbosity level
     } deriving Show
 
@@ -129,12 +136,14 @@ defaultOptions :: Options
 defaultOptions  = Options
  { optDataFile    = Nothing
  , optDiskMoves   = True
+ , optInstMoves   = True
  , optDynuFile    = Nothing
  , optEvacMode    = False
  , optExInst      = []
  , optExTags      = Nothing
  , optExecJobs    = False
  , optGroup       = Nothing
+ , optSelInst     = []
  , optINodes      = 2
  , optISpec       = RSpec 1 4096 102400
  , optLuxi        = Nothing
@@ -157,6 +166,7 @@ defaultOptions  = Options
  , optShowNodes   = Nothing
  , optShowVer     = False
  , optTieredSpec  = Nothing
+ , optReplay      = Nothing
  , optVerbose     = 1
  }
 
@@ -174,6 +184,18 @@ oDiskMoves = Option "" ["no-disk-moves"]
              "disallow disk moves from the list of allowed instance changes,\
              \ thus allowing only the 'cheap' failover/migrate operations"
 
+oSelInst :: OptType
+oSelInst = Option "" ["select-instances"]
+          (ReqArg (\ f opts -> Ok opts { optSelInst = sepSplit ',' f }) "INSTS")
+          "only select given instances for any moves"
+
+oInstMoves :: OptType
+oInstMoves = Option "" ["no-instance-moves"]
+             (NoArg (\ opts -> Ok opts { optInstMoves = False}))
+             "disallow instance (primary node) moves from the list of allowed,\
+             \ instance changes, thus allowing only slower, but sometimes\
+             \ safer, drbd secondary changes"
+
 oDynuFile :: OptType
 oDynuFile = Option "U" ["dynu-file"]
             (ReqArg (\ f opts -> Ok opts { optDynuFile = Just f }) "FILE")
@@ -188,7 +210,7 @@ oEvacMode = Option "E" ["evac-mode"]
 oExInst :: OptType
 oExInst = Option "" ["exclude-instances"]
           (ReqArg (\ f opts -> Ok opts { optExInst = sepSplit ',' f }) "INSTS")
-          "exclude given instances  from any moves"
+          "exclude given instances from any moves"
 
 oExTags :: OptType
 oExTags = Option "" ["exclusion-tags"]
@@ -362,6 +384,11 @@ oTieredSpec = Option "" ["tiered-alloc"]
               "TSPEC")
              "enable tiered specs allocation, given as 'disk,ram,cpu'"
 
+oReplay :: OptType
+oReplay = Option "" ["replay"]
+          (ReqArg (\ stat opts -> Ok opts { optReplay = Just stat } ) "STATE")
+          "Pre-seed the random number generator with STATE"
+
 oVerbose :: OptType
 oVerbose = Option "v" ["verbose"]
            (NoArg (\ opts -> Ok opts { optVerbose = optVerbose opts + 1 }))