ganeti

Safe HaskellNone

Ganeti.Luxi

Contents

Description

Implementation of the Ganeti LUXI interface.

Synopsis

Utility functions

withTimeout :: Int -> String -> IO a -> IO aSource

Generic protocol functionality

data RecvResult Source

Result of receiving a message from the socket.

Constructors

RecvConnClosed

Connection closed

RecvError String

Any other error

RecvOk String

Successfull receive

Instances

data LuxiOp Source

Currently supported Luxi operations and JSON serialization.

Constructors

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 

Instances

Eq LuxiOp 
Show LuxiOp 
Arbitrary LuxiOp 

luxiReqFromRaw :: forall m. Monad m => String -> m LuxiReqSource

opToArgs :: LuxiOp -> JSValueSource

opToDict :: LuxiOp -> [(String, JSValue)]Source

allLuxiCalls :: [String]Source

List of all defined Luxi calls.

strOfOp :: LuxiOp -> StringSource

The serialisation of LuxiOps into strings in messages.

data LuxiCall Source

Constructors

LuxiCall LuxiReq JSValue 

eOM :: Word8Source

bEOM :: ByteStringSource

data MsgKeys Source

Constructors

Method 
Args 
Success 
Result 

strOfKey :: MsgKeys -> StringSource

data Client Source

Luxi client encapsulation.

Constructors

Client 

Fields

socket :: Handle
 
rbuf :: IORef ByteString
 

getClient :: String -> IO ClientSource

Connects to the master daemon and returns a luxi Client.

getServer :: Bool -> FilePath -> IO SocketSource

Creates and returns a server endpoint.

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.

sendMsg :: Client -> String -> IO ()Source

Sends a message over a luxi transport.

recvUpdate :: Handle -> ByteString -> IO (ByteString, ByteString)Source

recvMsg :: Client -> IO StringSource

Waits for a message over a luxi transport.

recvMsgExt :: Client -> IO RecvResultSource

Extended wrapper over recvMsg.

buildCallSource

Arguments

:: LuxiOp

The method

-> String

The serialized form

Serialize a request to String.

buildResponseSource

Arguments

:: 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.

submitManyJobs :: Client -> [[MetaOpCode]] -> IO (ErrorResult [JobId])Source

Specialized submitManyJobs call.

queryJobsStatus :: Client -> [JobId] -> IO (ErrorResult [JobStatus])Source

Custom queryJobs call.