module Ganeti.DataCollectors.CLI
( Options(..)
, OptType
, defaultOptions
, oShowHelp
, oShowVer
, oShowComp
, oDrbdPairing
, oDrbdStatus
, oNode
, oConfdAddr
, oConfdPort
, oInputFile
, oInstances
, genericOptions
) where
import System.Console.GetOpt
import Ganeti.BasicTypes
import Ganeti.Common as Common
import Ganeti.Utils
data Options = Options
{ optShowHelp :: Bool
, optShowComp :: Bool
, optShowVer :: Bool
, optDrbdStatus :: Maybe FilePath
, optDrbdPairing :: Maybe FilePath
, optNode :: Maybe String
, optConfdAddr :: Maybe String
, optConfdPort :: Maybe Int
, optInputFile :: Maybe FilePath
, optInstances :: Maybe FilePath
} deriving Show
defaultOptions :: Options
defaultOptions = Options
{ optShowHelp = False
, optShowComp = False
, optShowVer = False
, optDrbdStatus = Nothing
, optDrbdPairing = Nothing
, optNode = Nothing
, optConfdAddr = Nothing
, optConfdPort = Nothing
, optInputFile = Nothing
, optInstances = Nothing
}
type OptType = GenericOptType Options
instance StandardOptions Options where
helpRequested = optShowHelp
verRequested = optShowVer
compRequested = optShowComp
requestHelp o = o { optShowHelp = True }
requestVer o = o { optShowVer = True }
requestComp o = o { optShowComp = True }
oDrbdPairing :: OptType
oDrbdPairing =
( Option "p" ["drbd-pairing"]
(ReqArg (\ f o -> Ok o { optDrbdPairing = Just f}) "FILE")
"the FILE containing pairings between instances and DRBD minors",
OptComplFile)
oDrbdStatus :: OptType
oDrbdStatus =
( Option "s" ["drbd-status"]
(ReqArg (\ f o -> Ok o { optDrbdStatus = Just f }) "FILE")
"the DRBD status FILE",
OptComplFile)
oNode :: OptType
oNode =
( Option "n" ["node"]
(ReqArg (\ n o -> Ok o { optNode = Just n }) "NODE")
"the FQDN of the NODE about which information is requested",
OptComplFile)
oConfdAddr :: OptType
oConfdAddr =
( Option "a" ["address"]
(ReqArg (\ a o -> Ok o { optConfdAddr = Just a }) "IP_ADDR")
"the IP address of the Confd server to connect to",
OptComplFile)
oConfdPort :: OptType
oConfdPort =
(Option "p" ["port"]
(reqWithConversion (tryRead "reading port")
(\port opts -> Ok opts { optConfdPort = Just port }) "PORT")
"Network port of the Confd server to connect to",
OptComplInteger)
oInputFile :: OptType
oInputFile =
( Option "f" ["file"]
(ReqArg (\ f o -> Ok o { optInputFile = Just f }) "FILE")
"the input FILE",
OptComplFile)
oInstances :: OptType
oInstances =
( Option "i" ["instances"]
(ReqArg (\ f o -> Ok o { optInstances = Just f}) "FILE")
"the FILE containing serialized instances",
OptComplFile)
genericOptions :: [GenericOptType Options]
genericOptions = [ oShowVer
, oShowHelp
, oShowComp
]