netbox
Netbox module.
- class homer.netbox.BaseNetboxData(api: pynetbox.core.api.Api, base_paths: dict[str, str])[source]
Bases:
UserDict
Base class to gather data dynamically from Netbox.
Initialize the dictionary.
- class homer.netbox.BaseNetboxDeviceData(api: pynetbox.core.api.Api, base_paths: dict[str, str], device: homer.devices.Device)[source]
Bases:
BaseNetboxData
Base class to gather device-specific data dynamically from Netbox.
Initialize the dictionary.
- Parameters:
api (
pynetbox.core.api.Api
) -- the Netbox API instance.base_paths (
dict
[str
,str
]) -- The path to the public and private directories.device (
homer.devices.Device
) -- the device for which to gather the data.
- class homer.netbox.NetboxData(api: pynetbox.core.api.Api, base_paths: dict[str, str])[source]
Bases:
BaseNetboxData
Dynamic dictionary to gather the required generic data from Netbox.
Initialize the dictionary.
- class homer.netbox.NetboxDeviceData(api: pynetbox.core.api.Api, base_paths: dict[str, str], device: homer.devices.Device)[source]
Bases:
BaseNetboxDeviceData
Dynamic dictionary to gather the required device-specific data from Netbox.
Initialize the dictionary.
- Parameters:
api (
pynetbox.core.api.Api
) -- the Netbox API instance.base_paths (
dict
[str
,str
]) -- The path to the public and private directories.device (
homer.devices.Device
) -- the device for which to gather the data.
- class homer.netbox.NetboxInventory(api: pynetbox.core.api.Api, device_roles: Sequence[str], device_statuses: Sequence[str])[source]
Bases:
object
Use Netbox as inventory to gather the list of devices to manage.
Initialize the instance.
- Parameters:
api (
pynetbox.core.api.Api
) -- the Netbox API instance.config -- Homer's configuration section about Netbox
device_roles (
typing.Sequence
[str
]) -- a sequence of Netbox device role slug strings to filter the devices.device_statuses (
typing.Sequence
[str
]) -- a sequence of Netbox device status label or value strings to filter the devices.
- homer.netbox.gql_execute(api: pynetbox.core.api.Api, query: str, variables: dict | None = None) dict[str, Any] [source]
Parse the query into a gql query, execute and return the results.
- Parameters:
api (
pynetbox.core.api.Api
) -- the Netbox API instance.query (
str
) -- a string representing the gql query.variables (
typing.Optional
[dict
], default:None
) -- A list of variables to send.
- Raises:
homer.exceptions.HomerError -- if failed to query Netbox or no data was returned.
- Return type:
- Results:
The results of the query.