Пример #1
0
def main():
    '''
    Connect to Juniper device using PyEZ. Display the routing table.
    '''
    pwd = getpass()
    ip_addr = raw_input("Enter Juniper SRX IP: ")
    ip_addr = ip_addr.strip()

    juniper_srx = {
        "host": ip_addr,
        "user": "******",
        "password": pwd
    }

    print "\n\nConnecting to Juniper SRX...\n"
    a_device = Device(**juniper_srx)
    a_device.open()

    routes = RouteTable(a_device)
    routes.get()

    print "\nJuniper SRX Routing Table: "
    for a_route, route_attr in routes.items():
        print "\n" + a_route
        for attr_desc, attr_value in route_attr:
            print "  {} {}".format(attr_desc, attr_value)

    print "\n"
Пример #2
0
def main():

    pwd = getpass()

    juniper = {
        "host": "50.76.53.27",
        "user": "******",
        "password": pwd
    }

    a_device = Device(**juniper)
    a_device.open()

    table = RouteTable(a_device)
    table.get()

    print
    print "Juniper SRX Routing Table"
    print

    for route, rtable in table.items():
        rtable = dict(rtable)
        #print stats
        nexthop = rtable['nexthop']
        age = rtable['age']
        via = rtable['via']
        protocol = rtable['protocol']
        print route
        print " NextHop %s" % (nexthop)
        print " age %s" % (age)
        print " via %s" % (via)
        print " protocol %s" % (protocol)
        print
Пример #3
0
def gather_routes():

    DEV = check_connected()
    ROUTE_TABLE = RouteTable(DEV)
    ROUTE_TABLE.get()
    #print("\n")
    #print("Printing ROUTE TABLE")
    #print("-"*30)
    #pprint(ROUTE_TABLE.items())
    return ROUTE_TABLE.items()
Пример #4
0
def main():
    pwd = getpass()

    srx = {
        "hostname": "srx1.twb-tech.com",
        "host": "184.105.247.76",
        "user": "******",
        "password": pwd
    }

    srx_device = Device(**srx)
    srx_device.open()

    print("\nThe current timeout is {} seconds.".format(srx_device.timeout))
    srx_device.timeout = 120
    print("\nThe updated timeout is {} seconds.".format(srx_device.timeout))

    routes = RouteTable(srx_device)
    routes.get()

    routes_dict = {}

    for item in routes.items():
        route = item[0]
        nexthop = item[1][3][1]
        age = item[1][2][1]
        via = item[1][1][1]
        protocol = item[1][0][1]

        print("\n")
        print("{}\n".format(route))
        print("nexthop:  {}\n".format(nexthop))
        print("age:  {}\n".format(age))
        print("via:  {}\n".format(via))
        print("protocol:  {}\n".format(protocol))
        print("\n")

        routes_dict.update({
            route: {
                "nexthop": nexthop,
                "age": age,
                "via": via,
                "protocol": protocol
            }
        })

    print("\n")
    pprint(routes_dict)

    print("\nJust the intfs ma'am")
    print("*******************")
    pprint(routes)
    print("*******************\n")
Пример #5
0
def main():
    pwd = getpass()

    a_device = Device(host='184.105.247.76', user=USER, password=pwd)
    a_device.open()

    routes = RouteTable(a_device)
    routes.get()

    print

    for k, v in routes.items():
        print k
        for info, stat in v:
            print("{} {}".format(info, stat))
        print

    print
Пример #6
0
def main():

    juniper_srx = {
        "host": "184.105.247.76",
        "user": "******",
        "password": "******"
    }

    print("\n\nConnecting to Juniper SRX...\n")
    a_device = Device(**juniper_srx)
    a_device.open()

    routes = RouteTable(a_device)
    routes.get()

    print("\nJuniper SRX Routing Table: ")
    for a_route, route_attr in routes.items():
        print("\n" + a_route)
        for attr_desc, attr_value in route_attr:
            print("  {} {}".format(attr_desc, attr_value))

    print("\n")
Пример #7
0
def main():
    '''
    Formatting the routing table
    '''
    pwd = getpass()
    try:
        a_device = Device(host='184.105.247.76', user='******', password=pwd)
        a_device.open()
        route_table = RouteTable(a_device)
        route_table.get()
        print "\n"*2
        print "Juniper SRX Routing Table: \n"
        for route, route_att in route_table.items():
            print route
            for desc, value in route_att:
                print ("\t {0} {1}").format(desc, value)
            print "\n"
        print
    except:
        print
        print "Authentication Error"
        print
Пример #8
0
def main():
    '''
    Connect to Juniper device using PyEZ. Display the routing table.
    '''
    pwd = getpass()
    ip_addr = raw_input("Enter Juniper SRX IP: ")
    ip_addr = ip_addr.strip()

    juniper_srx = {"host": ip_addr, "user": "******", "password": pwd}

    print "\n\nConnecting to Juniper SRX...\n"
    a_device = Device(**juniper_srx)
    a_device.open()

    routes = RouteTable(a_device)
    routes.get()

    print "\nJuniper SRX Routing Table: "
    for a_route, route_attr in routes.items():
        print "\n" + a_route
        for attr_desc, attr_value in route_attr:
            print "  {} {}".format(attr_desc, attr_value)

    print "\n"
Пример #9
0
def gather_routes():
    routing_table = RouteTable(connection)
    routing_table.get()
    return dict(routing_table.items())
Пример #10
0
    for entry in v:
        print entry

#### Getter operations
print "\nEth Port Get"
print '-' * 50
eth = EthPortTable(a_device)
eth.get()
pprint(eth.items())

#### Getter operations
print "\nRoute Table Get"
print '-' * 50
z_routes = RouteTable(a_device)
z_routes.get()
pprint(z_routes.items())

#### Config operations
print
print "Current static routes"
print '-' * 50
pprint(z_routes.keys())
print

# Create config object
cfg = Config(a_device)
cfg.lock()

config_str = """
routing-options {
    static {
Пример #11
0
from jnpr.junos import Device
from jnpr.junos.op.routes import RouteTable


a_device = Device(host="184.105.247.76", user='******', password='******')
a_device.open()
a_device.timeout = 120
routes = RouteTable(a_device)
routes.get()



for route, param in routes.items():
    print route
    for k, v in param:
        print k, v
    print ''