Safe Haskell | None |
---|
Implementation of the RPC client.
- curlOpts :: [CurlOption]
- data RpcError
- = CurlLayerError String
- | JsonDecodeError String
- | RpcResultError String
- | OfflineNodeError
- explainRpcError :: RpcError -> String
- type ERpcError = Either RpcError
- class JSON a => RpcCall a where
- rpcCallName :: a -> String
- rpcCallTimeout :: a -> Int
- rpcCallData :: Node -> a -> String
- rpcCallAcceptOffline :: a -> Bool
- class (RpcCall a, JSON b) => Rpc a b | a -> b, b -> a where
- rpcResultFill :: a -> JSValue -> ERpcError b
- data HttpClientRequest = HttpClientRequest {
- requestUrl :: String
- requestData :: String
- requestOpts :: [CurlOption]
- isIpV6 :: String -> Bool
- prepareUrl :: RpcCall a => Node -> a -> String
- prepareHttpRequest :: RpcCall a => [CurlOption] -> Node -> a -> ERpcError HttpClientRequest
- parseHttpReply :: Rpc a b => a -> ERpcError (CurlCode, String) -> ERpcError b
- parseHttpResponse :: Rpc a b => a -> String -> ERpcError b
- logRpcErrors :: [(a, ERpcError b)] -> IO ()
- executeRpcCall :: Rpc a b => [Node] -> a -> IO [(Node, ERpcError b)]
- sanitizeDictResults :: [(String, Result a)] -> ERpcError [(String, a)]
- fromJResultToRes :: Result a -> (a -> b) -> ERpcError b
- fromJSValueToRes :: JSON a => JSValue -> (a -> b) -> ERpcError b
- data RpcCallInstanceInfo = RpcCallInstanceInfo {
- rpcCallInstInfoInstance :: String
- rpcCallInstInfoHname :: Hypervisor
- loadRpcCallInstanceInfo :: JSValue -> Result RpcCallInstanceInfo
- saveRpcCallInstanceInfo :: RpcCallInstanceInfo -> JSValue
- toDictRpcCallInstanceInfo :: RpcCallInstanceInfo -> [(String, JSValue)]
- data InstanceInfo = InstanceInfo {
- instInfoMemory :: Int
- instInfoState :: String
- instInfoVcpus :: Int
- instInfoTime :: Int
- loadInstanceInfo :: JSValue -> Result InstanceInfo
- saveInstanceInfo :: InstanceInfo -> JSValue
- toDictInstanceInfo :: InstanceInfo -> [(String, JSValue)]
- data RpcResultInstanceInfo = RpcResultInstanceInfo {
- rpcResInstInfoInstInfo :: Maybe InstanceInfo
- loadRpcResultInstanceInfo :: JSValue -> Result RpcResultInstanceInfo
- saveRpcResultInstanceInfo :: RpcResultInstanceInfo -> JSValue
- toDictRpcResultInstanceInfo :: RpcResultInstanceInfo -> [(String, JSValue)]
- data RpcCallAllInstancesInfo = RpcCallAllInstancesInfo {}
- loadRpcCallAllInstancesInfo :: JSValue -> Result RpcCallAllInstancesInfo
- saveRpcCallAllInstancesInfo :: RpcCallAllInstancesInfo -> JSValue
- toDictRpcCallAllInstancesInfo :: RpcCallAllInstancesInfo -> [(String, JSValue)]
- data RpcResultAllInstancesInfo = RpcResultAllInstancesInfo {
- rpcResAllInstInfoInstances :: [(String, InstanceInfo)]
- loadRpcResultAllInstancesInfo :: JSValue -> Result RpcResultAllInstancesInfo
- saveRpcResultAllInstancesInfo :: RpcResultAllInstancesInfo -> JSValue
- toDictRpcResultAllInstancesInfo :: RpcResultAllInstancesInfo -> [(String, JSValue)]
- data RpcCallInstanceList = RpcCallInstanceList {}
- loadRpcCallInstanceList :: JSValue -> Result RpcCallInstanceList
- saveRpcCallInstanceList :: RpcCallInstanceList -> JSValue
- toDictRpcCallInstanceList :: RpcCallInstanceList -> [(String, JSValue)]
- data RpcResultInstanceList = RpcResultInstanceList {
- rpcResInstListInstances :: [String]
- loadRpcResultInstanceList :: JSValue -> Result RpcResultInstanceList
- saveRpcResultInstanceList :: RpcResultInstanceList -> JSValue
- toDictRpcResultInstanceList :: RpcResultInstanceList -> [(String, JSValue)]
- data RpcCallNodeInfo = RpcCallNodeInfo {
- rpcCallNodeInfoStorageUnits :: Map String [StorageUnit]
- rpcCallNodeInfoHypervisors :: [(Hypervisor, HvParams)]
- loadRpcCallNodeInfo :: JSValue -> Result RpcCallNodeInfo
- saveRpcCallNodeInfo :: RpcCallNodeInfo -> JSValue
- toDictRpcCallNodeInfo :: RpcCallNodeInfo -> [(String, JSValue)]
- data StorageInfo = StorageInfo {
- storageInfoName :: String
- storageInfoType :: String
- storageInfoStorageFree :: Maybe Int
- storageInfoStorageSize :: Maybe Int
- loadStorageInfo :: JSValue -> Result StorageInfo
- saveStorageInfo :: StorageInfo -> JSValue
- toDictStorageInfo :: StorageInfo -> [(String, JSValue)]
- data HvInfo = HvInfo {
- hvInfoMemoryTotal :: Int
- hvInfoMemoryFree :: Int
- hvInfoMemoryDom0 :: Int
- hvInfoCpuTotal :: Int
- hvInfoCpuNodes :: Int
- hvInfoCpuSockets :: Int
- hvInfoCpuDom0 :: Int
- loadHvInfo :: JSValue -> Result HvInfo
- saveHvInfo :: HvInfo -> JSValue
- toDictHvInfo :: HvInfo -> [(String, JSValue)]
- data RpcResultNodeInfo = RpcResultNodeInfo {
- rpcResNodeInfoBootId :: String
- rpcResNodeInfoStorageInfo :: [StorageInfo]
- rpcResNodeInfoHvInfo :: [HvInfo]
- loadRpcResultNodeInfo :: JSValue -> Result RpcResultNodeInfo
- saveRpcResultNodeInfo :: RpcResultNodeInfo -> JSValue
- toDictRpcResultNodeInfo :: RpcResultNodeInfo -> [(String, JSValue)]
- data RpcCallVersion = RpcCallVersion {
- loadRpcCallVersion :: JSValue -> Result RpcCallVersion
- saveRpcCallVersion :: RpcCallVersion -> JSValue
- toDictRpcCallVersion :: RpcCallVersion -> [(String, JSValue)]
- data RpcResultVersion = RpcResultVersion {
- rpcResultVersionVersion :: Int
- loadRpcResultVersion :: JSValue -> Result RpcResultVersion
- saveRpcResultVersion :: RpcResultVersion -> JSValue
- toDictRpcResultVersion :: RpcResultVersion -> [(String, JSValue)]
- data RpcCallStorageList = RpcCallStorageList {
- rpcCallStorageListSuName :: StorageType
- rpcCallStorageListSuArgs :: [String]
- rpcCallStorageListName :: String
- rpcCallStorageListFields :: [StorageField]
- loadRpcCallStorageList :: JSValue -> Result RpcCallStorageList
- saveRpcCallStorageList :: RpcCallStorageList -> JSValue
- toDictRpcCallStorageList :: RpcCallStorageList -> [(String, JSValue)]
- data RpcResultStorageList = RpcResultStorageList {
- rpcResStorageListStorage :: [[(StorageField, JSValue)]]
- loadRpcResultStorageList :: JSValue -> Result RpcResultStorageList
- saveRpcResultStorageList :: RpcResultStorageList -> JSValue
- toDictRpcResultStorageList :: RpcResultStorageList -> [(String, JSValue)]
- data RpcCallTestDelay = RpcCallTestDelay {
- rpcCallTestDelayDuration :: Double
- loadRpcCallTestDelay :: JSValue -> Result RpcCallTestDelay
- saveRpcCallTestDelay :: RpcCallTestDelay -> JSValue
- toDictRpcCallTestDelay :: RpcCallTestDelay -> [(String, JSValue)]
- data RpcResultTestDelay = RpcResultTestDelay
- data RpcCallExportList = RpcCallExportList {
- loadRpcCallExportList :: JSValue -> Result RpcCallExportList
- saveRpcCallExportList :: RpcCallExportList -> JSValue
- toDictRpcCallExportList :: RpcCallExportList -> [(String, JSValue)]
- data RpcResultExportList = RpcResultExportList {
- rpcResExportListExports :: [String]
- loadRpcResultExportList :: JSValue -> Result RpcResultExportList
- saveRpcResultExportList :: RpcResultExportList -> JSValue
- toDictRpcResultExportList :: RpcResultExportList -> [(String, JSValue)]
Base RPC functionality and types
Data type for RPC error reporting.
CurlLayerError String | |
JsonDecodeError String | |
RpcResultError String | |
OfflineNodeError |
explainRpcError :: RpcError -> StringSource
Provide explanation to RPC errors.
class JSON a => RpcCall a whereSource
A generic class for RPC calls.
rpcCallName :: a -> StringSource
Give the (Python) name of the procedure.
rpcCallTimeout :: a -> IntSource
Calculate the timeout value for the call execution.
rpcCallData :: Node -> a -> StringSource
Prepare arguments of the call to be send as POST.
rpcCallAcceptOffline :: a -> BoolSource
Whether we accept offline nodes when making a call.
class (RpcCall a, JSON b) => Rpc a b | a -> b, b -> a whereSource
Generic class that ensures matching RPC call with its respective result.
rpcResultFill :: a -> JSValue -> ERpcError bSource
Create a result based on the received HTTP response.
data HttpClientRequest Source
HttpClientRequest | |
|
prepareUrl :: RpcCall a => Node -> a -> StringSource
prepareHttpRequest :: RpcCall a => [CurlOption] -> Node -> a -> ERpcError HttpClientRequestSource
parseHttpReply :: Rpc a b => a -> ERpcError (CurlCode, String) -> ERpcError bSource
parseHttpResponse :: Rpc a b => a -> String -> ERpcError bSource
logRpcErrors :: [(a, ERpcError b)] -> IO ()Source
Scan the list of results produced by executeRpcCall and log all the RPC errors.
executeRpcCall :: Rpc a b => [Node] -> a -> IO [(Node, ERpcError b)]Source
Execute RPC call for many nodes in parallel.
sanitizeDictResults :: [(String, Result a)] -> ERpcError [(String, a)]Source
fromJResultToRes :: Result a -> (a -> b) -> ERpcError bSource
fromJSValueToRes :: JSON a => JSValue -> (a -> b) -> ERpcError bSource
RPC calls and results
Instance info
data RpcCallInstanceInfo Source
InstanceInfo Returns information about a single instance.
loadRpcCallInstanceInfo :: JSValue -> Result RpcCallInstanceInfoSource
saveRpcCallInstanceInfo :: RpcCallInstanceInfo -> JSValueSource
toDictRpcCallInstanceInfo :: RpcCallInstanceInfo -> [(String, JSValue)]Source
data InstanceInfo Source
InstanceInfo | |
|
Eq InstanceInfo | |
Show InstanceInfo | |
JSON InstanceInfo |
loadInstanceInfo :: JSValue -> Result InstanceInfoSource
saveInstanceInfo :: InstanceInfo -> JSValueSource
toDictInstanceInfo :: InstanceInfo -> [(String, JSValue)]Source
loadRpcResultInstanceInfo :: JSValue -> Result RpcResultInstanceInfoSource
saveRpcResultInstanceInfo :: RpcResultInstanceInfo -> JSValueSource
toDictRpcResultInstanceInfo :: RpcResultInstanceInfo -> [(String, JSValue)]Source
AllInstancesInfo
data RpcCallAllInstancesInfo Source
AllInstancesInfo Returns information about all running instances on the given nodes
loadRpcCallAllInstancesInfo :: JSValue -> Result RpcCallAllInstancesInfoSource
saveRpcCallAllInstancesInfo :: RpcCallAllInstancesInfo -> JSValueSource
toDictRpcCallAllInstancesInfo :: RpcCallAllInstancesInfo -> [(String, JSValue)]Source
data RpcResultAllInstancesInfo Source
RpcResultAllInstancesInfo | |
|
loadRpcResultAllInstancesInfo :: JSValue -> Result RpcResultAllInstancesInfoSource
saveRpcResultAllInstancesInfo :: RpcResultAllInstancesInfo -> JSValueSource
toDictRpcResultAllInstancesInfo :: RpcResultAllInstancesInfo -> [(String, JSValue)]Source
InstanceList
data RpcCallInstanceList Source
InstanceList Returns the list of running instances on the given nodes.
loadRpcCallInstanceList :: JSValue -> Result RpcCallInstanceListSource
saveRpcCallInstanceList :: RpcCallInstanceList -> JSValueSource
toDictRpcCallInstanceList :: RpcCallInstanceList -> [(String, JSValue)]Source
data RpcResultInstanceList Source
RpcResultInstanceList | |
|
loadRpcResultInstanceList :: JSValue -> Result RpcResultInstanceListSource
saveRpcResultInstanceList :: RpcResultInstanceList -> JSValueSource
toDictRpcResultInstanceList :: RpcResultInstanceList -> [(String, JSValue)]Source
NodeInfo
data RpcCallNodeInfo Source
NodeInfo Return node information.
RpcCallNodeInfo | |
|
Eq RpcCallNodeInfo | |
Show RpcCallNodeInfo | |
Arbitrary RpcCallNodeInfo | |
JSON RpcCallNodeInfo | |
RpcCall RpcCallNodeInfo | |
Rpc RpcCallNodeInfo RpcResultNodeInfo |
loadRpcCallNodeInfo :: JSValue -> Result RpcCallNodeInfoSource
saveRpcCallNodeInfo :: RpcCallNodeInfo -> JSValueSource
toDictRpcCallNodeInfo :: RpcCallNodeInfo -> [(String, JSValue)]Source
data StorageInfo Source
StorageInfo | |
|
Eq StorageInfo | |
Show StorageInfo | |
JSON StorageInfo |
loadStorageInfo :: JSValue -> Result StorageInfoSource
saveStorageInfo :: StorageInfo -> JSValueSource
toDictStorageInfo :: StorageInfo -> [(String, JSValue)]Source
We only provide common fields as described in hv_base.py.
HvInfo | |
|
loadHvInfo :: JSValue -> Result HvInfoSource
saveHvInfo :: HvInfo -> JSValueSource
toDictHvInfo :: HvInfo -> [(String, JSValue)]Source
data RpcResultNodeInfo Source
RpcResultNodeInfo | |
|
loadRpcResultNodeInfo :: JSValue -> Result RpcResultNodeInfoSource
saveRpcResultNodeInfo :: RpcResultNodeInfo -> JSValueSource
toDictRpcResultNodeInfo :: RpcResultNodeInfo -> [(String, JSValue)]Source
Version
data RpcCallVersion Source
Query node version.
loadRpcCallVersion :: JSValue -> Result RpcCallVersionSource
saveRpcCallVersion :: RpcCallVersion -> JSValueSource
toDictRpcCallVersion :: RpcCallVersion -> [(String, JSValue)]Source
data RpcResultVersion Source
Query node reply.
loadRpcResultVersion :: JSValue -> Result RpcResultVersionSource
saveRpcResultVersion :: RpcResultVersion -> JSValueSource
toDictRpcResultVersion :: RpcResultVersion -> [(String, JSValue)]Source
StorageList
data RpcCallStorageList Source
RpcCallStorageList | |
|
loadRpcCallStorageList :: JSValue -> Result RpcCallStorageListSource
saveRpcCallStorageList :: RpcCallStorageList -> JSValueSource
toDictRpcCallStorageList :: RpcCallStorageList -> [(String, JSValue)]Source
data RpcResultStorageList Source
RpcResultStorageList | |
|
loadRpcResultStorageList :: JSValue -> Result RpcResultStorageListSource
saveRpcResultStorageList :: RpcResultStorageList -> JSValueSource
toDictRpcResultStorageList :: RpcResultStorageList -> [(String, JSValue)]Source
TestDelay
data RpcCallTestDelay Source
Call definition for test delay.
RpcCallTestDelay | |
|
loadRpcCallTestDelay :: JSValue -> Result RpcCallTestDelaySource
saveRpcCallTestDelay :: RpcCallTestDelay -> JSValueSource
toDictRpcCallTestDelay :: RpcCallTestDelay -> [(String, JSValue)]Source
data RpcResultTestDelay Source
Result definition for test delay.
Show RpcResultTestDelay | |
JSON RpcResultTestDelay | Custom JSON instance for null result. |
Rpc RpcCallTestDelay RpcResultTestDelay |
ExportList
data RpcCallExportList Source
Call definition for export list.
loadRpcCallExportList :: JSValue -> Result RpcCallExportListSource
saveRpcCallExportList :: RpcCallExportList -> JSValueSource
toDictRpcCallExportList :: RpcCallExportList -> [(String, JSValue)]Source
data RpcResultExportList Source
Result definition for export list.
RpcResultExportList | |
|
loadRpcResultExportList :: JSValue -> Result RpcResultExportListSource
saveRpcResultExportList :: RpcResultExportList -> JSValueSource
toDictRpcResultExportList :: RpcResultExportList -> [(String, JSValue)]Source