Advertisement
Guest User

Untitled

a guest
Apr 1st, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. from noc.lib.app import ExtApplication, view
  2. from noc.ip.models import *
  3. from noc.inv.models import *
  4.  
  5. def netinfo(network):
  6.     prf=Prefix.objects.get(prefix=network)
  7.     addrs = prf.nested_address_set
  8.     ni = ""
  9.     for a in addrs:
  10.         subs = SubInterface.objects.filter(ipv4_addresses__contains=a.address+'/')
  11.         for s in subs:
  12.             if s.managed_object:
  13.                 mo = s.managed_object
  14.                 ni += "L3 device: "+mo.name+"\n"
  15.                 ni += "L3 interface: "+s.name+"\n"
  16.                 arps = mo.scripts.get_arp()
  17.                 for arp in arps:
  18.                     if s.name == arp['interface']:
  19.                         ni += "ARP entry: "+arp['ip']+" "+arp['mac']+"\n"
  20.                 needbreak = True
  21.                 break
  22.         if needbreak: break
  23.     return ni
  24. >>> netinfo('212.233.127.48/29')
  25. 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