Page MenuHomePhabricator
Paste P7957

Example for netbox script
ActivePublic

Authored by Volans on Jan 3 2019, 7:22 PM.
@property
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

Event Timeline

Volans created this paste.Jan 3 2019, 7:22 PM