Paste P7957

Example for netbox script

Authored by Volans on Thu, Jan 3, 7:22 PM.
def interfaces(self):
if self._interfaces: # those are the formatted ones
return self._interfaces
if not self._device_interfaces: # to cache them
with self.connect():
self._device_interfaces = self.device.get_interfaces()
interfaces = {}
# all the code for mangling the interfaces calling self.optics, etc...
# if this is getting too large it can be moved to something like
# def _get_formatted_interfaces(self)
self._interfaces = interfaces # or self._get_formatted_interfaces()
return self._interfaces
Volans created this paste.Thu, Jan 3, 7:22 PM