Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## NOC modules
- from noc.lib.app import ExtApplication, view
- from noc.ip.models import *
- from noc.inv.models import *
- class network_infoAppplication(ExtApplication):
- """
- sa.network_info application
- """
- title = "Network Info"
- menu = "Network Info"
- @view(method=["GET"], url=r"^$", access="read", api=True)
- def api_main(self, request):
- req = request.GET
- network = req['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"
- break
- return {
- "network_info": ni,
- "success" : True
- }
Advertisement
Add Comment
Please, Sign In to add comment