Esempio n. 1
0
def build_network(input_filename):
    anm = AbstractNetworkModel()
    input_graph = ank.load_graphml(input_filename)

    G_in = anm.add_overlay("input", input_graph)
    ank.set_node_default(G_in, G_in, platform="netkit")
    ank.set_node_default(G_in, G_in, host="nectar1")

    if len(ank.unique_attr(G_in, "asn")) > 1:
        # Multiple ASNs set, use label format device.asn
        anm.set_node_label(".as", ['label', 'asn'])


# set syntax for routers according to platform
    G_in.update(G_in.nodes("is_router", platform="junosphere"), syntax="junos")
    G_in.update(G_in.nodes("is_router", platform="dynagen"), syntax="ios")
    G_in.update(G_in.nodes("is_router", platform="netkit"), syntax="quagga")

    G_graphics = anm.add_overlay("graphics")  # plotting data
    G_graphics.add_nodes_from(G_in, retain=['x', 'y', 'device_type', 'asn'])

    build_phy(anm)
    build_ip(anm)
    build_ospf(anm)
    build_bgp(anm)

    return anm