Package ganeti :: Module query :: Class Query
[hide private]
[frames] | no frames]

Class Query

source code

Instance Methods [hide private]
 
__init__(self, fieldlist, selected, filter_=None, namefield=None)
Initializes this class.
source code
 
RequestedNames(self)
Returns all names referenced in the filter.
source code
frozenset
RequestedData(self)
Gets requested kinds of data.
source code
List of objects.QueryFieldDefinition
GetFields(self)
Returns the list of fields for this query.
source code
 
Query(self, ctx, sort_by_name=True)
Execute a query.
source code
 
OldStyleQuery(self, ctx, sort_by_name=True)
Query with "old" query result format.
source code
Method Details [hide private]

__init__(self, fieldlist, selected, filter_=None, namefield=None)
(Constructor)

source code 

Initializes this class.

The field definition is a dictionary with the field's name as a key and a tuple containing, in order, the field definition object (objects.QueryFieldDefinition, the data kind to help calling code collect data and a retrieval function. The retrieval function is called with two parameters, in order, the data container and the item in container (see Query.Query).

Users of this class can call RequestedData before preparing the data container to determine what data is needed.

Parameters:
  • fieldlist (dictionary) - Field definitions
  • selected (list of strings) - List of selected fields

RequestedNames(self)

source code 

Returns all names referenced in the filter.

If there is no filter or operators are preventing determining the exact names, None is returned.

GetFields(self)

source code 

Returns the list of fields for this query.

Includes unknown fields.

Returns: List of objects.QueryFieldDefinition

Query(self, ctx, sort_by_name=True)

source code 

Execute a query.

Parameters:
  • ctx - Data container passed to field retrieval functions, must support iteration using __iter__
  • sort_by_name (boolean) - Whether to sort by name or keep the input data's ordering

OldStyleQuery(self, ctx, sort_by_name=True)

source code 

Query with "old" query result format.

See Query.Query for arguments.