Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from noc.lib.app import ExtApplication, view
- from noc.ip.models import *
- from noc.inv.models import *
- def netinfo(network):
- prf=Prefix.objects.get(prefix=network)
- addrs = prf.nested_address_set
- ni = ""
- for a in addrs:
- subs = SubInterface.objects.filter(ipv4_addresses__contains=a.address+'/')
- for s in subs:
- if s.managed_object:
- mo = s.managed_object
- ni += "L3 device: "+mo.name+"\n"
- ni += "L3 interface: "+s.name+"\n"
- arps = mo.scripts.get_arp()
- for arp in arps:
- if s.name == arp['interface']:
- ni += "ARP entry: "+arp['ip']+" "+arp['mac']+"\n"
- needbreak = True
- break
- if needbreak: break
- return ni
- >>> netinfo('212.233.127.48/29')
- u'L3 device: msk-sbl-cr1\nL3 interface: Vl 412\nARP entry: 212.233.127.50 CC:5D:4E:4D:C8:11\n'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement