Exemple #1
0
def initialise(input_graph):
    """Initialises the input graph with from a NetworkX graph"""
    all_multigraph = input_graph.is_multigraph()
    anm = autonetkit.anm.NetworkModel(all_multigraph=all_multigraph)

    g_in = anm.initialise_input(input_graph)
    if g_in.data.igp:
        if g_in.data.profiles:
            node_profiles = g_in.data["profiles"]
            for node in g_in:
                for prof in node_profiles:
                    if node.profile == prof["id"]:
                        if "configs" in prof and "igp" in prof["configs"]:
                            if (
                                "enabled" in prof["configs"]["igp"]
                                and prof["configs"]["igp"]["enabled"] == 1
                                and prof["configs"]["igp"]["igp_prot"]
                            ):
                                node.igp = prof["configs"]["igp"]["igp_prot"]
    else:
        g_in.data.igp = None

    if g_in.data.vxlan_global_config:
        # sharad: right now enable multicast on all nodes by default
        if "multicast" in g_in.data.vxlan_global_config:
            for node in g_in:
                node.multicast = g_in.data.vxlan_global_config["multicast"]

    # autonetkit.update_vis(anm)

    # set defaults
    if not g_in.data.specified_int_names:
        # if not specified then automatically assign interface names
        g_in.data.specified_int_names = False

    # import autonetkit.plugins.graph_product as graph_product
    # graph_product.expand(g_in)  # apply graph products if relevant

    expand_fqdn = False
    # TODO: make this set from config and also in the input file
    if expand_fqdn and len(ank_utils.unique_attr(g_in, "asn")) > 1:
        # Multiple ASNs set, use label format device.asn
        anm.set_node_label(".", ["label", "asn"])

    g_in.update(g_in.routers(platform="junosphere"), syntax="junos")
    if autonetkit.config.settings["Graphml"]["Node Defaults"]["syntax"] == "ios":
        g_in.update(g_in.routers(platform="dynagen"), syntax="ios")
    elif autonetkit.config.settings["Graphml"]["Node Defaults"]["syntax"] == "nx_os":
        g_in.update(g_in.routers(platform="dynagen"), syntax="nx_os")
    g_in.update(g_in.routers(platform="netkit"), syntax="quagga")
    # TODO: is this used?
    g_in.update(g_in.servers(platform="netkit"), syntax="quagga")

    # TODO: check this is needed
    # autonetkit.ank.set_node_default(g_in, specified_int_names=None)

    g_graphics = anm.add_overlay("graphics")  # plotting data
    g_graphics.add_nodes_from(g_in, retain=["x", "y", "device_type", "label", "device_subtype", "asn"])

    return anm
Exemple #2
0
def initialise(input_graph):
    """Initialises the input graph with from a NetworkX graph"""
    all_multigraph = input_graph.is_multigraph()
    anm = autonetkit.anm.NetworkModel(all_multigraph=all_multigraph)

    g_in = anm.initialise_input(input_graph)
    # autonetkit.update_vis(anm)

# set defaults
    if not g_in.data.specified_int_names:
        # if not specified then automatically assign interface names
        g_in.data.specified_int_names = False

    #import autonetkit.plugins.graph_product as graph_product
    # graph_product.expand(g_in)  # apply graph products if relevant

    expand_fqdn = False
    # TODO: make this set from config and also in the input file
    if expand_fqdn and len(ank_utils.unique_attr(g_in, "asn")) > 1:
        # Multiple ASNs set, use label format device.asn
        anm.set_node_label(".", ['label', 'asn'])

    g_in.update(g_in.routers(platform="junosphere"), syntax="junos")
    g_in.update(g_in.routers(platform="dynagen"), syntax="ios")
    g_in.update(g_in.routers(platform="netkit"), syntax="quagga")
    # TODO: is this used?
    g_in.update(g_in.servers(platform="netkit"), syntax="quagga")

    autonetkit.ank.set_node_default(g_in, specified_int_names=None)

    g_graphics = anm.add_overlay("graphics")  # plotting data
    g_graphics.add_nodes_from(g_in, retain=['x', 'y', 'device_type',
                                            'label', 'device_subtype', 'asn'])

    return anm
Exemple #3
0
def initialise(input_graph):
    """Initialises the input graph with from a NetworkX graph"""
    all_multigraph = input_graph.is_multigraph()
    anm = autonetkit.anm.NetworkModel(all_multigraph=all_multigraph)

    g_in = anm.initialise_input(input_graph)
    if g_in.data.igp:
        if g_in.data.profiles:
            node_profiles = g_in.data['profiles']
            for node in g_in:
                for prof in node_profiles:
                    if node.profile == prof['id']:
                        if 'configs' in prof and 'igp' in prof['configs']:
                            if ('enabled' in prof['configs']['igp'] and prof['configs']['igp']['enabled'] == 1 and
                                prof['configs']['igp']['igp_prot']):
                                node.igp = prof['configs']['igp']['igp_prot']
    else:
        g_in.data.igp = None

    if g_in.data.vxlan_global_config:
        #sharad: right now enable multicast on all nodes by default
        if 'multicast' in g_in.data.vxlan_global_config:
            for node in g_in:
                node.multicast = g_in.data.vxlan_global_config['multicast']

    # autonetkit.update_vis(anm)

# set defaults
    if not g_in.data.specified_int_names:
        # if not specified then automatically assign interface names
        g_in.data.specified_int_names = False

    #import autonetkit.plugins.graph_product as graph_product
    # graph_product.expand(g_in)  # apply graph products if relevant

    expand_fqdn = False
    # TODO: make this set from config and also in the input file
    if expand_fqdn and len(ank_utils.unique_attr(g_in, "asn")) > 1:
        # Multiple ASNs set, use label format device.asn
        anm.set_node_label(".", ['label', 'asn'])

    g_in.update(g_in.routers(platform="junosphere"), syntax="junos")
    if autonetkit.config.settings['Graphml']['Node Defaults']['syntax'] == 'ios':
        g_in.update(g_in.routers(platform="dynagen"), syntax="ios")
    elif autonetkit.config.settings['Graphml']['Node Defaults']['syntax'] == 'nx_os':
        g_in.update(g_in.routers(platform="dynagen"), syntax="nx_os")
    g_in.update(g_in.routers(platform="netkit"), syntax="quagga")
    # TODO: is this used?
    g_in.update(g_in.servers(platform="netkit"), syntax="quagga")

    #TODO: check this is needed
    #autonetkit.ank.set_node_default(g_in, specified_int_names=None)

    g_graphics = anm.add_overlay("graphics")  # plotting data
    g_graphics.add_nodes_from(g_in, retain=['x', 'y', 'device_type',
                                            'label', 'device_subtype', 'asn'])

    return anm
Exemple #4
0
def initialise(input_graph):
    """Initialises the input graph with from a NetworkX graph"""
    all_multigraph = input_graph.is_multigraph()
    anm = autonetkit.anm.NetworkModel(all_multigraph=all_multigraph)

    g_in = anm.initialise_input(input_graph)
    autonetkit.update_vis(anm)

    # set defaults
    if not g_in.data.specified_int_names:
        # if not specified then automatically assign interface names
        g_in.data.specified_int_names = False

    #import autonetkit.plugins.graph_product as graph_product
    # graph_product.expand(g_in)  # apply graph products if relevant

    expand_fqdn = False
    # TODO: make this set from config and also in the input file
    if expand_fqdn and len(ank_utils.unique_attr(g_in, "asn")) > 1:
        # Multiple ASNs set, use label format device.asn
        anm.set_node_label(".", ['label', 'asn'])

    g_in.update(g_in.routers(platform="junosphere"), syntax="junos")
    g_in.update(g_in.routers(platform="dynagen"), syntax="ios")
    g_in.update(g_in.routers(platform="netkit"), syntax="quagga")
    # TODO: is this used?
    g_in.update(g_in.servers(platform="netkit"), syntax="quagga")

    autonetkit.ank.set_node_default(g_in, specified_int_names=None)

    g_graphics = anm.add_overlay("graphics")  # plotting data
    g_graphics.add_nodes_from(
        g_in,
        retain=['x', 'y', 'device_type', 'label', 'device_subtype', 'asn'])

    if g_in.data.Creator == "VIRL":
        # TODO: move this to other module
        # Multiple ASNs set, use label format device.asn
        #anm.set_node_label(".", ['label_full'])
        pass

    return anm