devices
Devices module.
- class homer.devices.Device(fqdn, metadata, config, private)
Bases:
tupleCreate new instance of Device(fqdn, metadata, config, private)
-
config:
typing.Mapping Alias for field number 2
-
metadata:
typing.MutableMapping Alias for field number 1
-
private:
typing.Mapping Alias for field number 3
-
config:
- class homer.devices.Devices(devices: Mapping[str, MutableMapping[str, str]], devices_config: Mapping[str, Mapping], private_config: Mapping[str, Mapping] | None = None)[source]
Bases:
UserDictCollection of devices, accessible by FQDN as a dict or role and site via dedicated accessors.
Initialize the instance.
- Parameters:
devices (
typing.Mapping[str,typing.MutableMapping[str,str]]) -- the devices configuration with FQDN as key and a dictionary with the device metadata as value.devices_config (
typing.Mapping[str,typing.Mapping]) -- the devices configuration with FQDN as key and a dictionary with the device-specific configuration as value.private_config (
typing.Optional[typing.Mapping[str,typing.Mapping]], default:None) -- an optional dictionary of the devices private configuration with the FQDN as key and a dictionary of device-specific private configuration as value. It cannot have top level keys in common with the same device public configuration.
- query(query_string: str) List[homer.devices.Device][source]
Get the devices matching the query, supporting comma-separated sub-queries.
This method processes a query string that can include: - Comma-separated sub-queries (e.g., "host*,db*") to match multiple patterns. - Key-value pairs (e.g., "key:value") to filter devices by metadata. - FQDN glob patterns (e.g., "host*") to match device FQDNs.
The results are deduplicated and sorted by FQDN before returning.
- Parameters:
query_string (
str) -- The query string to filter devices. Can include comma-separated sub-queries, key-value pairs, or FQDN glob patterns.- Raises:
homer.exceptions.HomerError -- If the query is invalid or cannot be processed.
- Return type:
- Returns:
A sorted list of unique Device objects matching the query.