Guest User

Untitled

a guest
Mar 31st, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. ## NOC modules
  2. from noc.lib.app import ExtApplication, view
  3. from noc.ip.models import *
  4. from noc.inv.models import *
  5.  
  6.  
  7. class network_infoAppplication(ExtApplication):
  8.     """
  9.    sa.network_info application
  10.    """
  11.     title = "Network Info"
  12.     menu = "Network Info"
  13.  
  14.     @view(method=["GET"], url=r"^$", access="read", api=True)
  15.     def api_main(self, request):
  16.         req = request.GET
  17.         network = req['network']
  18.  
  19.         prf=Prefix.objects.get(prefix=network)
  20.         addrs = prf.nested_address_set
  21.  
  22.         ni = ""
  23.         for a in addrs:
  24.             subs = SubInterface.objects.filter(ipv4_addresses__contains=a.address+'/')
  25.             for s in subs:
  26.                 if s.managed_object:
  27.                     mo = s.managed_object
  28.                     ni += "L3 device: "+mo.name+"\n"
  29.                     ni += "L3 interface: "+s.name+"\n"
  30.                     #arps = mo.scripts.get_arp()
  31.                     #for arp in arps:
  32.                     #    if s.name == arp['interface']:
  33.                     #        ni += "ARP entry: "+arp['ip']+" "+arp['mac']+"\n"
  34.  
  35.                     break
  36.  
  37.         return {
  38.             "network_info": ni,
  39.             "success" : True
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment