netbox

Netbox module.

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

Bases: collections.UserDict

Base class to gather data dynamically from Netbox.

Initialize the dictionary.

Parameters

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

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

Bases: homer.netbox.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: pynetbox.api.Api, device: homer.devices.Device)[source]

Bases: homer.netbox.BaseNetboxData

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(api: pynetbox.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.api) -- the Netbox API instance.

  • 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 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