Example #1
0
def delete_snapshot(batfish_network, submit, delete_snapshot, batfish_host):
    ctx = dash.callback_context
    button_id = ctx.triggered[0]['prop_id'].split('.')[0]
    if not submit:
        raise PreventUpdate
    if button_id == "delete_snapshot_submit_button":
        batfish = Batfish(batfish_host)
        batfish.set_network(batfish_network)
        batfish.delete_snapshot(delete_snapshot)
Example #2
0
def acl_table(original_platform, original_acl, refractored_platform,
              refractored_acl, submit, host_value, network_value,
              snapshot_value):
    ctx = dash.callback_context
    button_id = ctx.triggered[0]['prop_id'].split('.')[0]

    if button_id != "acl_analyze_button":
        raise PreventUpdate
    batfish = Batfish(host_value)
    batfish.set_network(network_value)
    batfish.set_snapshot(snapshot_value)
    compare_acl_df = batfish.compare_acls(original_acl, refractored_acl,
                                          original_platform,
                                          refractored_platform)
    batfish.delete_snapshot("refractored")
    batfish.delete_snapshot("original")
    children = dash_table.DataTable(id='table',
                                    columns=[{
                                        "name": i,
                                        "id": i,
                                        "deletable": True
                                    } for i in compare_acl_df.columns],
                                    data=compare_acl_df.to_dict('records'),
                                    filter_action="native",
                                    style_cell={
                                        'fontSize': 12,
                                        'font-family': 'sans-serif'
                                    },
                                    style_data_conditional=[{
                                        'if': {
                                            'row_index': 'odd'
                                        },
                                        'backgroundColor':
                                        'rgb(248, 248, 248)'
                                    }],
                                    style_header={
                                        'backgroundColor':
                                        'rgb(230, 230, 230)',
                                        'fontWeight': 'bold'
                                    })
    return children