ganeti
Safe HaskellNone

Ganeti.Query.Query

Description

Implementation of the Ganeti Query2 functionality.

Synopsis

Documentation

data CollectorType a b Source #

Collector type

Constructors

CollectorSimple (Bool -> ConfigData -> [a] -> IO [(a, b)]) 
CollectorFieldAware (Bool -> ConfigData -> [String] -> [a] -> IO [(a, b)]) 

Helper functions

mkUnknownFDef :: String -> FieldData a b Source #

Builds an unknown field definition.

execGetter :: ConfigData -> b -> a -> FieldGetter a b -> ResultEntry Source #

Runs a field getter on the existing contexts.

Main query execution

getSelectedFields Source #

Arguments

:: FieldMap a b

Defined fields

-> [String]

Requested fields

-> FieldList a b

Selected fields

Helper to build the list of requested fields. This transforms the list of string fields to a list of field defs and getters, with some of them possibly being unknown fields.

needsLiveData :: [FieldGetter a b] -> Bool Source #

Check whether list of queried fields contains live fields.

needsNames :: Query -> Maybe [FilterValue] Source #

Checks whether we have requested exactly some names. This is a simple wrapper over requestedNames and nameField.

nameField :: ItemType -> FilterField Source #

Computes the name field for different query types.

uuidField :: ItemType -> FilterField Source #

Computes the uuid field, or the best possible substitute, for different query types.

getAllQuotedStrings :: [FilterValue] -> [String] Source #

Extracts all quoted strings from a list, ignoring the NumericValue entries.

getRequestedNames :: Query -> [String] Source #

Checks that we have either requested a valid set of names, or we have a more complex filter.

getRequestedJobIDs :: Filter FilterField -> Result [JobId] Source #

Compute the requested job IDs. This is custom since we need to handle both strings and integers.

genericQuery Source #

Arguments

:: FieldMap a b

Maps field names to field definitions

-> CollectorType a b

Collector of live data

-> (a -> String)

Object to name function

-> (ConfigData -> Container a)

Get all objects from config

-> (ConfigData -> String -> ErrorResult a)

Lookup object

-> ConfigData

The config to run the query against

-> Bool

Whether the query should be run live

-> [String]

List of requested fields

-> Filter FilterField

Filter field

-> [String]

List of requested names

-> IO (ErrorResult QueryResult) 

Generic query implementation for resources that are backed by some configuration objects.

Different query types use the same genericQuery function by providing a collector function and a field map. The collector function retrieves live data, and the field map provides both the requirements and the logic necessary to retrieve the data needed for the field.

The b type in the specification is the runtime. Every query can gather additional live data related to the configuration object using the collector to perform RPC calls.

The gathered data, or the failure to get it, is expressed through a runtime object. The type of a runtime object is determined by every query type for itself, and used exclusively by that query.

recollectLocksData :: ([(GanetiLocks, [(ClientId, OwnerState)])], [(Integer, ClientId, [LockRequest GanetiLocks])]) -> Bool -> ConfigData -> [String] -> IO [(String, RuntimeData)] Source #

Dummy recollection of the data for a lock from the prefected data for all locks.

query Source #

Arguments

:: ConfigData

The current configuration

-> Bool

Whether to collect live data

-> Query

The query (item, fields, filter)

-> IO (ErrorResult QueryResult)

Result

Main query execution function.

dummyCollectLiveData :: Bool -> ConfigData -> [a] -> IO [(a, NoDataRuntime)] Source #

Dummy data collection fuction

queryInner Source #

Arguments

:: ConfigData

The current configuration

-> Bool

Whether to collect live data

-> Query

The query (item, fields, filter)

-> [String]

Requested names

-> IO (ErrorResult QueryResult)

Result

Inner query execution function.

queryJobs Source #

Arguments

:: ConfigData

The current configuration

-> Bool

Whether to collect live data

-> [FilterField]

Item

-> Filter FilterField

Filter

-> IO (ErrorResult QueryResult)

Result

Query jobs specific query function, needed as we need to accept both QuotedString and NumericValue as wanted names.

queryCompat :: QueryResult -> ErrorResult [[JSValue]] Source #

Classic query converter. It gets a standard query result on input and computes the classic style results.