ganeti

Safe HaskellSafe-Infered

Ganeti.Query.Common

Contents

Description

Implementation of the Ganeti Query2 common objects.

Synopsis

Documentation

data NoDataRuntime Source

The runtime used by queries which retrieve no live data.

Constructors

NoDataRuntime 

Generic functions

Result helpers

rsNoData :: ResultEntrySource

Helper for a result with no data.

rsUnavail :: ResultEntrySource

Helper for result for an entity which supports no such field.

rsNormal :: JSON a => a -> ResultEntrySource

Helper to declare a normal result.

rsMaybeNoData :: JSON a => Maybe a -> ResultEntrySource

Helper to declare a result from a Maybe (the item might be missing, in which case we return no data). Note that there's some ambiguity here: in some cases, we mean RSNoData, but in other RSUnavail; this is easy to solve in simple cases, but not in nested dicts. If you want to return RSUnavail in case of Nothing use the function rsMaybeUnavail.

rsErrorNoData :: JSON a => ErrorResult a -> ResultEntrySource

Helper to declare a result from a ErrorResult (an error happened while retrieving the data from a config, or there was no data). This function should be used if an error signals there was no data.

rsMaybeUnavail :: JSON a => Maybe a -> ResultEntrySource

Helper to declare a result from a Maybe. This version returns a RSUnavail in case of Nothing. It should be used for optional fields that are not set. For cases where Nothing means that there was an error, consider using rsMaybe instead.

rsErrorMaybeUnavail :: JSON a => ErrorResult (Maybe a) -> ResultEntrySource

Helper to declare a result from 'ErrorResult Maybe'. This version should be used if an error signals there was no data and at the same time when we have optional fields that may not be setted (i.e. we want to return a RSUnavail in case of Nothing).

rsUnknown :: ResultEntrySource

Helper for unknown field result.

missingRuntime :: FieldGetter a bSource

Helper for a missing runtime parameter.

Error conversion

rpcErrorToStatus :: RpcError -> ResultStatusSource

Convert RpcError to ResultStatus

Common fields

timeStampFields :: TimeStampObject a => FieldList a bSource

The list of timestamp fields.

uuidFields :: UuidObject a => String -> FieldList a bSource

The list of UUID fields.

serialFields :: SerialNoObject a => String -> FieldList a bSource

The list of serial number fields.

tagsFields :: TagsObject a => FieldList a bSource

The list of tag fields.

Generic parameter functions

dictFieldGetter :: DictObject a => String -> Maybe a -> ResultEntrySource

Returns a field from a (possibly missing) DictObject. This is used by parameter dictionaries, usually. Note that we have two levels of maybe: the top level dict might be missing, or one key in the dictionary might be.

buildNdParamField :: NdParamObject a => String -> FieldData a bSource

Builds the ndparam fields for an object.

buildBeParamField :: (String -> ConfigData -> a -> ResultEntry) -> String -> FieldData a bSource

Builds the beparam fields for an object.

buildHvParamField :: (String -> ConfigData -> a -> ResultEntry) -> String -> FieldData a bSource

Builds the beparam fields for an object.

buildParamField :: String -> String -> Map String String -> Map String FieldType -> (String -> ConfigData -> a -> ResultEntry) -> String -> FieldData a bSource

getDefaultHypervisorSpec :: ConfigData -> (Hypervisor, HvParams)Source

Looks up the default hypervisor and its hvparams

getHvParamsFromCluster :: ConfigData -> Hypervisor -> HvParamsSource

Looks up the cluster's hvparams of the given hypervisor

aliasFields :: [(FieldName, FieldName)] -> FieldList a b -> FieldList a bSource

Given an alias list and a field list, copies field definitions under a new field name. Aliases should be tested - see the test module Aliases!