16 lines
514 B
Python
16 lines
514 B
Python
|
#!/usr/bin/python
|
||
|
|
||
|
class FilterModule(object):
|
||
|
'''Various utilities for manipulating NetBox data'''
|
||
|
def filters(self):
|
||
|
return {
|
||
|
'device_address': self.device_address
|
||
|
}
|
||
|
|
||
|
def device_address(self, device):
|
||
|
'''Return loopback IP addresses for an L3 attached device'''
|
||
|
for iface in device['interfaces']:
|
||
|
for addr in iface['ip_addresses']:
|
||
|
if addr.get('role') and addr['role'].get('value') == 'loopback':
|
||
|
yield addr
|