def generate_graph_rep_and_augment():
    # Config files -> batfish -> emulation
    # first, let's get the networkx graph
    G = nx.Graph()
    G_layer_2 = nx.Graph()
    G_layer_3 = nx.Graph()
    color_map = []

    device_dataframe = bfq.nodeProperties().answer().frame()
    add_devices_to_graphs(device_dataframe, G, G_layer_2, G_layer_3, color_map)

    interface_dataframe = bfq.interfaceProperties().answer().frame()
    add_interfaces_to_graphs(interface_dataframe, G, G_layer_2, G_layer_3,
                             color_map)

    edge_dataframe = bfq.edges().answer().frame()
    edges_layer1_dataframe = bfq.layer1Edges().answer().frame()
    edge_interfaces = set()
    connected_interfaces = add_edges_to_graphs(
        edge_dataframe,
        G,
        G_layer_2,
        G_layer_3,
        color_map,
        edge_interfaces,
        edges_layer1_dataframe,
    )

    for connected_interface in connected_interfaces:
        if str(connected_interface) in G_layer_2.nodes():
            G_layer_2.remove_node(str(connected_interface))

    return G, G_layer_2, G_layer_3, color_map
예제 #2
0
    def _get_isis_neighbors(self):
        isis_neighbors = list()
        isis_adjacencies = bfq.edges(edgeType='isis').answer()
        for neighbor in isis_adjacencies.rows:
            isis_neighbors.append(neighbor.get('Interface'))

        return isis_neighbors
def deactivate_l3_interfaces(bf_snapshot_base, bf_snapshot_fail):
    l3_links = (bfq.edges(
        nodes=L3_INTERFACE_SCOPE,
        remoteNodes=L3_INTERFACE_SCOPE).answer(bf_snapshot_base).frame())

    for link_index in range(len(l3_links)):
        print(
            "[*] Deactivating l3 link interface: [magenta bold]{}[/magenta bold]"
            .format(l3_links.loc[link_index].Interface),
            end=" ",
        )
        bf_fork_snapshot(
            base_name=bf_snapshot_base,
            name=bf_snapshot_fail,
            deactivate_interfaces=[l3_links.loc[link_index].Interface],
            overwrite=True,
        )
        pprint_results(
            get_differential_reachability(bf_snapshot_base, bf_snapshot_fail))
def print_debugging_info():
    parse_status = bfq.fileParseStatus().answer().frame()

    print("----------------------")

    print(parse_status)

    print("----------------------")

    parse_warning = bfq.parseWarning().answer().frame()

    print("----------------------")

    print(parse_warning)

    print("----------------------")

    # vxlanEdges,layer3Edges
    node_properties_trunc = bfq.nodeProperties(
        properties="Interfaces").answer().frame()

    print(node_properties_trunc)

    print("---------")
    print(bfq.undefinedReferences().answer().frame())

    print("layer1Edges")
    print("----------------------")
    print(bfq.layer1Edges().answer().frame())
    print("LAYER3_EDGES")
    print("----------------------")
    print(bfq.layer3Edges().answer().frame())
    print("----------------------")

    print(bfq.undefinedReferences().answer().frame())

    # Get edges of type layer 3 (IP layer)
    print(bfq.edges(edgeType="layer3").answer().frame())
예제 #5
0
print("#"*100)
print("Lists the structures defined in the network, along with the files and line numbers in which they are defined.")
print("#"*100)
print(bfq.definedStructures().answer().frame())

# Detect Loops 
print("#"*100)
print("Detect forwarding loops.")
print("#"*100)
print(bfq.detectLoops().answer().frame())

# List edges types
print("#"*100)
print("Lists neighbor relationships of the specified type (layer3, BGP, ospf, etc. in the form of edges).")
print("#"*100)
print(bfq.edges().answer().frame())

# File parse status
print("#"*100)
print("For each file in a snapshot, returns the host(s) that were produced by the file and the parse status: pass, fail, partially parsed.")
print("#"*100)
print(bfq.fileParseStatus().answer().frame())

# IP Interfaces
print("#"*100)
print("List IPs configured on interfaces")
print("#"*100)
ip_owners_ans = bfq.ipOwners().answer()
print(ip_owners_ans.frame())

# Traceroute !!