Skip to content

Instantly share code, notes, and snippets.

@amulheirn
Last active February 1, 2019 02:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amulheirn/47d7f2545992a38ca9687e84cc7c8eb8 to your computer and use it in GitHub Desktop.
Save amulheirn/47d7f2545992a38ca9687e84cc7c8eb8 to your computer and use it in GitHub Desktop.
Python script to create 8,000 policies in Junos for use in VRFs
__author__ = 'amulheirn'
# Create 8,000 export policies for use on 8,000 VRFs in Junos
# Used for type-approval-testing of customer MX960
interface = '0/0/0' # Local source interface
startvrf = 1 # Start of the vrf range
endvrf = 8001 # End of the vrf range
for i in range (startvrf, endvrf):
print "set policy-options policy-statement VRF-%s-redistribute-bgp term export-direct from protocol direct" % i
print "set policy-options policy-statement VRF-%s-redistribute-bgp term export-direct from policy IMS-VOICE-VPN-LP" % i
print "set policy-options policy-statement VRF-%s-redistribute-bgp term export-direct then accept" % i
print "set policy-options policy-statement VRF-%s-redistribute-bgp term reject-others then reject" % i
print "set policy-options policy-statement VRF-%s-export-to-PEs term add-communities then community add VRF-%s-%s" % (i, i, i)
print "set policy-options policy-statement VRF-%s-export-to-PEs term redist-to-bgp from policy VRF-%s-redistribute-bgp" % (i, i)
print "set policy-options policy-statement VRF-%s-export-to-PEs term redist-to-bgp then accept" % i
print "set policy-options policy-statement VRF-%s-export-to-PEs term reject-others then reject" % i
print "======[END]====="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment