Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for m in r:
- mo = m['mo']
- commands = m['config'].split('\n')
- task = ReduceTask.create_task(object_selector=mo,
- map_script="commands", map_script_params={"commands":commands},
- reduce_script="pyrule:mrt_result", reduce_script_params={},
- timeout=180)
- sleep(7)
- ############### "WHILE" DO NOT WORK. WHY??? #####
- # while not task.complete:
- # sleep(0.1)
- ##################################################
- if "BVI" in m:
- fqdn_gw=m['mo'].name + "-" + bvi + ".kis.ru"
- Address(address=ip_gw, fqdn=fqdn_gw, vrf = GlobalVRF, project = project).save()
- iface = Interface(managed_object=mo, type="SVI", name=bvi, project = project, description = description)
- siface = SubInterface(managed_object=mo, interface=iface, name=bvi, enabled_afi=["IPv4"], project = project, description = description, ipv4_addresses = [ip_gw + '/30'])
- iface.save()
- siface.save()
- if "subif" in m:
- SubInterface(managed_object=mo.id, interface=m['interface'], name=m['subif'], project = project, description = description).save()
- ## Send config via jabber. TODO import xmpp in virtualenv
- if len(jids)>0:
- msg = m['config']
- # for to in jids:
- # jid = xmpp.protocol.JID(xmpp_jid)
- # client = xmpp.Client(jid.getDomain(),debug=[])
- # client.connect()
- # client.auth(jid.getNode(),str(xmpp_pwd),resource='xmpppy')
- # client.send(xmpp.protocol.Message(to,msg))
- # client.disconnect()
- result += m['mo'].name + "\n\n" + m['config'] + "\n\n\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement