devices

Devices module.

class homer.devices.Device(fqdn, role, site, config, private)

Bases: tuple

Create new instance of Device(fqdn, role, site, config, private)

property config

Alias for field number 3

property fqdn

Alias for field number 0

property private

Alias for field number 4

property role

Alias for field number 1

property site

Alias for field number 2

class homer.devices.Devices(devices: Dict[str, Dict[Any, Any]], private_config: Dict[str, Any])[source]

Bases: collections.UserDict

Collection of devices, accessible by FQDN as a dict or role and site via dedicated accessors.

Initialize the instance.

Parameters
  • devices (dict) -- the devices configuration with FQDN as key and a dictionary with role, site and device-specific configuration as value.

  • private_config (dict, optional) -- an optional devices private configuration with FQDN as key and a dictionary of device-specific 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.

Todo

If needed, expand the query capabilities with a proper syntax using pyparsing.

Parameters

query_string (str) -- the query_string to use to filter for.

Raises

homer.exceptions.HomerError -- on invalid query.

Returns

a list of Device objects.

Return type

list

role(name: str) → List[homer.devices.Device][source]

Get all the devices with a specific role.

Parameters

name (str) -- the role name to filter for.

Returns

a list of Device objects.

Return type

list

site(name: str) → List[homer.devices.Device][source]

Get all the devices within a specific site.

Parameters

name (str) -- the site name to filter for.

Returns

a list of Device objects.

Return type

list