def set_update_trace_graph( source, destination, submit, bidir, src_ports, dst_ports, applications, ip_protocols, host_value, network_value, snapshot_value, ): ctx = dash.callback_context button_id = ctx.triggered[0]['prop_id'].split('.')[0] if button_id != "main_page_traceroute_submit": raise PreventUpdate src_ports = src_ports.split(',') if src_ports else None dst_ports = dst_ports.split(',') if dst_ports else None applications = applications.split(',') if applications else None ip_protocols = ip_protocols.split(',') if ip_protocols else None batfish = Batfish(host_value) batfish.set_network(network_value) result = batfish.traceroute(source, destination, bidir, snapshot_value, src_ports, dst_ports, applications, ip_protocols) reverse_flow_graph = [] reverse_flow_traces = [] if bidir: forward_flow_details = get_traceroute_details('forward', result, True) forward_flow_graph = forward_flow_details[0] forward_flow_traces = forward_flow_details[1] reverse_flow_details = get_traceroute_details('reverse', result, True) reverse_flow_graph = reverse_flow_details[0] reverse_flow_traces = reverse_flow_details[1] else: forward_flow_details = get_traceroute_details('forward', result, False) forward_flow_graph = forward_flow_details[0] forward_flow_traces = forward_flow_details[1] return forward_flow_graph, forward_flow_traces, reverse_flow_graph, reverse_flow_traces,
def set_chaos_trace_graph(source, destination, submit, choose_node, deactivate_node, deactivated_interface, src_ports, dst_ports, applications, ip_protocols, change_configuration_switch, host_value, network_value, snapshot_value): ctx = dash.callback_context button_id = ctx.triggered[0]['prop_id'].split('.')[0] deactivated_nodes = [] deactivated_interfaces = [] if button_id not in [ "chaos_traceroute_submit", "change_configuration_submit" ]: raise PreventUpdate src_ports = src_ports.split(',') if src_ports else None dst_ports = dst_ports.split(',') if dst_ports else None applications = applications.split(',') if applications else None ip_protocols = ip_protocols.split(',') if ip_protocols else None batfish = Batfish(host_value) batfish.set_network(network_value) bidir = False if change_configuration_switch: reference_snapshot = snapshot_value + "_CHANGED" batfish.init_snapshot(reference_snapshot) else: reference_snapshot = snapshot_value + "_FAIL" deactivated_nodes.append(choose_node) if not deactivate_node: deactivated_interfaces.append(deactivated_interface) batfish.network_failure(snapshot_value, reference_snapshot, deactivated_nodes, deactivated_interfaces) result = batfish.traceroute(source, destination, bidir, reference_snapshot, src_ports, dst_ports, applications, ip_protocols) chaos_flow_details = get_traceroute_details('forward', result, False, True) chaos_flow_graph = chaos_flow_details[0] chaos_flow_traces = chaos_flow_details[1] delete_old_files() return chaos_flow_graph, chaos_flow_traces