def create_nidb(anm):
    nidb = NIDB()
    g_phy = anm['phy']
    g_ip = anm['ip']
    g_graphics = anm['graphics']
# TODO: build this on a platform by platform basis
    nidb.add_nodes_from(
        g_phy, retain=['label', 'host', 'platform', 'Network', 'update'])

    cd_nodes = [n for n in g_ip.nodes(
        "collision_domain") if not n.is_switch]  # Only add created cds - otherwise overwrite host of switched
    nidb.add_nodes_from(
        cd_nodes, retain=['label', 'host'], collision_domain=True)

    #TODO: write a helper functions to do this
    for node in nidb.nodes("collision_domain"):
        ipv4_node = anm['ipv4'].node(node)
        node.ipv4_subnet = ipv4_node.subnet
        node.ipv6_subnet = ipv4_node['ipv6'].subnet


# add edges to switches
    edges_to_add = [edge for edge in g_phy.edges()
            if edge.src.is_switch or edge.dst.is_switch]
    edges_to_add += [edge for edge in g_ip.edges() if edge.split] # cd edges from split
    nidb.add_edges_from(edges_to_add, retain='edge_id')

# TODO: boundaries is still a work in progress...
    nidb.copy_graphics(g_graphics)

    return nidb
Exemple #2
0
def create_nidb(anm):
    nidb = NIDB()
    g_phy = anm['phy']
    g_ip = anm['ip']
    g_graphics = anm['graphics']
    nidb.add_nodes_from(
        g_phy, retain=['label', 'host', 'platform', 'Network', 'update'])

    cd_nodes = [n for n in g_ip.nodes(
        "collision_domain") if not n.is_switch]  # Only add created cds - otherwise overwrite host of switched
    nidb.add_nodes_from(
        cd_nodes, retain=['label', 'host'], collision_domain=True)

    for node in nidb.nodes("collision_domain"):
        ipv4_node = anm['ipv4'].node(node)
        if ipv4_node:
            node.ipv4_subnet = ipv4_node.subnet
            node.ipv6_subnet = ipv4_node['ipv6'].subnet

# add edges to switches
    edges_to_add = [edge for edge in g_phy.edges()
            if edge.src.is_switch or edge.dst.is_switch]
    edges_to_add += [edge for edge in g_ip.edges() if edge.split] # cd edges from split
    nidb.add_edges_from(edges_to_add, retain='edge_id')

    nidb.copy_graphics(g_graphics)

    return nidb
Exemple #3
0
def create_nidb(anm):
    nidb = NIDB()
    g_phy = anm['phy']
    g_ip = anm['ip']
    g_graphics = anm['graphics']
    nidb.add_nodes_from(
        g_phy, retain=['label', 'host', 'platform', 'Network', 'update', 'asn'])

    cd_nodes = [n for n in g_ip.nodes(
        "broadcast_domain") if not n.is_switch()]  # Only add created cds - otherwise overwrite host of switched
    nidb.add_nodes_from(
        cd_nodes, retain=['label', 'host'], broadcast_domain=True)

    for node in nidb.nodes("broadcast_domain"):
        ipv4_node = anm['ipv4'].node(node)
        if ipv4_node:
            node.ipv4_subnet = ipv4_node.subnet
            #TODO: copy across IPv6 seperately
            node.ipv6_subnet = ipv4_node['ipv6'].subnet

# add edges to switches
    edges_to_add = [edge for edge in g_phy.edges()
                    if edge.src.is_switch() or edge.dst.is_switch()]
    # cd edges from split
    edges_to_add += [edge for edge in g_ip.edges() if edge.split]
    nidb.add_edges_from(edges_to_add)

    nidb.copy_graphics(g_graphics)

    return nidb
def create_nidb(anm):
    nidb = NIDB()
    g_phy = anm['phy']
    g_ip = anm['ip']
    g_graphics = anm['graphics']
    # TODO: build this on a platform by platform basis
    nidb.add_nodes_from(
        g_phy, retain=['label', 'host', 'platform', 'Network', 'update'])

    cd_nodes = [
        n for n in g_ip.nodes("collision_domain") if not n.is_switch
    ]  # Only add created cds - otherwise overwrite host of switched
    nidb.add_nodes_from(cd_nodes,
                        retain=['label', 'host'],
                        collision_domain=True)

    #TODO: write a helper functions to do this
    for node in nidb.nodes("collision_domain"):
        ipv4_node = anm['ipv4'].node(node)
        node.ipv4_subnet = ipv4_node.subnet
        node.ipv6_subnet = ipv4_node['ipv6'].subnet


# add edges to switches
    edges_to_add = [
        edge for edge in g_phy.edges()
        if edge.src.is_switch or edge.dst.is_switch
    ]
    edges_to_add += [edge for edge in g_ip.edges()
                     if edge.split]  # cd edges from split
    nidb.add_edges_from(edges_to_add, retain='edge_id')

    # TODO: boundaries is still a work in progress...
    nidb.copy_graphics(g_graphics)

    return nidb