Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. {% load python %}
  2. {% var cmd internal %}
  3. {% python %}
  4.  
  5. from noc.inv.models import *
  6. from noc.sa.models import *
  7. from noc.ip.models import *
  8. from noc.vc.models import *
  9. from noc.lib.ip import IP
  10. from noc.lib.text import split_alnum
  11.  
  12. interface = Interface.objects.filter(managed_object=context["object"].id, type="physical")
  13.  
  14. context["cmd"]="\n"
  15. for i in interface:
  16. #   if i.lag:
  17. #       context["cmd"]+="interface " + str(i.name) + "\n"
  18. #       context["cmd"]+="description " + str(i.lag) + "\n"
  19. #   elif "uplink port" in str(i.profile):
  20.     if "uplink port" in str(i.profile) or "routed port" in str(i.profile):
  21.             if i.link:
  22.                 nei_link = str(i.link)
  23.                 nei_obj = str(context["object"].name) + ':' + ' ' + i.name + ','
  24.                 if nei_obj in nei_link:
  25.                     nei_link = str(i.link).split(',')[1].split(')')[0]
  26.                 else:
  27.                     nei_link = str(i.link).split(',')[0].split('(')[1]
  28.                 context["cmd"]+="interface " + str(i.name) + "\n"
  29.                 nei_link = nei_link.replace(': ','--')
  30.                 nei_link = nei_link.replace('.net.billing.ru','')
  31.                 context["cmd"]+="description " + nei_link + "\n"
  32. #   elif "default" in str(i.profile):
  33.     elif "mng" in str(i.profile):
  34.         context["cmd"]+="interface " + str(i.name) + "\n"
  35.         context["cmd"]+="description " + "MNG" + "\n"              
  36. {% endpython %}
  37. {{cmd}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement