Пример #1
0
def set_change_configuration(changed_configuration,
                             changed_configuration_submit,
                             chaos_traceroute_submit, choose_node,
                             batfish_host, batfish_network, batfish_snapshot):
    ctx = dash.callback_context
    button_id = ctx.triggered[0]['prop_id'].split('.')[0]

    if button_id not in [
            "change_configuration_submit", "chaos_traceroute_submit"
    ]:
        raise PreventUpdate
    if button_id == "chaos_traceroute_submit":
        return False

    batfish = Batfish(batfish_host)
    batfish.set_network(batfish_network)
    batfish.set_snapshot(batfish_snapshot)

    with open(r"assets\snapshot_holder\configs\\" + choose_node + ".txt",
              'w') as f:
        f.write(changed_configuration)

    nodes_df = batfish.get_info('fileParseStatus')
    for key, value in nodes_df.iterrows():
        if choose_node.lower() not in value['Nodes']:
            with open(
                    r"assets\snapshot_holder\configs\\" + value['Nodes'][0] +
                    ".txt", 'w') as f:
                f.write(
                    batfish.get_configuration(value['File_Name'],
                                              batfish_snapshot))
    return True
Пример #2
0
def get_change_configuration(choose_node, batfish_host, batfish_network,
                             batfish_snapshot):
    ctx = dash.callback_context
    button_id = ctx.triggered[0]['prop_id'].split('.')[0]

    if button_id != "acl_choose_node":
        raise PreventUpdate

    batfish = Batfish(batfish_host)
    batfish.set_network(batfish_network)
    batfish.set_snapshot(batfish_snapshot)
    nodes_df = batfish.get_info('fileParseStatus')
    for key, value in nodes_df.iterrows():
        if choose_node.lower() in value['Nodes']:
            return batfish.get_configuration(value['File_Name'],
                                             batfish_snapshot)