Esempio n. 1
0
def build_layer3():
    anm = autonetkit.topos.house()
    from autonetkit.design.osi_layers import build_layer2, build_layer3
    build_layer2(anm)
    build_layer3(anm)

    return anm
Esempio n. 2
0
def apply_design_rules(anm):
    """Applies appropriate design rules to ANM"""
    g_in = anm['input']

    build_phy(anm)
    g_phy = anm['phy']
    from autonetkit.design.osi_layers import (build_layer2,
        build_layer2_broadcast, build_layer3)
    build_layer2(anm)
    build_layer2_broadcast(anm)
    build_layer3(anm)

    build_l3_connectivity(anm)
    check_server_asns(anm)

    from autonetkit.design.mpls import build_vrf
    build_vrf(anm)  # do before to add loopbacks before ip allocations
    from autonetkit.design.ip import build_ip, build_ipv4, build_ipv6
    # TODO: replace this with layer2 overlay topology creation
    build_ip(anm)  # ip infrastructure topology

    address_family = g_in.data.address_family or "v4"  # default is v4
# TODO: can remove the infrastructure now create g_ip seperately
    if address_family == "None":
        log.info("IP addressing disabled, disabling routing protocol ",
                 "configuration")
        anm['phy'].data.enable_routing = False

    if address_family == "None":
        log.info("IP addressing disabled, skipping IPv4")
        anm.add_overlay("ipv4")  # create empty so rest of code follows
        g_phy.update(g_phy, use_ipv4=False)
    elif address_family in ("v4", "dual_stack"):
        build_ipv4(anm, infrastructure=True)
        g_phy.update(g_phy, use_ipv4=True)
    elif address_family == "v6":
        # Allocate v4 loopbacks for router ids
        build_ipv4(anm, infrastructure=False)
        g_phy.update(g_phy, use_ipv4=False)

    # TODO: Create collision domain overlay for ip addressing - l2 overlay?
    if address_family == "None":
        log.info("IP addressing disabled, not allocating IPv6")
        anm.add_overlay("ipv6")  # create empty so rest of code follows
        g_phy.update(g_phy, use_ipv6=False)
    elif address_family in ("v6", "dual_stack"):
        build_ipv6(anm)
        g_phy.update(g_phy, use_ipv6=True)
    else:
        anm.add_overlay("ipv6")  # placeholder for compiler logic

    default_igp = g_in.data.igp or "ospf"
    ank_utils.set_node_default(g_in,  igp=default_igp)

    ank_utils.copy_attr_from(g_in, g_phy, "include_csr")

    try:
        from autonetkit_cisco import build_network as cisco_build_network
    except ImportError, e:
        log.debug("Unable to load autonetkit_cisco %s" % e)
Esempio n. 3
0
def build_layer3():
    anm = house.house()
    from autonetkit.design.osi_layers import build_layer2, build_layer3
    build_layer2(anm)
    build_layer3(anm)


    return anm
Esempio n. 4
0
def test_multi_igp():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True
    g_phy = anm['phy']

    igps = {
        "r1": "ospf",
        "r2": "ospf",
        "r3": "ospf",
        "r4": "isis",
        "r5": "isis"
    }
    for label, igp in igps.items():
        g_phy.node(label).igp = igp

    with patch("autonetkit.design.igp.build_network_entity_title",
               side_effect=net_side_effect):
        autonetkit.design.igp.build_igp(anm)

    g_ospf = anm['ospf']
    g_isis = anm['isis']
    assert (len(g_ospf) == 3)
    assert (len(g_isis) == 2)
    edges = {(e.src, e.dst) for e in g_ospf.edges()}
    expected = {("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected

    edges = {(e.src, e.dst) for e in g_isis.edges()}
    expected = {("r4", "r5")}
    assert edges == expected
Esempio n. 5
0
def test_eigrp():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True

    for node in anm['phy']:
        node.igp = "eigrp"

    autonetkit.design.igp.build_eigrp(anm)

    g_eigrp = anm['eigrp']
    assert(len(g_eigrp) == 5)
    edges = {(e.src, e.dst) for e in g_eigrp.edges()}
    expected = {("r4", "r5"), ("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected
Esempio n. 6
0
def test_eigrp():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True

    for node in anm['phy']:
        node.igp = "eigrp"

    autonetkit.design.igp.build_eigrp(anm)

    g_eigrp = anm['eigrp']
    assert (len(g_eigrp) == 5)
    edges = {(e.src, e.dst) for e in g_eigrp.edges()}
    expected = {("r4", "r5"), ("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected
Esempio n. 7
0
def test_isis():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True

    # isis also needs ipv4 to allocate the OSI addresses

    for node in anm['phy']:
        node.igp = "isis"

#@patch("", side_effect=net_side_effect)
    with patch("autonetkit.design.igp.build_network_entity_title",
        side_effect = net_side_effect):
        autonetkit.design.igp.build_isis(anm)

    g_isis = anm['isis']
    assert(len(g_isis) == 5)
    edges = {(e.src, e.dst) for e in g_isis.edges()}
    expected = {("r4", "r5"), ("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected
Esempio n. 8
0
def test_isis():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True

    # isis also needs ipv4 to allocate the OSI addresses

    for node in anm['phy']:
        node.igp = "isis"


#@patch("", side_effect=net_side_effect)
    with patch("autonetkit.design.igp.build_network_entity_title",
               side_effect=net_side_effect):
        autonetkit.design.igp.build_isis(anm)

    g_isis = anm['isis']
    assert (len(g_isis) == 5)
    edges = {(e.src, e.dst) for e in g_isis.edges()}
    expected = {("r4", "r5"), ("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected
Esempio n. 9
0
def test_multi_igp():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True
    g_phy = anm['phy']

    igps = {"r1": "ospf", "r2": "ospf", "r3": "ospf", "r4": "isis", "r5": "isis"}
    for label, igp in igps.items():
        g_phy.node(label).igp = igp

    with patch("autonetkit.design.igp.build_network_entity_title",
        side_effect = net_side_effect):
        autonetkit.design.igp.build_igp(anm)

    g_ospf = anm['ospf']
    g_isis = anm['isis']
    assert(len(g_ospf) == 3)
    assert(len(g_isis) == 2)
    edges = {(e.src, e.dst) for e in g_ospf.edges()}
    expected = {("r1", "r2"), ("r1", "r3"), ("r2", "r3")}
    assert edges == expected

    edges = {(e.src, e.dst) for e in g_isis.edges()}
    expected = {("r4", "r5")}
    assert edges == expected
Esempio n. 10
0
def test_eigrp_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_eigrp(anm)
Esempio n. 11
0
def test_ospf_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_ospf(anm)
Esempio n. 12
0
def test_isis_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_isis(anm)
Esempio n. 13
0
def test_isis_no_isis_set():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True
    autonetkit.design.igp.build_isis(anm)
Esempio n. 14
0
def test_eigrp_no_isis_set():
    anm = build_layer3()
    anm['phy'].data.enable_routing = True
    autonetkit.design.igp.build_eigrp(anm)
Esempio n. 15
0
def test_eigrp_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_eigrp(anm)
Esempio n. 16
0
def test_ospf_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_ospf(anm)
Esempio n. 17
0
def test_isis_no_routing():
    anm = build_layer3()
    autonetkit.design.igp.build_isis(anm)
Esempio n. 18
0
    try:
        from autonetkit_cisco import build_network as cisco_build_network
    except ImportError, e:
        log.debug("Unable to load autonetkit_cisco %s", e)
    else:
        cisco_build_network.post_phy(anm)

    g_phy = anm['phy']
    from autonetkit.design.osi_layers import build_layer1, build_layer2, build_layer3
    # log.info("Building layer2")
    build_layer1(anm)
    build_layer2(anm)
    # autonetkit.update_http(anm)

    # log.info("Building layer3")
    build_layer3(anm)

    check_server_asns(anm)

    from autonetkit.design.mpls import build_vrf
    build_vrf(anm)  # do before to add loopbacks before ip allocations
    from autonetkit.design.ip import build_ip, build_ipv4, build_ipv6
    # TODO: replace this with layer2 overlay topology creation
    # log.info("Allocating IP addresses")
    build_ip(anm)  # ip infrastructure topology

    address_family = g_in.data.address_family or "v4"  # default is v4
    # TODO: can remove the infrastructure now create g_ip seperately
    if address_family == "None":
        log.info("IP addressing disabled, disabling routing protocol ",
                 "configuration")
Esempio n. 19
0
        from autonetkit_cisco import build_network as cisco_build_network
    except ImportError, e:
        log.debug("Unable to load autonetkit_cisco %s", e)
    else:
        cisco_build_network.post_phy(anm)

    g_phy = anm["phy"]
    from autonetkit.design.osi_layers import build_layer1, build_layer2, build_layer3

    # log.info("Building layer2")
    build_layer1(anm)
    build_layer2(anm)
    # autonetkit.update_http(anm)

    # log.info("Building layer3")
    build_layer3(anm)

    # assign interface ip from pool
    # assign_interface_ip_pool(anm)

    # assign loopback ip from pool
    # assign_loopback_ip_pool(anm)

    check_server_asns(anm)

    from autonetkit.design.mpls import build_vrf

    build_vrf(anm)  # do before to add loopbacks before ip allocations
    from autonetkit.design.ip import build_ip, build_ipv4, build_ipv6

    # TODO: replace this with layer2 overlay topology creation
Esempio n. 20
0
def apply_design_rules(anm):
    """Applies appropriate design rules to ANM"""
    g_in = anm['input']

    build_phy(anm)
    g_phy = anm['phy']
    from autonetkit.design.osi_layers import (build_layer2, check_layer2,
                                              build_layer2_broadcast,
                                              build_layer3)
    build_layer2(anm)
    check_layer2(anm)
    build_layer2_broadcast(anm)
    build_layer3(anm)

    build_l3_connectivity(anm)
    check_server_asns(anm)

    from autonetkit.design.mpls import build_vrf
    build_vrf(anm)  # do before to add loopbacks before ip allocations
    from autonetkit.design.ip import build_ip, build_ipv4, build_ipv6
    # TODO: replace this with layer2 overlay topology creation
    build_ip(anm)  # ip infrastructure topology

    address_family = g_in.data.address_family or "v4"  # default is v4
    # TODO: can remove the infrastructure now create g_ip seperately
    if address_family == "None":
        log.info("IP addressing disabled, disabling routing protocol ",
                 "configuration")
        anm['phy'].data.enable_routing = False

    if address_family == "None":
        log.info("IP addressing disabled, skipping IPv4")
        anm.add_overlay("ipv4")  # create empty so rest of code follows
        g_phy.update(g_phy, use_ipv4=False)
    elif address_family in ("v4", "dual_stack"):
        build_ipv4(anm, infrastructure=True)
        g_phy.update(g_phy, use_ipv4=True)
    elif address_family == "v6":
        # Allocate v4 loopbacks for router ids
        build_ipv4(anm, infrastructure=False)
        g_phy.update(g_phy, use_ipv4=False)

    # TODO: Create collision domain overlay for ip addressing - l2 overlay?
    if address_family == "None":
        log.info("IP addressing disabled, not allocating IPv6")
        anm.add_overlay("ipv6")  # create empty so rest of code follows
        g_phy.update(g_phy, use_ipv6=False)
    elif address_family in ("v6", "dual_stack"):
        build_ipv6(anm)
        g_phy.update(g_phy, use_ipv6=True)
    else:
        anm.add_overlay("ipv6")  # placeholder for compiler logic

    default_igp = g_in.data.igp or "ospf"
    ank_utils.set_node_default(g_in, igp=default_igp)

    ank_utils.copy_attr_from(g_in, g_phy, "include_csr")

    try:
        from autonetkit_cisco import build_network as cisco_build_network
    except ImportError, e:
        log.debug("Unable to load autonetkit_cisco %s" % e)