Module for query operations
How it works:
- Add field definitions
- See how
NODE_FIELDSis built - Each field gets:
- Query field definition (
objects.QueryFieldDefinition, use_MakeFieldfor creating), containing:- Name, must be lowercase and match
FIELD_NAME_RE - Title for tables, must not contain whitespace and match
TITLE_RE - Value data type, e.g.
constants.QFT_NUMBER - Human-readable description, must not end with punctuation or contain newlines
- Name, must be lowercase and match
- Data request type, see e.g. NQ_*
- OR-ed flags, see QFF_*
- A retrieval function, see
Query.__init__for description
- Query field definition (
- Pass list of fields through
_PrepareFieldListfor preparation and checks
- See how
- Instantiate
Querywith prepared field list definition and selected fields - Call
Query.RequestedDatato determine what data to collect/compute - Call
Query.QueryorQuery.OldStyleQuerywith collected data and use result- Data container must support iteration using __iter__
- Items are passed to retrieval functions and can have any format
- Call
Query.GetFieldsto get list of definitions for selected fields
| Unknown Field: attention | |
| Retrieval functions must be idempotent. They can be called multiple times, in any order and any number of times. |
| Class | |
No class docstring; 0/4 instance variable, 1/2 method documented |
| Class | |
Undocumented |
| Class | |
Data container for node group data queries. |
| Class | |
Data container for instance data queries. |
| Class | |
Data container for lock data queries. |
| Class | |
Data container for network data queries. |
| Class | |
Data container for node data queries. |
| Class | |
Undocumented |
| Class | |
No class docstring; 0/5 instance variable, 6/6 methods documented |
| Function | |
Extract objects.QueryFieldDefinition from field definitions. |
| Function | |
Prepares the response for a query. |
| Function | |
Returns list of available fields. |
| Constant | ALL |
Undocumented |
| Constant | ALL |
Undocumented |
| Constant | CLUSTER |
Undocumented |
| Constant | CQ |
Undocumented |
| Constant | CQ |
Undocumented |
| Constant | CQ |
Undocumented |
| Constant | DOC |
Undocumented |
| Constant | EXPORT |
Undocumented |
| Constant | EXTSTORAGE |
Undocumented |
| Constant | FIELD |
Undocumented |
| Constant | FILTER |
Undocumented |
| Constant | GQ |
Undocumented |
| Constant | GQ |
Undocumented |
| Constant | GQ |
Undocumented |
| Constant | GQ |
Undocumented |
| Constant | GROUP |
Undocumented |
| Constant | INSTANCE |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | IQ |
Undocumented |
| Constant | JOB |
Undocumented |
| Constant | JQ |
Undocumented |
| Constant | LOCK |
Undocumented |
| Constant | LQ |
Undocumented |
| Constant | LQ |
Undocumented |
| Constant | LQ |
Undocumented |
| Constant | NETQ |
Undocumented |
| Constant | NETQ |
Undocumented |
| Constant | NETQ |
Undocumented |
| Constant | NETQ |
Undocumented |
| Constant | NETWORK |
Undocumented |
| Constant | NODE |
Undocumented |
| Constant | NQ |
Undocumented |
| Constant | NQ |
Undocumented |
| Constant | NQ |
Undocumented |
| Constant | NQ |
Undocumented |
| Constant | NQ |
Undocumented |
| Constant | OS |
Undocumented |
| Constant | QFF |
Undocumented |
| Constant | QFF |
Undocumented |
| Constant | QFF |
Undocumented |
| Constant | QFF |
Undocumented |
| Constant | QFF |
Undocumented |
| Constant | TITLE |
Undocumented |
| Class | _ |
Converts a query filter to a callable usable for filtering. |
| Class | _ |
Class for filter analytics. |
| Function | _ |
Builds list of fields for cluster information. |
| Function | _ |
Builds list of fields for exports. |
| Function | _ |
Builds list of fields for extstorage provider queries. |
| Function | _ |
Builds list of fields for job filter queries. |
| Function | _ |
Builds list of fields for node group queries. |
| Function | _ |
Builds list of fields for instance queries. |
| Function | _ |
Builds list of fields for job queries. |
| Function | _ |
Builds list of fields for lock queries. |
| Function | _ |
Builds all the ndparam fields. |
| Function | _ |
Builds list of fields for network queries. |
| Function | _ |
Builds list of fields for node queries. |
| Function | _ |
Builds list of fields for operating system queries. |
| Function | _ |
Returns until when watcher is paused (if available). |
| Function | _ |
Converts a query filter into a callable function. |
| Function | _ |
Convenience wrapper for _ConvWrapInner. |
| Function | _ |
Wrapper for converting values. |
| Function | _ |
Generates key for field dictionary. |
| Function | _ |
Undocumented |
| Function | _ |
Returns an export name if available. |
| Function | _ |
Build function for calling another function with an node group. |
| Function | _ |
Get all network bridges for an instance. |
| Function | _ |
Get all network names for an instance. |
| Function | _ |
Get all network VLANs for an instance. |
| Function | _ |
Get console information for instance. |
| Function | _ |
Get instance fields involving disks. |
| Function | _ |
Get instance fields involving network interfaces. |
| Function | _ |
Get instance fields involving parameters. |
| Function | _ |
Get a Device's Name. |
| Function | _ |
Get a Device's UUID. |
| Function | _ |
Build function for calling another function with an instance Disk. |
| Function | _ |
Get a Disk's size. |
| Function | _ |
Get a Disk's spindles. |
| Function | _ |
Get disk usage for an instance. |
| Function | _ |
Build function for retrieving live data. |
| Function | _ |
Build function for calling another function with an instance NIC. |
| Function | _ |
Get a NIC's bridge. |
| Function | _ |
Get a NIC's IP address. |
| Function | _ |
Get a NIC's Network. |
| Function | _ |
Get a NIC's Network. |
| Function | _ |
Build function for retrieving a NIC parameter. |
| Function | _ |
Get a NIC's VLAN. |
| Function | _ |
Gets group UUID of an instance node. |
| Function | _ |
Gets group name of an instance node. |
| Function | _ |
Get instance's operational status. |
| Function | _ |
Get instance status. |
| Function | _ |
Returns a field function to return an attribute of the item. |
| Function | _ |
Returns a field function to return a not-None attribute of the item. |
| Function | _ |
Returns function for getting timestamp of item. |
| Function | _ |
Returns common timestamp fields. |
| Function | _ |
Undocumented |
| Function | _ |
Gets the value of a "live" field from NodeQueryData. |
| Function | _ |
Returns a sorted list of a lock's current owners. |
| Function | _ |
Returns a sorted list of a lock's pending acquires. |
| Function | _ |
Return a field function to return an ND parameter out of the context. |
| Function | _ |
Returns the ndparams for this node. |
| Function | _ |
Gets the value of a "stats" field from NetworkQueryData. |
| Function | _ |
Converts node's disk state for query result. |
| Function | _ |
Returns the name of a node's group. |
| Function | _ |
Converts node's hypervisor state for query result. |
| Function | _ |
Gets node name of a node. |
| Function | _ |
Returns the node powered state |
| Function | _ |
Determine node role. |
| Function | _ |
Calculates the internal list of selected fields. |
| Function | _ |
Gets a value from live statistics. |
| Function | _ |
Gets the contents of an unknown field. |
| Function | _ |
Wrapper for _JobTimestampInner. |
| Function | _ |
Converts unavailable timestamp to _FS_UNAVAIL. |
| Function | _ |
Wrapper for _JobUnavailInner. |
| Function | _ |
Return _FS_UNAVAIL if job is None. |
| Function | _ |
Prepares flag-specific comparisons using a comparison function. |
| Function | _ |
Wrapper for creating objects.QueryFieldDefinition instances. |
| Function | _ |
Compares split timestamp values after converting to float. |
| Function | _ |
Wrapper for _PerJobOpInner. |
| Function | _ |
Executes a function per opcode in a job. |
| Function | _ |
Prepares field list for use by Query. |
| Function | _ |
Compiles a regular expression. |
| Function | _ |
Prepares a value for comparison by _MakeSplitTimestampComparison. |
| Function | _ |
Converts result values into externally-visible ones. |
| Function | _ |
Prepares a function to return a static value. |
| Function | _ |
Returns a static value. |
| Function | _ |
Verifies the contents of a query result row. |
| Function | _ |
Wrapper for binary operator functions. |
| Function | _ |
Wrapper for logic operator functions. |
| Function | _ |
Negates the result of a wrapped function. |
| Function | _ |
Wrapper for unary operator functions. |
| Constant | _CLUSTER |
Undocumented |
| Constant | _CLUSTER |
Undocumented |
| Constant | _FILTER |
Undocumented |
| Constant | _FS |
Undocumented |
| Constant | _FS |
Undocumented |
| Constant | _FS |
Undocumented |
| Constant | _FS |
Undocumented |
| Constant | _FS |
Undocumented |
| Constant | _GROUP |
Undocumented |
| Constant | _INST |
Undocumented |
| Constant | _NETWORK |
Undocumented |
| Constant | _NETWORK |
Undocumented |
| Constant | _NODE |
Undocumented |
| Constant | _NODE |
Undocumented |
| Constant | _SERIAL |
Undocumented |
| Constant | _VERIFY |
Undocumented |
| Variable | _ |
Undocumented |
Extract objects.QueryFieldDefinition from field definitions.
| Returns | |
list of objects.QueryFieldDefinition | Undocumented |
Prepares the response for a query.
| Parameters | |
query:Query | Undocumented |
| ctx | Data container, see Query.Query |
| sort | Whether to sort by name or keep the input data's ordering |
Returns list of available fields.
| Parameters | |
| fielddefs:dict | Field definitions |
| selected:list of strings | List of selected fields |
| Returns | |
List of objects.QueryFieldDefinition | |
Converts a query filter into a callable function.
See _FilterCompilerHelper for details.
| Returns | |
| callable | Undocumented |
Convenience wrapper for _ConvWrapInner.
| Parameters | |
| convert | Conversion function receiving value as single parameter |
| fn | Retrieval function |
Wrapper for converting values.
| Parameters | |
| convert | Conversion function receiving value as single parameter |
| fn | Retrieval function |
| ctx | Undocumented |
| item | Undocumented |
Build function for calling another function with an node group.
| Parameters | |
| cb | The callback to be called with the nodegroup |
Get all network bridges for an instance.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Get all network names for an instance.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Get all network VLANs for an instance.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Get console information for instance.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Get instance fields involving disks.
| Returns | |
List of field definitions used as input for _PrepareFieldList |
Get instance fields involving network interfaces.
| Returns | |
Tuple containing list of field definitions used as input for _PrepareFieldList and a list of aliases |
Get instance fields involving parameters.
| Returns | |
List of field definitions used as input for _PrepareFieldList |
Get a Device's Name.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
device:objects.NIC or objects.Disk | The NIC or Disk object |
Get a Device's UUID.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
device:objects.NIC or objects.Disk | The NIC or Disk object |
Build function for calling another function with an instance Disk.
| Parameters | |
| index:int | Disk index |
| cb:callable | Callback |
Get a Disk's size.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
disk:objects.Disk | The Disk object |
Get disk usage for an instance.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Build function for calling another function with an instance NIC.
| Parameters | |
| index:int | NIC index |
| cb:callable | Callback |
Get a NIC's IP address.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
nic:objects.NIC | NIC object |
Get a NIC's Network.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
nic:objects.NIC | NIC object |
Get a NIC's Network.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| _ | Undocumented |
nic:objects.NIC | NIC object |
Gets group UUID of an instance node.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| default | Default value |
| node | Node UUID |
Gets group name of an instance node.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| default | Default value |
| node | Node UUID |
Get instance's operational status.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Get instance status.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
inst:objects.Instance | Instance object |
Returns a field function to return a not-None attribute of the item.
If the value is None, then _FS_UNAVAIL will be returned instead.
| Parameters | |
| attr | Attribute name |
Returns function for getting timestamp of item.
| Parameters | |
| getter:callable | Function to retrieve timestamp attribute |
Gets the value of a "live" field from NodeQueryData.
| Parameters | |
| field | Live field name |
| kind | Data kind, one of constants.QFT_ALL |
ctx:NodeQueryData | Undocumented |
node:objects.Node | Node object |
Returns the ndparams for this node.
| Parameters | |
ctx:NodeQueryData | Undocumented |
node:objects.Node | Node object |
ng:objects.NodeGroup | The node group this node belongs to |
Gets the value of a "stats" field from NetworkQueryData.
| Parameters | |
| field | Field name |
| kind | Data kind, one of constants.QFT_ALL |
ctx:NetworkQueryData | Undocumented |
| _ | Undocumented |
Returns the name of a node's group.
| Parameters | |
ctx:NodeQueryData | Undocumented |
node:objects.Node | Node object |
ng:objects.NodeGroup | The node group this node belongs to |
Gets node name of a node.
| Parameters | |
ctx:InstanceQueryData | Undocumented |
| default | Default value |
| node | Node UUID |
Calculates the internal list of selected fields.
Unknown fields are returned as constants.QFT_UNKNOWN.
| Parameters | |
| fielddefs:dict | Field definitions |
| selected:list of strings | List of selected fields |
Gets a value from live statistics.
If the value is not found, _FS_UNAVAIL is returned. If the field kind is numeric a conversion to integer is attempted. If that fails, _FS_UNAVAIL is returned.
| Parameters | |
| field | Live field name |
| kind | Data kind, one of constants.QFT_ALL |
| data:dict | Statistics |
Return _FS_UNAVAIL if job is None.
When listing specifc jobs (e.g. "gnt-job list 1 2 3"), a job may not be found, in which case this function converts it to _FS_UNAVAIL.
Wrapper for creating objects.QueryFieldDefinition instances.
| Parameters | |
| name | Field name as a regular expression |
| title | Human-readable title |
| kind | Field type |
| doc | Human-readable description |
Prepares field list for use by Query.
Converts the list to a dictionary and does some verification.
| Parameters | |
fields:list of tuples; (objects.QueryFieldDefinition, data kind, retrieval function) | List of fields, see Query.__init__ for a better description |
| aliases:list of tuples; (alias, target) | list of tuples containing aliases; for each alias/target pair, a duplicate will be created in the field list |
| Returns | |
| dict | Field dictionary for Query |
Verifies the contents of a query result row.
| Parameters | |
| fields:list | Field definitions for result |
| row:list of tuples | Row data |
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|
Undocumented
| Value |
|