module Ganeti.DataCollectors.CLI
( Options(..)
, OptType
, defaultOptions
, oShowHelp
, oShowVer
, oShowComp
, oDrbdPairing
, oDrbdStatus
, oNode
, oConfdAddr
, oConfdPort
, 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
} deriving Show
defaultOptions :: Options
defaultOptions = Options
{ optShowHelp = False
, optShowComp = False
, optShowVer = False
, optDrbdStatus = Nothing
, optDrbdPairing = Nothing
, optNode = Nothing
, optConfdAddr = Nothing
, optConfdPort = 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)
genericOptions :: [GenericOptType Options]
genericOptions = [ oShowVer
, oShowHelp
, oShowComp
]