Safe Haskell | None |
---|
Implementation of the Ganeti LUXI interface.
- withTimeout :: Int -> String -> IO a -> IO a
- data RecvResult
- = RecvConnClosed
- | RecvError String
- | RecvOk String
- data LuxiOp
- = Query ItemType [String] (Filter FilterField)
- | QueryFields ItemType [String]
- | QueryNodes [String] [String] Bool
- | QueryGroups [String] [String] Bool
- | QueryNetworks [String] [String] Bool
- | QueryInstances [String] [String] Bool
- | QueryJobs [JobId] [String]
- | QueryExports [String] Bool
- | QueryConfigValues [String]
- | QueryClusterInfo
- | QueryTags TagObject
- | SubmitJob [MetaOpCode]
- | SubmitManyJobs [[MetaOpCode]]
- | WaitForJobChange JobId [String] JSValue JSValue Int
- | ArchiveJob JobId
- | AutoArchiveJobs Int Int
- | CancelJob JobId
- | ChangeJobPriority JobId Int
- | SetDrainFlag Bool
- | SetWatcherPause Double
- data LuxiReq
- = ReqQuery
- | ReqQueryFields
- | ReqQueryNodes
- | ReqQueryGroups
- | ReqQueryNetworks
- | ReqQueryInstances
- | ReqQueryJobs
- | ReqQueryExports
- | ReqQueryConfigValues
- | ReqQueryClusterInfo
- | ReqQueryTags
- | ReqSubmitJob
- | ReqSubmitManyJobs
- | ReqWaitForJobChange
- | ReqArchiveJob
- | ReqAutoArchiveJobs
- | ReqCancelJob
- | ReqChangeJobPriority
- | ReqSetDrainFlag
- | ReqSetWatcherPause
- luxiReqFromRaw :: forall m. Monad m => String -> m LuxiReq
- luxiReqToRaw :: LuxiReq -> String
- opToArgs :: LuxiOp -> JSValue
- opToDict :: LuxiOp -> [(String, JSValue)]
- allLuxiCalls :: [String]
- strOfOp :: LuxiOp -> String
- data LuxiCall = LuxiCall LuxiReq JSValue
- eOM :: Word8
- bEOM :: ByteString
- data MsgKeys
- strOfKey :: MsgKeys -> String
- data Client = Client {}
- getClient :: String -> IO Client
- getServer :: Bool -> FilePath -> IO Socket
- closeServer :: FilePath -> Socket -> IO ()
- acceptClient :: Socket -> IO Client
- closeClient :: Client -> IO ()
- sendMsg :: Client -> String -> IO ()
- recvUpdate :: Handle -> ByteString -> IO (ByteString, ByteString)
- recvMsg :: Client -> IO String
- recvMsgExt :: Client -> IO RecvResult
- buildCall :: LuxiOp -> String
- buildResponse :: Bool -> JSValue -> String
- validateCall :: String -> Result LuxiCall
- decodeCall :: LuxiCall -> Result LuxiOp
- validateResult :: String -> ErrorResult JSValue
- decodeError :: JSValue -> ErrorResult JSValue
- callMethod :: LuxiOp -> Client -> IO (ErrorResult JSValue)
- parseSubmitJobResult :: JSValue -> ErrorResult JobId
- submitManyJobs :: Client -> [[MetaOpCode]] -> IO (ErrorResult [JobId])
- queryJobsStatus :: Client -> [JobId] -> IO (ErrorResult [JobStatus])
Utility functions
withTimeout :: Int -> String -> IO a -> IO aSource
Generic protocol functionality
data RecvResult Source
Result of receiving a message from the socket.
RecvConnClosed | Connection closed |
RecvError String | Any other error |
RecvOk String | Successfull receive |
Eq RecvResult | |
Show RecvResult |
Currently supported Luxi operations and JSON serialization.
Query ItemType [String] (Filter FilterField) | |
QueryFields ItemType [String] | |
QueryNodes [String] [String] Bool | |
QueryGroups [String] [String] Bool | |
QueryNetworks [String] [String] Bool | |
QueryInstances [String] [String] Bool | |
QueryJobs [JobId] [String] | |
QueryExports [String] Bool | |
QueryConfigValues [String] | |
QueryClusterInfo | |
QueryTags TagObject | |
SubmitJob [MetaOpCode] | |
SubmitManyJobs [[MetaOpCode]] | |
WaitForJobChange JobId [String] JSValue JSValue Int | |
ArchiveJob JobId | |
AutoArchiveJobs Int Int | |
CancelJob JobId | |
ChangeJobPriority JobId Int | |
SetDrainFlag Bool | |
SetWatcherPause Double |
luxiReqFromRaw :: forall m. Monad m => String -> m LuxiReqSource
luxiReqToRaw :: LuxiReq -> StringSource
allLuxiCalls :: [String]Source
List of all defined Luxi calls.
closeServer :: FilePath -> Socket -> IO ()Source
Closes a server endpoint. FIXME: this should be encapsulated into a nicer type.
acceptClient :: Socket -> IO ClientSource
Accepts a client
closeClient :: Client -> IO ()Source
Closes the client socket.
recvUpdate :: Handle -> ByteString -> IO (ByteString, ByteString)Source
recvMsgExt :: Client -> IO RecvResultSource
Extended wrapper over recvMsg.
:: Bool | Success |
-> JSValue | The arguments |
-> String | The serialized form |
Serialize the response to String.
validateCall :: String -> Result LuxiCallSource
Check that luxi request contains the required keys and parse it.
decodeCall :: LuxiCall -> Result LuxiOpSource
Converts Luxi call arguments into a LuxiOp
data structure.
This is currently hand-coded until we make it more uniform so that it can be generated using TH.
validateResult :: String -> ErrorResult JSValueSource
decodeError :: JSValue -> ErrorResult JSValueSource
callMethod :: LuxiOp -> Client -> IO (ErrorResult JSValue)Source
Generic luxi method call.
parseSubmitJobResult :: JSValue -> ErrorResult JobIdSource
submitManyJobs :: Client -> [[MetaOpCode]] -> IO (ErrorResult [JobId])Source
Specialized submitManyJobs call.
queryJobsStatus :: Client -> [JobId] -> IO (ErrorResult [JobStatus])Source
Custom queryJobs call.