netbox

Netbox module.

class homer.netbox.BaseNetboxData(api: Api)[source]

Bases: UserDict

Base class to gather data dynamically from Netbox.

Initialize the dictionary.

Parameters:

api (pynetbox.api) -- the Netbox API instance.

class homer.netbox.BaseNetboxDeviceData(api: Api, device: Device)[source]

Bases: BaseNetboxData

Base class to gather device-specific data dynamically from Netbox.

Initialize the dictionary.

Parameters:
  • api (pynetbox.api) -- the Netbox API instance.

  • device (homer.devices.Device) -- the device for which to gather the data.

class homer.netbox.NetboxData(api: Api)[source]

Bases: BaseNetboxData

Dynamic dictionary to gather the required generic data from Netbox.

Initialize the dictionary.

Parameters:

api (pynetbox.api) -- the Netbox API instance.

class homer.netbox.NetboxDeviceData(api: Api, device: Device)[source]

Bases: BaseNetboxDeviceData

Dynamic dictionary to gather the required device-specific data from Netbox.

Initialize the dictionary.

Parameters:
  • api (pynetbox.api) -- the Netbox API instance.

  • device (homer.devices.Device) -- the device for which to gather the data.

class homer.netbox.NetboxInventory(config: dict, 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:
  • config (dict) -- Homer's configuration section about Netbox

  • device_roles (list) -- a sequence of Netbox device role slug strings to filter the devices.

  • device_statuses (list) -- a sequence of Netbox device status label or value strings to filter the devices.

get_devices() Dict[str, Dict[str, str]][source]

Return all the devices based on configuration with their role and site.

Returns:

a dictionary with the device FQDN as keys and a metadata dictionary as value.

Return type:

dict