Advertisement
Guest User

Untitled

a guest
Aug 5th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. for m in r:
  2. mo = m['mo']
  3. commands = m['config'].split('\n')
  4. task = ReduceTask.create_task(object_selector=mo,
  5. map_script="commands", map_script_params={"commands":commands},
  6. reduce_script="pyrule:mrt_result", reduce_script_params={},
  7. timeout=180)
  8. sleep(7)
  9. ############### "WHILE" DO NOT WORK. WHY??? #####
  10. # while not task.complete:
  11. # sleep(0.1)
  12. ##################################################
  13.  
  14. if "BVI" in m:
  15. fqdn_gw=m['mo'].name + "-" + bvi + ".kis.ru"
  16. Address(address=ip_gw, fqdn=fqdn_gw, vrf = GlobalVRF, project = project).save()
  17. iface = Interface(managed_object=mo, type="SVI", name=bvi, project = project, description = description)
  18. siface = SubInterface(managed_object=mo, interface=iface, name=bvi, enabled_afi=["IPv4"], project = project, description = description, ipv4_addresses = [ip_gw + '/30'])
  19. iface.save()
  20. siface.save()
  21. if "subif" in m:
  22. SubInterface(managed_object=mo.id, interface=m['interface'], name=m['subif'], project = project, description = description).save()
  23.  
  24. ## Send config via jabber. TODO import xmpp in virtualenv
  25. if len(jids)>0:
  26. msg = m['config']
  27. # for to in jids:
  28. # jid = xmpp.protocol.JID(xmpp_jid)
  29. # client = xmpp.Client(jid.getDomain(),debug=[])
  30. # client.connect()
  31. # client.auth(jid.getNode(),str(xmpp_pwd),resource='xmpppy')
  32. # client.send(xmpp.protocol.Message(to,msg))
  33. # client.disconnect()
  34. result += m['mo'].name + "\n\n" + m['config'] + "\n\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement