Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/circui15/public_html/packetpros.com/index.php:4) in /home/circui15/public_html/packetpros.com/wp-content/plugins/wp-file-upload/wordpress_file_upload.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/circui15/public_html/packetpros.com/index.php:4) in /home/circui15/public_html/packetpros.com/wp-content/plugins/wp-file-upload/wordpress_file_upload.php on line 2
BGP commands with Python

Hopefully the title of this post didn’t get too excited…We’re not building python scripts to make BGP changes….yet. Nope, this one is to help with BGP commands when you are running VRF’s. It will prompt you for the neighbor IP and if you use a VRF or not. Based on your answers, it will output the BGP commands you need for troubleshooting.

# !/usr/bin/python

print "---------------------------------------------------------"
print "The point of this script is to help create show commands"
print "and assist in troubleshooting. There are no validation"
print "tests! Simply follow the prompts. Good luck!"
print "---------------------------------------------------------"
print " "

neighbor_ip = raw_input("Enter IP address of the BGP neighbor: ")
vrf_question = raw_input("Is the device using VRF's? [Y/N] ")
if vrf_question.lower() == 'y':
        vrf_name = raw_input("Enter the VRF name: ")
        print " "
        print " "
        print('== Advertised Routes ==')
        print "show ip bgp vpnv4 vrf", vrf_name, 'neighbor', neighbor_ip, "advertised-routes"
        print " "
        print('== Received Routes ==')
        print "show ip bgp vpnv4 vrf", vrf_name, "neighbor", neighbor_ip, "received-routes"
        print " "
        print("== Show BGP Neighbors ==")
        print "show ip bgp vpnv4 all summary"
        print " "
        print " "
        quit()
elif vrf_question.lower()  == 'n':
        print " "
        print("== Advertised Routes ==")
        print "show ip bgp vpnv4", "neighbor", neighbor_ip, "advertised-routes"
        print " "
        print( "== Received Routes ==")
        print "show ip bgp vpnv4", "neighbor", neighbor_ip, "received-routes"
        print " "
        print( "== Show BGP Neighbors ==")
        print "show ip bgp vpnv4 all summary"
        print " "
        print " "
        quit()
else:
        print " "
        print("I was expecting a y(es) or n(o) answer and not",vrf_question,"! I'm out...")
        quit()