예제 #1
0
def setup_bgp_config(step):
    global bgpconfigarr, bgp_config1, bgp_config2
    step("\n########## Setup of BGP configurations... ##########\n")

    # Create BGP configurations
    bgp_config1 = BgpConfig("1", "8.0.0.1", "9.0.0.0")
    bgp_config2 = BgpConfig("2", "8.0.0.2", "11.0.0.0")

    # Add additional network for the BGPs.
    bgp_config1.add_network("10.0.0.0")

    # Add the neighbors for each BGP config
    bgp_config1.add_neighbor(bgp_config2)
    bgp_config2.add_neighbor(bgp_config1)

    bgpconfigarr = [bgp_config1, bgp_config2]

    # Configure "deny" for "out" of the first network of BGP1
    # neighbor = bgp_config1.neighbors[0]
    network = bgp_config1.networks[0]
    prefixlist = PrefixList("BGP%s_OUT" % bgp_config1.asn, 5, "deny", network,
                            default_pl)

    bgp_config1.prefixlists.append(prefixlist)

    # Configure so that the second route from BGP1 is permitted
    network = bgp_config1.networks[1]
    prefixlist = PrefixList("BGP%s_OUT" % bgp_config1.asn, 10, "permit",
                            network, default_pl)

    bgp_config1.prefixlists.append(prefixlist)

    # Configure neighbor with prefix-list
    addnbrprefixlist("8.0.0.2", "BGP%s_OUT" % (bgp_config1.asn), "out")
예제 #2
0
def setup_bgp_config(step):
    global bgpconfigarr, bgp_config1, bgp_config2, bgp_config3
    step("\n########## Setup of BGP configurations... ##########\n")

    # Create BGP configurations
    bgp_config1 = BgpConfig("1", "9.0.0.1", "15.0.0.0")
    bgp_config2 = BgpConfig("2", "9.0.0.2", "12.0.0.0")
    bgp_config3 = BgpConfig("3", "10.0.0.2", "20.0.0.0")

    # Add the neighbors for each BGP config
    bgp_config1.add_neighbor(bgp_config2)
    bgp_config2.add_neighbor(bgp_config1)

    bgpconfigarr = [bgp_config1, bgp_config2, bgp_config3]
def setup_bgp_config(step):
    global bgp_config1, bgp_config2, bgp_config_arr
    step("\n########## Setup of BGP configurations... ##########\n")

    # Create BGP configurations
    bgp_config1 = BgpConfig("1", "8.0.0.1", "9.0.0.0")
    bgp_config2 = BgpConfig("2", "8.0.0.2", "11.0.0.0")

    # Add additional network for the BGPs.
    bgp_config1.add_network("10.0.0.0")

    # Add the neighbors for each BGP config
    bgp_config1.add_neighbor(bgp_config2)
    bgp_config2.add_neighbor(bgp_config1)

    bgp_config_arr = [bgp_config1, bgp_config2]

    # Configure filter-list entries
    addfilterlist("BGP%s_OUT" % (bgp_config1.asn), "deny",
                  "%s" % (bgp_config2.asn))

    # Configure neighbor with filter-list
    addnbrfilterlist("8.0.0.2", "BGP%s_OUT" % (bgp_config1.asn), "out")
예제 #4
0
# *> 9.0.0.0          8.0.0.1                  0             0 1 i
# *> 10.0.0.0         0.0.0.0                  0         32768 i
# *> 11.0.0.0         0.0.0.0                  0         32768 i

default_pl = "8"
default_netmask = "255.0.0.0"
rm_description = "A route-map description for testing."
extcommunity_rt_str = "2:0"
extcommunity_soo_str = "3:0"
extcommunity_rt_str2 = "4:0"
extcommunity_soo_str2 = "5:0"
ipv6_nexthop_gbl_addr = ipv6_nexthop_local_addr = "2001:db8::0:1"
bgp_configArr = []
all_cfg_array = []
switches = []
bgp_config1 = BgpConfig("1", "8.0.0.1", "9.0.0.0")
bgp_config2 = BgpConfig("2", "8.0.0.2", "10.0.0.0")


def configure_switches(step):
    step("Configuring switch IPs..")
    i = 0
    for switch in switches:
        bgp_cfg = bgp_configArr[i]
        # Configure the IPs between the switches
        switch("configure terminal")
        switch("interface {}".format(switch.ports["if01"]))
        switch("no shutdown")
        switch("ip address {}/{}".format(bgp_cfg.routerid, default_pl))
        switch("exit")
        i += 1