@Test public void testGetDiffTableMetadataBGP() { ImmutableList.Builder<String> expectedBuilder = ImmutableList.builder(); expectedBuilder.add( COL_NODE, COL_VRF_NAME, COL_NETWORK, COL_ROUTE_ENTRY_PRESENCE, COL_BASE_PREFIX + COL_NEXT_HOP_IP, COL_DELTA_PREFIX + COL_NEXT_HOP_IP, COL_BASE_PREFIX + COL_PROTOCOL, COL_DELTA_PREFIX + COL_PROTOCOL, COL_BASE_PREFIX + COL_AS_PATH, COL_DELTA_PREFIX + COL_AS_PATH, COL_BASE_PREFIX + COL_METRIC, COL_DELTA_PREFIX + COL_METRIC, COL_BASE_PREFIX + COL_LOCAL_PREF, COL_DELTA_PREFIX + COL_LOCAL_PREF, COL_BASE_PREFIX + COL_COMMUNITIES, COL_DELTA_PREFIX + COL_COMMUNITIES, COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, COL_BASE_PREFIX + COL_ORIGIN_TYPE, COL_DELTA_PREFIX + COL_ORIGIN_TYPE, COL_BASE_PREFIX + COL_TAG, COL_DELTA_PREFIX + COL_TAG); ImmutableList.Builder<Schema> schemaBuilderList = ImmutableList.builder(); schemaBuilderList.add( Schema.NODE, Schema.STRING, Schema.PREFIX, Schema.STRING, Schema.IP, Schema.IP, Schema.STRING, Schema.STRING, Schema.STRING, Schema.STRING, Schema.LONG, Schema.LONG, Schema.LONG, Schema.LONG, Schema.list(Schema.STRING), Schema.list(Schema.STRING), Schema.STRING, Schema.STRING, Schema.STRING, Schema.STRING, Schema.LONG, Schema.LONG); List<ColumnMetadata> columnMetadata = getDiffTableMetadata(RibProtocol.BGP).getColumnMetadata(); assertThat( columnMetadata.stream() .map(ColumnMetadata::getName) .collect(ImmutableList.toImmutableList()), equalTo(expectedBuilder.build())); assertThat( columnMetadata.stream() .map(ColumnMetadata::getSchema) .collect(ImmutableList.toImmutableList()), equalTo(schemaBuilderList.build())); }
@VisibleForTesting static TableMetadata getDiffTableMetadata(RibProtocol rib) { ImmutableList.Builder<ColumnMetadata> columnBuilder = ImmutableList.builder(); addCommonTableColumnsAtStart(columnBuilder); columnBuilder.add( new ColumnMetadata( COL_ROUTE_ENTRY_PRESENCE, Schema.STRING, "Presence of a Route for the given Network (Prefix)", Boolean.FALSE, Boolean.TRUE)); switch (rib) { case BGP: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); break; case MAIN: default: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); } columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); return new TableMetadata(columnBuilder.build(), "Display diff of RIB routes"); }
RoutesAnswerer extends Answerer { @VisibleForTesting static TableMetadata getDiffTableMetadata(RibProtocol rib) { ImmutableList.Builder<ColumnMetadata> columnBuilder = ImmutableList.builder(); addCommonTableColumnsAtStart(columnBuilder); columnBuilder.add( new ColumnMetadata( COL_ROUTE_ENTRY_PRESENCE, Schema.STRING, "Presence of a Route for the given Network (Prefix)", Boolean.FALSE, Boolean.TRUE)); switch (rib) { case BGP: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); break; case MAIN: default: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); } columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); return new TableMetadata(columnBuilder.build(), "Display diff of RIB routes"); } }
RoutesAnswerer extends Answerer { @VisibleForTesting static TableMetadata getDiffTableMetadata(RibProtocol rib) { ImmutableList.Builder<ColumnMetadata> columnBuilder = ImmutableList.builder(); addCommonTableColumnsAtStart(columnBuilder); columnBuilder.add( new ColumnMetadata( COL_ROUTE_ENTRY_PRESENCE, Schema.STRING, "Presence of a Route for the given Network (Prefix)", Boolean.FALSE, Boolean.TRUE)); switch (rib) { case BGP: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); break; case MAIN: default: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); } columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); return new TableMetadata(columnBuilder.build(), "Display diff of RIB routes"); } RoutesAnswerer(Question question, IBatfish batfish); }
RoutesAnswerer extends Answerer { @VisibleForTesting static TableMetadata getDiffTableMetadata(RibProtocol rib) { ImmutableList.Builder<ColumnMetadata> columnBuilder = ImmutableList.builder(); addCommonTableColumnsAtStart(columnBuilder); columnBuilder.add( new ColumnMetadata( COL_ROUTE_ENTRY_PRESENCE, Schema.STRING, "Presence of a Route for the given Network (Prefix)", Boolean.FALSE, Boolean.TRUE)); switch (rib) { case BGP: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); break; case MAIN: default: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); } columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); return new TableMetadata(columnBuilder.build(), "Display diff of RIB routes"); } RoutesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); @Override AnswerElement answerDiff(NetworkSnapshot snapshot, NetworkSnapshot reference); }
RoutesAnswerer extends Answerer { @VisibleForTesting static TableMetadata getDiffTableMetadata(RibProtocol rib) { ImmutableList.Builder<ColumnMetadata> columnBuilder = ImmutableList.builder(); addCommonTableColumnsAtStart(columnBuilder); columnBuilder.add( new ColumnMetadata( COL_ROUTE_ENTRY_PRESENCE, Schema.STRING, "Presence of a Route for the given Network (Prefix)", Boolean.FALSE, Boolean.TRUE)); switch (rib) { case BGP: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_AS_PATH, Schema.STRING, "Route's AS path", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_LOCAL_PREF, Schema.LONG, "Route's Local Preference", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_COMMUNITIES, Schema.list(Schema.STRING), "Route's List of communities", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_PROTOCOL, Schema.STRING, "Route's Origin protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ORIGIN_TYPE, Schema.STRING, "Route's Origin type", Boolean.FALSE, Boolean.TRUE)); break; case MAIN: default: columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP, Schema.STRING, "Route's Next Hop's Hostname", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_IP, Schema.IP, "Route's Next Hop IP", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_PROTOCOL, Schema.STRING, "Route's Protocol", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_NEXT_HOP_INTERFACE, Schema.STRING, "Route's Next Hop Interface", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_METRIC, Schema.LONG, "Route's Metric", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_ADMIN_DISTANCE, Schema.INTEGER, "Route's Admin distance", Boolean.FALSE, Boolean.TRUE)); } columnBuilder.add( new ColumnMetadata( COL_BASE_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); columnBuilder.add( new ColumnMetadata( COL_DELTA_PREFIX + COL_TAG, Schema.LONG, "Tag for this route", Boolean.FALSE, Boolean.TRUE)); return new TableMetadata(columnBuilder.build(), "Display diff of RIB routes"); } RoutesAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); @Override AnswerElement answerDiff(NetworkSnapshot snapshot, NetworkSnapshot reference);  }