Search in sources :

Example 1 with ValueGraph

use of com.google.common.graph.ValueGraph in project batfish by batfish.

the class BgpSessionCompatibilityAnswerer method getRows.

/**
 * Return the answer for {@link BgpSessionCompatibilityQuestion} -- a set of BGP sessions and
 * their compatibility.
 */
private List<Row> getRows(NetworkSnapshot snapshot, BgpSessionCompatibilityQuestion question) {
    Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot);
    NetworkConfigurations nc = NetworkConfigurations.of(configurations);
    SpecifierContext specifierContext = _batfish.specifierContext(snapshot);
    Set<String> nodes = question.getNodeSpecifier().resolve(specifierContext);
    Set<String> remoteNodes = question.getRemoteNodeSpecifier().resolve(specifierContext);
    L3Adjacencies l3Adjacencies = _batfish.getTopologyProvider().getInitialL3Adjacencies(snapshot);
    Map<Ip, Map<String, Set<String>>> ipVrfOwners = _batfish.getTopologyProvider().getInitialIpOwners(snapshot).getIpVrfOwners();
    ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology = BgpTopologyUtils.initBgpTopology(configurations, ipVrfOwners, true, l3Adjacencies).getGraph();
    // Generate answer row for each BGP peer (or rows, for dynamic peers with multiple remotes)
    return configuredTopology.nodes().stream().flatMap(peerId -> {
        switch(peerId.getType()) {
            case ACTIVE:
                BgpActivePeerConfig activePeer = nc.getBgpPointToPointPeerConfig(peerId);
                assert activePeer != null;
                return Stream.of(getActivePeerRow(peerId, activePeer, ipVrfOwners, configuredTopology));
            case DYNAMIC:
                BgpPassivePeerConfig passivePeer = nc.getBgpDynamicPeerConfig(peerId);
                assert passivePeer != null;
                return getPassivePeerRows(peerId, passivePeer, nc, configuredTopology).stream();
            case UNNUMBERED:
                BgpUnnumberedPeerConfig unnumPeer = nc.getBgpUnnumberedPeerConfig(peerId);
                assert unnumPeer != null;
                return Stream.of(getUnnumberedPeerRow(peerId, unnumPeer, configuredTopology));
            default:
                throw new BatfishException(String.format("Unsupported type of BGP peer config: %s", peerId.getType()));
        }
    }).filter(row -> matchesQuestionFilters(row, nodes, remoteNodes, question)).collect(ImmutableList.toImmutableList());
}
Also used : UNIQUE_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.UNIQUE_MATCH) COL_LOCAL_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_INTERFACE) COL_ADDRESS_FAMILIES(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_ADDRESS_FAMILIES) BgpSessionAnswererUtils.matchesNodesAndType(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.matchesNodesAndType) DisplayHints(org.batfish.datamodel.questions.DisplayHints) TableAnswerElement(org.batfish.datamodel.table.TableAnswerElement) BgpSessionAnswererUtils.getConfiguredStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getConfiguredStatus) BgpSessionProperties.getSessionType(org.batfish.datamodel.BgpSessionProperties.getSessionType) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Map(java.util.Map) SpecifierContext(org.batfish.specifier.SpecifierContext) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Schema(org.batfish.datamodel.answers.Schema) COL_REMOTE_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_IP) IBatfish(org.batfish.common.plugin.IBatfish) DYNAMIC_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.DYNAMIC_MATCH) Row(org.batfish.datamodel.table.Row) COL_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_NODE) List(java.util.List) ValueGraph(com.google.common.graph.ValueGraph) Stream(java.util.stream.Stream) COL_REMOTE_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_NODE) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) Question(org.batfish.datamodel.questions.Question) COL_REMOTE_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_INTERFACE) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) Optional(java.util.Optional) AnswerElement(org.batfish.datamodel.answers.AnswerElement) COL_VRF(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_VRF) NetworkSnapshot(org.batfish.common.NetworkSnapshot) ColumnMetadata(org.batfish.datamodel.table.ColumnMetadata) Ip(org.batfish.datamodel.Ip) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) COL_LOCAL_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_IP) COL_SESSION_TYPE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_SESSION_TYPE) TableMetadata(org.batfish.datamodel.table.TableMetadata) COL_LOCAL_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_AS) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) BatfishException(org.batfish.common.BatfishException) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) NO_MATCH_FOUND(org.batfish.datamodel.questions.ConfiguredSessionStatus.NO_MATCH_FOUND) COL_REMOTE_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_AS) ImmutableList(com.google.common.collect.ImmutableList) Configuration(org.batfish.datamodel.Configuration) Nonnull(javax.annotation.Nonnull) ConfiguredSessionStatus(org.batfish.datamodel.questions.ConfiguredSessionStatus) Answerer(org.batfish.common.Answerer) Type(org.batfish.datamodel.bgp.AddressFamily.Type) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) SessionType(org.batfish.datamodel.BgpSessionProperties.SessionType) Node(org.batfish.datamodel.pojo.Node) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpTopologyUtils(org.batfish.datamodel.bgp.BgpTopologyUtils) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) BgpSessionAnswererUtils.getLocallyBrokenStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getLocallyBrokenStatus) BatfishException(org.batfish.common.BatfishException) Configuration(org.batfish.datamodel.Configuration) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Ip(org.batfish.datamodel.Ip) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) SpecifierContext(org.batfish.specifier.SpecifierContext) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) Map(java.util.Map) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId)

Example 2 with ValueGraph

use of com.google.common.graph.ValueGraph in project batfish by batfish.

the class BgpSessionCompatibilityAnswerer method getPassivePeerRows.

@Nonnull
@VisibleForTesting
static List<Row> getPassivePeerRows(BgpPeerConfigId passiveId, BgpPassivePeerConfig passivePeer, NetworkConfigurations nc, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) {
    // Start row with base columns. Need to add status.
    // If there are compatible peers, will also add remote node and replace:
    // - local IP, with the remote node's remote IP
    // - remote AS
    // - remote IP
    // - session type
    // Local and remote interface will not be filled in (reserved for unnumbered peers).
    Row.TypedRowBuilder rb = Row.builder(METADATA_MAP).put(COL_LOCAL_AS, passivePeer.getLocalAs()).put(COL_LOCAL_IP, passivePeer.getLocalIp()).put(COL_NODE, new Node(passiveId.getHostname())).put(COL_REMOTE_AS, passivePeer.getRemoteAsns().toString()).put(COL_REMOTE_IP, new SelfDescribingObject(Schema.PREFIX, passivePeer.getPeerPrefix())).put(COL_ADDRESS_FAMILIES, ImmutableSet.of()).put(COL_SESSION_TYPE, SessionType.UNSET).put(COL_VRF, passiveId.getVrfName());
    // If peer has null remote prefix or empty remote AS list, generate one row
    ConfiguredSessionStatus brokenStatus = getLocallyBrokenStatus(passivePeer);
    if (brokenStatus != null) {
        return ImmutableList.of(rb.put(COL_CONFIGURED_STATUS, brokenStatus).build());
    }
    // Create a row for each valid remote peer compatible with this peer
    List<Row> rows = configuredTopology.adjacentNodes(passiveId).stream().filter(remoteId -> configuredTopology.inDegree(remoteId) == 1).map(remoteId -> {
        BgpSessionProperties sessionProps = configuredTopology.edgeValue(passiveId, remoteId).orElse(null);
        assert sessionProps != null;
        BgpActivePeerConfig activeRemote = nc.getBgpPointToPointPeerConfig(remoteId);
        assert activeRemote != null;
        return rb.put(COL_CONFIGURED_STATUS, DYNAMIC_MATCH).put(COL_ADDRESS_FAMILIES, sessionProps.getAddressFamilies()).put(COL_LOCAL_IP, sessionProps.getLocalIp()).put(COL_LOCAL_AS, sessionProps.getLocalAs()).put(COL_REMOTE_AS, Long.toString(sessionProps.getRemoteAs())).put(COL_REMOTE_NODE, new Node(remoteId.getHostname())).put(COL_REMOTE_IP, new SelfDescribingObject(Schema.IP, sessionProps.getRemoteIp())).put(COL_SESSION_TYPE, getSessionType(activeRemote)).build();
    }).collect(ImmutableList.toImmutableList());
    // If no compatible neighbors were found, generate one NO_MATCH_FOUND row
    return rows.isEmpty() ? ImmutableList.of(rb.put(COL_CONFIGURED_STATUS, NO_MATCH_FOUND).build()) : rows;
}
Also used : ConfiguredSessionStatus(org.batfish.datamodel.questions.ConfiguredSessionStatus) UNIQUE_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.UNIQUE_MATCH) COL_LOCAL_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_INTERFACE) COL_ADDRESS_FAMILIES(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_ADDRESS_FAMILIES) BgpSessionAnswererUtils.matchesNodesAndType(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.matchesNodesAndType) DisplayHints(org.batfish.datamodel.questions.DisplayHints) TableAnswerElement(org.batfish.datamodel.table.TableAnswerElement) BgpSessionAnswererUtils.getConfiguredStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getConfiguredStatus) BgpSessionProperties.getSessionType(org.batfish.datamodel.BgpSessionProperties.getSessionType) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Map(java.util.Map) SpecifierContext(org.batfish.specifier.SpecifierContext) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Schema(org.batfish.datamodel.answers.Schema) COL_REMOTE_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_IP) IBatfish(org.batfish.common.plugin.IBatfish) DYNAMIC_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.DYNAMIC_MATCH) Row(org.batfish.datamodel.table.Row) COL_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_NODE) List(java.util.List) ValueGraph(com.google.common.graph.ValueGraph) Stream(java.util.stream.Stream) COL_REMOTE_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_NODE) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) Question(org.batfish.datamodel.questions.Question) COL_REMOTE_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_INTERFACE) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) Optional(java.util.Optional) AnswerElement(org.batfish.datamodel.answers.AnswerElement) COL_VRF(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_VRF) NetworkSnapshot(org.batfish.common.NetworkSnapshot) ColumnMetadata(org.batfish.datamodel.table.ColumnMetadata) Ip(org.batfish.datamodel.Ip) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) COL_LOCAL_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_IP) COL_SESSION_TYPE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_SESSION_TYPE) TableMetadata(org.batfish.datamodel.table.TableMetadata) COL_LOCAL_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_AS) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) BatfishException(org.batfish.common.BatfishException) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) NO_MATCH_FOUND(org.batfish.datamodel.questions.ConfiguredSessionStatus.NO_MATCH_FOUND) COL_REMOTE_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_AS) ImmutableList(com.google.common.collect.ImmutableList) Configuration(org.batfish.datamodel.Configuration) Nonnull(javax.annotation.Nonnull) ConfiguredSessionStatus(org.batfish.datamodel.questions.ConfiguredSessionStatus) Answerer(org.batfish.common.Answerer) Type(org.batfish.datamodel.bgp.AddressFamily.Type) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) SessionType(org.batfish.datamodel.BgpSessionProperties.SessionType) Node(org.batfish.datamodel.pojo.Node) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpTopologyUtils(org.batfish.datamodel.bgp.BgpTopologyUtils) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) BgpSessionAnswererUtils.getLocallyBrokenStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getLocallyBrokenStatus) Node(org.batfish.datamodel.pojo.Node) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) Row(org.batfish.datamodel.table.Row) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Nonnull(javax.annotation.Nonnull)

Example 3 with ValueGraph

use of com.google.common.graph.ValueGraph in project batfish by batfish.

the class BgpSessionStatusAnswerer method getPassivePeerRows.

@Nonnull
@VisibleForTesting
static List<Row> getPassivePeerRows(BgpPeerConfigId passiveId, BgpPassivePeerConfig passivePeer, NetworkConfigurations nc, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology, ValueGraph<BgpPeerConfigId, BgpSessionProperties> establishedTopology) {
    // Start row with base columns. Need to add status.
    // If there are compatible peers, will also add remote node and replace:
    // - local IP, with the remote node's remote IP
    // - remote AS
    // - remote IP
    // - session type
    // Local and remote interface will not be filled in (reserved for unnumbered peers).
    Row.TypedRowBuilder rb = Row.builder(METADATA_MAP).put(COL_ADDRESS_FAMILIES, ImmutableSet.of()).put(COL_LOCAL_AS, passivePeer.getLocalAs()).put(COL_LOCAL_IP, passivePeer.getLocalIp()).put(COL_NODE, new Node(passiveId.getHostname())).put(COL_REMOTE_AS, passivePeer.getRemoteAsns().toString()).put(COL_REMOTE_IP, new SelfDescribingObject(Schema.PREFIX, passivePeer.getPeerPrefix())).put(COL_SESSION_TYPE, SessionType.UNSET).put(COL_VRF, passiveId.getVrfName());
    // If peer is locally misconfigured (missing remote prefix or local/remote AS) generate one row
    if (getLocallyBrokenStatus(passivePeer) != null) {
        return ImmutableList.of(rb.put(COL_ESTABLISHED_STATUS, NOT_COMPATIBLE).build());
    }
    // Find all correctly configured remote peers compatible with this peer
    Set<BgpPeerConfigId> compatibleRemotes = configuredTopology.adjacentNodes(passiveId);
    // If no compatible neighbors exist, generate one NOT_ESTABLISHED row
    if (compatibleRemotes.isEmpty()) {
        return ImmutableList.of(rb.put(COL_ESTABLISHED_STATUS, NOT_ESTABLISHED).build());
    }
    // Find all remote peers that established a session with this peer. Passive peer will not be in
    // establishedBgpTopology at all it was invalid according to bgpConfigPassesSanityChecks()
    Set<BgpPeerConfigId> establishedRemotes = establishedTopology.nodes().contains(passiveId) ? establishedTopology.adjacentNodes(passiveId) : ImmutableSet.of();
    // Compatible remotes exist. Generate a row for each.
    return compatibleRemotes.stream().map(remoteId -> {
        BgpSessionProperties sessionProps = configuredTopology.edgeValue(passiveId, remoteId).orElse(null);
        assert sessionProps != null;
        BgpActivePeerConfig activeRemote = nc.getBgpPointToPointPeerConfig(remoteId);
        assert activeRemote != null;
        BgpSessionStatus status = establishedRemotes.contains(remoteId) ? ESTABLISHED : NOT_ESTABLISHED;
        return rb.put(COL_ESTABLISHED_STATUS, status).put(COL_ADDRESS_FAMILIES, sessionProps.getAddressFamilies()).put(COL_LOCAL_IP, sessionProps.getLocalIp()).put(COL_LOCAL_AS, sessionProps.getLocalAs()).put(COL_REMOTE_AS, Long.toString(sessionProps.getRemoteAs())).put(COL_REMOTE_NODE, new Node(remoteId.getHostname())).put(COL_REMOTE_IP, new SelfDescribingObject(Schema.IP, sessionProps.getRemoteIp())).put(COL_SESSION_TYPE, sessionProps.getSessionType()).build();
    }).collect(ImmutableList.toImmutableList());
}
Also used : UNIQUE_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.UNIQUE_MATCH) COL_LOCAL_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_INTERFACE) COL_ADDRESS_FAMILIES(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_ADDRESS_FAMILIES) NOT_COMPATIBLE(org.batfish.datamodel.questions.BgpSessionStatus.NOT_COMPATIBLE) BgpSessionAnswererUtils.matchesNodesAndType(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.matchesNodesAndType) DisplayHints(org.batfish.datamodel.questions.DisplayHints) TableAnswerElement(org.batfish.datamodel.table.TableAnswerElement) BgpSessionAnswererUtils.getConfiguredStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getConfiguredStatus) TopologyProvider(org.batfish.common.topology.TopologyProvider) BgpSessionProperties.getSessionType(org.batfish.datamodel.BgpSessionProperties.getSessionType) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Map(java.util.Map) SpecifierContext(org.batfish.specifier.SpecifierContext) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) ImmutableSet(com.google.common.collect.ImmutableSet) BgpPeerConfig(org.batfish.datamodel.BgpPeerConfig) Set(java.util.Set) Schema(org.batfish.datamodel.answers.Schema) COL_REMOTE_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_IP) IBatfish(org.batfish.common.plugin.IBatfish) Row(org.batfish.datamodel.table.Row) COL_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_NODE) List(java.util.List) NOT_ESTABLISHED(org.batfish.datamodel.questions.BgpSessionStatus.NOT_ESTABLISHED) ValueGraph(com.google.common.graph.ValueGraph) Stream(java.util.stream.Stream) COL_REMOTE_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_NODE) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) Question(org.batfish.datamodel.questions.Question) ESTABLISHED(org.batfish.datamodel.questions.BgpSessionStatus.ESTABLISHED) COL_REMOTE_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_INTERFACE) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) AnswerElement(org.batfish.datamodel.answers.AnswerElement) COL_VRF(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_VRF) NetworkSnapshot(org.batfish.common.NetworkSnapshot) ColumnMetadata(org.batfish.datamodel.table.ColumnMetadata) Ip(org.batfish.datamodel.Ip) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) COL_LOCAL_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_IP) COL_SESSION_TYPE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_SESSION_TYPE) TableMetadata(org.batfish.datamodel.table.TableMetadata) COL_LOCAL_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_AS) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) BatfishException(org.batfish.common.BatfishException) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) COL_REMOTE_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_AS) ImmutableList(com.google.common.collect.ImmutableList) Configuration(org.batfish.datamodel.Configuration) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Answerer(org.batfish.common.Answerer) Type(org.batfish.datamodel.bgp.AddressFamily.Type) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) SessionType(org.batfish.datamodel.BgpSessionProperties.SessionType) Node(org.batfish.datamodel.pojo.Node) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpTopologyUtils(org.batfish.datamodel.bgp.BgpTopologyUtils) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BgpSessionStatus(org.batfish.datamodel.questions.BgpSessionStatus) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) BgpSessionAnswererUtils.getLocallyBrokenStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getLocallyBrokenStatus) Node(org.batfish.datamodel.pojo.Node) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) BgpSessionStatus(org.batfish.datamodel.questions.BgpSessionStatus) Row(org.batfish.datamodel.table.Row) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Nonnull(javax.annotation.Nonnull)

Example 4 with ValueGraph

use of com.google.common.graph.ValueGraph in project batfish by batfish.

the class BgpSessionStatusAnswerer method getRows.

/**
 * Return the answer for {@link BgpSessionStatusQuestion} -- a set of BGP sessions and their
 * status.
 */
private List<Row> getRows(NetworkSnapshot snapshot, BgpSessionStatusQuestion question) {
    Map<String, Configuration> configurations = _batfish.loadConfigurations(snapshot);
    NetworkConfigurations nc = NetworkConfigurations.of(configurations);
    SpecifierContext specifierContext = _batfish.specifierContext(snapshot);
    Set<String> nodes = question.getNodeSpecifier().resolve(specifierContext);
    Set<String> remoteNodes = question.getRemoteNodeSpecifier().resolve(specifierContext);
    TopologyProvider topologyProvider = _batfish.getTopologyProvider();
    Map<Ip, Map<String, Set<String>>> ipVrfOwners = topologyProvider.getInitialIpOwners(snapshot).getIpVrfOwners();
    L3Adjacencies adjacencies = topologyProvider.getL3Adjacencies(snapshot);
    ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology = BgpTopologyUtils.initBgpTopology(configurations, ipVrfOwners, true, adjacencies).getGraph();
    ValueGraph<BgpPeerConfigId, BgpSessionProperties> establishedTopology = topologyProvider.getBgpTopology(snapshot).getGraph();
    // Generate answer row for each BGP peer (or rows, for dynamic peers with multiple remotes)
    return configuredTopology.nodes().stream().flatMap(peerId -> {
        switch(peerId.getType()) {
            case ACTIVE:
                BgpActivePeerConfig activePeer = nc.getBgpPointToPointPeerConfig(peerId);
                assert activePeer != null;
                return Stream.of(getActivePeerRow(peerId, activePeer, ipVrfOwners, configuredTopology, establishedTopology));
            case DYNAMIC:
                BgpPassivePeerConfig passivePeer = nc.getBgpDynamicPeerConfig(peerId);
                assert passivePeer != null;
                return getPassivePeerRows(peerId, passivePeer, nc, configuredTopology, establishedTopology).stream();
            case UNNUMBERED:
                BgpUnnumberedPeerConfig unnumPeer = nc.getBgpUnnumberedPeerConfig(peerId);
                assert unnumPeer != null;
                return Stream.of(getUnnumberedPeerRow(peerId, unnumPeer, configuredTopology, establishedTopology));
            default:
                throw new BatfishException(String.format("Unsupported type of BGP peer config: %s", peerId.getType()));
        }
    }).filter(row -> matchesQuestionFilters(row, nodes, remoteNodes, question)).collect(ImmutableList.toImmutableList());
}
Also used : UNIQUE_MATCH(org.batfish.datamodel.questions.ConfiguredSessionStatus.UNIQUE_MATCH) COL_LOCAL_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_INTERFACE) COL_ADDRESS_FAMILIES(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_ADDRESS_FAMILIES) NOT_COMPATIBLE(org.batfish.datamodel.questions.BgpSessionStatus.NOT_COMPATIBLE) BgpSessionAnswererUtils.matchesNodesAndType(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.matchesNodesAndType) DisplayHints(org.batfish.datamodel.questions.DisplayHints) TableAnswerElement(org.batfish.datamodel.table.TableAnswerElement) BgpSessionAnswererUtils.getConfiguredStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getConfiguredStatus) TopologyProvider(org.batfish.common.topology.TopologyProvider) BgpSessionProperties.getSessionType(org.batfish.datamodel.BgpSessionProperties.getSessionType) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Map(java.util.Map) SpecifierContext(org.batfish.specifier.SpecifierContext) SelfDescribingObject(org.batfish.datamodel.answers.SelfDescribingObject) ImmutableSet(com.google.common.collect.ImmutableSet) BgpPeerConfig(org.batfish.datamodel.BgpPeerConfig) Set(java.util.Set) Schema(org.batfish.datamodel.answers.Schema) COL_REMOTE_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_IP) IBatfish(org.batfish.common.plugin.IBatfish) Row(org.batfish.datamodel.table.Row) COL_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_NODE) List(java.util.List) NOT_ESTABLISHED(org.batfish.datamodel.questions.BgpSessionStatus.NOT_ESTABLISHED) ValueGraph(com.google.common.graph.ValueGraph) Stream(java.util.stream.Stream) COL_REMOTE_NODE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_NODE) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) Question(org.batfish.datamodel.questions.Question) ESTABLISHED(org.batfish.datamodel.questions.BgpSessionStatus.ESTABLISHED) COL_REMOTE_INTERFACE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_INTERFACE) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) AnswerElement(org.batfish.datamodel.answers.AnswerElement) COL_VRF(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_VRF) NetworkSnapshot(org.batfish.common.NetworkSnapshot) ColumnMetadata(org.batfish.datamodel.table.ColumnMetadata) Ip(org.batfish.datamodel.Ip) NodeInterfacePair(org.batfish.datamodel.collections.NodeInterfacePair) COL_LOCAL_IP(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_IP) COL_SESSION_TYPE(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_SESSION_TYPE) TableMetadata(org.batfish.datamodel.table.TableMetadata) COL_LOCAL_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_LOCAL_AS) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) BatfishException(org.batfish.common.BatfishException) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) COL_REMOTE_AS(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.COL_REMOTE_AS) ImmutableList(com.google.common.collect.ImmutableList) Configuration(org.batfish.datamodel.Configuration) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Answerer(org.batfish.common.Answerer) Type(org.batfish.datamodel.bgp.AddressFamily.Type) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) SessionType(org.batfish.datamodel.BgpSessionProperties.SessionType) Node(org.batfish.datamodel.pojo.Node) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpTopologyUtils(org.batfish.datamodel.bgp.BgpTopologyUtils) VisibleForTesting(com.google.common.annotations.VisibleForTesting) BgpSessionStatus(org.batfish.datamodel.questions.BgpSessionStatus) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) BgpSessionAnswererUtils.getLocallyBrokenStatus(org.batfish.question.bgpsessionstatus.BgpSessionAnswererUtils.getLocallyBrokenStatus) BatfishException(org.batfish.common.BatfishException) Configuration(org.batfish.datamodel.Configuration) NetworkConfigurations(org.batfish.datamodel.NetworkConfigurations) Ip(org.batfish.datamodel.Ip) BgpUnnumberedPeerConfig(org.batfish.datamodel.BgpUnnumberedPeerConfig) L3Adjacencies(org.batfish.common.topology.L3Adjacencies) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) TopologyProvider(org.batfish.common.topology.TopologyProvider) SpecifierContext(org.batfish.specifier.SpecifierContext) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) Map(java.util.Map) TableMetadata.toColumnMap(org.batfish.datamodel.table.TableMetadata.toColumnMap) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId)

Example 5 with ValueGraph

use of com.google.common.graph.ValueGraph in project batfish by batfish.

the class AristaGrammarTest method testBgpLocalAs.

@Test
public void testBgpLocalAs() throws IOException {
    String testrigName = "arista-bgp-local-as";
    List<String> configurationNames = ImmutableList.of("r1", "r2");
    Batfish batfish = BatfishTestUtils.getBatfishFromTestrigText(TestrigText.builder().setConfigurationFiles(SNAPSHOTS_PREFIX + testrigName, configurationNames).build(), _folder);
    Map<String, Configuration> configurations = batfish.loadConfigurations(batfish.getSnapshot());
    assertTrue(configurations.values().stream().allMatch(c -> c.getConfigurationFormat() == ARISTA));
    Map<Ip, Map<String, Set<String>>> ipOwners = batfish.getTopologyProvider().getInitialIpOwners(batfish.getSnapshot()).getIpVrfOwners();
    ValueGraph<BgpPeerConfigId, BgpSessionProperties> bgpTopology = BgpTopologyUtils.initBgpTopology(configurations, ipOwners, false, null).getGraph();
    // Edge one direction
    assertThat(bgpTopology.adjacentNodes(new BgpPeerConfigId("r1", DEFAULT_VRF_NAME, Prefix.parse("1.2.0.2/32"), false)).iterator().next(), equalTo(new BgpPeerConfigId("r2", DEFAULT_VRF_NAME, Prefix.parse("1.2.0.1/32"), false)));
    // Edge the other direction
    assertThat(bgpTopology.adjacentNodes(new BgpPeerConfigId("r2", DEFAULT_VRF_NAME, Prefix.parse("1.2.0.1/32"), false)).iterator().next(), equalTo(new BgpPeerConfigId("r1", DEFAULT_VRF_NAME, Prefix.parse("1.2.0.2/32"), false)));
}
Also used : OspfExternalType2Route(org.batfish.datamodel.OspfExternalType2Route) ConnectedRouteMetadata(org.batfish.datamodel.ConnectedRouteMetadata) PrefixList(org.batfish.representation.arista.PrefixList) BgpNeighborMatchers.hasRemoteAs(org.batfish.datamodel.matchers.BgpNeighborMatchers.hasRemoteAs) InterfaceMatchers.hasDescription(org.batfish.datamodel.matchers.InterfaceMatchers.hasDescription) ExpandedCommunityList(org.batfish.representation.arista.ExpandedCommunityList) ALL_VLANS(org.batfish.representation.arista.Interface.ALL_VLANS) CommunityMatchExpr(org.batfish.datamodel.routing_policy.communities.CommunityMatchExpr) BgpRouteMatchers.hasCommunities(org.batfish.datamodel.matchers.BgpRouteMatchers.hasCommunities) CommunityContext(org.batfish.datamodel.routing_policy.communities.CommunityContext) ParametersAreNonnullByDefault(javax.annotation.ParametersAreNonnullByDefault) InterfaceMatchers.hasMtu(org.batfish.datamodel.matchers.InterfaceMatchers.hasMtu) ConfigurationMatchers.hasMlagConfig(org.batfish.datamodel.matchers.ConfigurationMatchers.hasMlagConfig) Map(java.util.Map) AclLine(org.batfish.datamodel.AclLine) DependencyType(org.batfish.datamodel.Interface.DependencyType) AristaStaticSourceNat(org.batfish.representation.arista.AristaStaticSourceNat) OSPF_INTERNAL(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF_INTERNAL) Dependency(org.batfish.datamodel.Interface.Dependency) BgpPeerConfig(org.batfish.datamodel.BgpPeerConfig) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) SwitchportMode(org.batfish.datamodel.SwitchportMode) AristaBgpVrfIpv6UnicastAddressFamily(org.batfish.representation.arista.eos.AristaBgpVrfIpv6UnicastAddressFamily) VniMatchers.hasUdpPort(org.batfish.datamodel.matchers.VniMatchers.hasUdpPort) TraceAndReverseFlow(org.batfish.datamodel.flow.TraceAndReverseFlow) RouteMapSetCommunityNone(org.batfish.representation.arista.RouteMapSetCommunityNone) Assert.assertFalse(org.junit.Assert.assertFalse) MapMatchers.hasKeys(org.batfish.datamodel.matchers.MapMatchers.hasKeys) NetworkSnapshot(org.batfish.common.NetworkSnapshot) IpAsPathAccessList(org.batfish.representation.arista.IpAsPathAccessList) OspfNetwork(org.batfish.representation.arista.OspfNetwork) BgpProcessMatchers.hasMultipathEquivalentAsPathMatchMode(org.batfish.datamodel.matchers.BgpProcessMatchers.hasMultipathEquivalentAsPathMatchMode) BatfishTestUtils.configureBatfishTestSettings(org.batfish.main.BatfishTestUtils.configureBatfishTestSettings) ConfigurationMatchers(org.batfish.datamodel.matchers.ConfigurationMatchers) VniMatchers.hasSourceAddress(org.batfish.datamodel.matchers.VniMatchers.hasSourceAddress) FlowMatchers.hasSrcIp(org.batfish.datamodel.matchers.FlowMatchers.hasSrcIp) SerializationUtils(org.apache.commons.lang3.SerializationUtils) IpAccessListMatchers.hasLines(org.batfish.datamodel.matchers.IpAccessListMatchers.hasLines) AristaBgpVlan(org.batfish.representation.arista.eos.AristaBgpVlan) NextHop(org.batfish.representation.arista.StaticRoute.NextHop) EvpnAddressFamily(org.batfish.datamodel.bgp.EvpnAddressFamily) SnmpServer(org.batfish.datamodel.SnmpServer) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Names.generatedBgpRedistributionPolicyName(org.batfish.datamodel.Names.generatedBgpRedistributionPolicyName) LineAction(org.batfish.datamodel.LineAction) VniMatchers.hasBumTransportIps(org.batfish.datamodel.matchers.VniMatchers.hasBumTransportIps) Layer2Vni(org.batfish.datamodel.vxlan.Layer2Vni) Assert.assertTrue(org.junit.Assert.assertTrue) Iterables.getOnlyElement(com.google.common.collect.Iterables.getOnlyElement) AddressFamilyCapabilitiesMatchers.hasSendCommunity(org.batfish.datamodel.matchers.AddressFamilyCapabilitiesMatchers.hasSendCommunity) IOException(java.io.IOException) InterfaceType(org.batfish.datamodel.InterfaceType) Test(org.junit.Test) CommunitySetMatchExpr(org.batfish.datamodel.routing_policy.communities.CommunitySetMatchExpr) DEFAULT_VRF(org.batfish.representation.arista.eos.AristaBgpProcess.DEFAULT_VRF) WarningMatchers(org.batfish.common.matchers.WarningMatchers) BgpConfederation(org.batfish.datamodel.bgp.BgpConfederation) ExtendedCommunity(org.batfish.datamodel.bgp.community.ExtendedCommunity) OspfIntraAreaRoute(org.batfish.datamodel.OspfIntraAreaRoute) BgpAggregate(org.batfish.datamodel.bgp.BgpAggregate) Assert.assertNull(org.junit.Assert.assertNull) AristaConfiguration(org.batfish.representation.arista.AristaConfiguration) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) GeneratedRoute(org.batfish.datamodel.GeneratedRoute) RemovePrivateAsMode(org.batfish.representation.arista.eos.AristaBgpNeighbor.RemovePrivateAsMode) AristaBgpVrf(org.batfish.representation.arista.eos.AristaBgpVrf) AristaBgpNetworkConfiguration(org.batfish.representation.arista.eos.AristaBgpNetworkConfiguration) Resources.readResource(org.batfish.common.util.Resources.readResource) BgpNeighborMatchers.hasIpv4UnicastAddressFamily(org.batfish.datamodel.matchers.BgpNeighborMatchers.hasIpv4UnicastAddressFamily) SnmpCommunity(org.batfish.datamodel.SnmpCommunity) DEFAULT_LOCAL_BGP_WEIGHT(org.batfish.representation.arista.AristaConfiguration.DEFAULT_LOCAL_BGP_WEIGHT) InterfaceMatchers.hasAddressMetadata(org.batfish.datamodel.matchers.InterfaceMatchers.hasAddressMetadata) Matchers.hasKey(org.hamcrest.Matchers.hasKey) AclLineMatchExprs.matchDst(org.batfish.datamodel.acl.AclLineMatchExprs.matchDst) Assert.assertThat(org.junit.Assert.assertThat) Transformation.when(org.batfish.datamodel.transformation.Transformation.when) RouteMapSetCommunityListDelete(org.batfish.representation.arista.RouteMapSetCommunityListDelete) ConvertConfigurationAnswerElement(org.batfish.datamodel.answers.ConvertConfigurationAnswerElement) AddressFamilyCapabilitiesMatchers.hasAllowRemoteAsOut(org.batfish.datamodel.matchers.AddressFamilyCapabilitiesMatchers.hasAllowRemoteAsOut) Prefix6(org.batfish.datamodel.Prefix6) RouteMapClause(org.batfish.representation.arista.RouteMapClause) InterfaceMatchers.hasAllowedVlans(org.batfish.datamodel.matchers.InterfaceMatchers.hasAllowedVlans) Names.generatedBgpPeerExportPolicyName(org.batfish.datamodel.Names.generatedBgpPeerExportPolicyName) ImmutableSet(com.google.common.collect.ImmutableSet) AristaEosVxlan(org.batfish.representation.arista.eos.AristaEosVxlan) AclLineMatchExprs.and(org.batfish.datamodel.acl.AclLineMatchExprs.and) FlowDisposition(org.batfish.datamodel.FlowDisposition) AristaBgpV4Neighbor(org.batfish.representation.arista.eos.AristaBgpV4Neighbor) Collectors(java.util.stream.Collectors) OriginType(org.batfish.datamodel.OriginType) NextHopDiscard(org.batfish.datamodel.route.nh.NextHopDiscard) IpSpaceReference(org.batfish.datamodel.IpSpaceReference) Settings(org.batfish.config.Settings) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) BgpPassivePeerConfig(org.batfish.datamodel.BgpPassivePeerConfig) RoutingPolicy(org.batfish.datamodel.routing_policy.RoutingPolicy) Matchers.equalTo(org.hamcrest.Matchers.equalTo) CommunitySetMatchExprEvaluator(org.batfish.datamodel.routing_policy.communities.CommunitySetMatchExprEvaluator) Ip(org.batfish.datamodel.Ip) State(org.batfish.representation.arista.Vlan.State) AristaBgpV4DynamicNeighbor(org.batfish.representation.arista.eos.AristaBgpV4DynamicNeighbor) DUMMY_SNAPSHOT_1(org.batfish.main.BatfishTestUtils.DUMMY_SNAPSHOT_1) LongSpace(org.batfish.datamodel.LongSpace) DataModelMatchers.hasRedFlagWarning(org.batfish.datamodel.matchers.DataModelMatchers.hasRedFlagWarning) VXLAN(org.batfish.representation.arista.AristaStructureType.VXLAN) Ipv4UnicastAddressFamily(org.batfish.datamodel.bgp.Ipv4UnicastAddressFamily) MlagConfiguration(org.batfish.representation.arista.MlagConfiguration) ImmutableList(com.google.common.collect.ImmutableList) Configuration(org.batfish.datamodel.Configuration) StandardCommunityListLine(org.batfish.representation.arista.StandardCommunityListLine) ALWAYS(org.batfish.datamodel.bgp.AllowRemoteAsOutMode.ALWAYS) AbstractRouteDecoratorMatchers.hasProtocol(org.batfish.datamodel.matchers.AbstractRouteDecoratorMatchers.hasProtocol) Nonnull(javax.annotation.Nonnull) RouteMapSetCommunityList(org.batfish.representation.arista.RouteMapSetCommunityList) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) VniMatchers.hasBumTransportMethod(org.batfish.datamodel.matchers.VniMatchers.hasBumTransportMethod) ParseWarningMatchers.hasText(org.batfish.common.matchers.ParseWarningMatchers.hasText) Matchers.empty(org.hamcrest.Matchers.empty) BumTransportMethod(org.batfish.datamodel.BumTransportMethod) UTF_8(java.nio.charset.StandardCharsets.UTF_8) InterfaceMatchers.hasAllAddresses(org.batfish.datamodel.matchers.InterfaceMatchers.hasAllAddresses) OspfProcess.getReferenceOspfBandwidth(org.batfish.representation.arista.OspfProcess.getReferenceOspfBandwidth) Vlan(org.batfish.representation.arista.Vlan) Names.generatedBgpPeerEvpnExportPolicyName(org.batfish.datamodel.Names.generatedBgpPeerEvpnExportPolicyName) Builder(org.batfish.datamodel.Bgpv4Route.Builder) AristaBgpNeighborAddressFamily(org.batfish.representation.arista.eos.AristaBgpNeighborAddressFamily) OspfInterAreaRoute(org.batfish.datamodel.OspfInterAreaRoute) AclLineMatchExprs.permittedByAcl(org.batfish.datamodel.acl.AclLineMatchExprs.permittedByAcl) DataModelMatchers.hasBandwidth(org.batfish.datamodel.matchers.DataModelMatchers.hasBandwidth) AnnotatedRoute(org.batfish.datamodel.AnnotatedRoute) Prefix(org.batfish.datamodel.Prefix) OSPF(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF) VrfMatchers.hasLayer2Vnis(org.batfish.datamodel.matchers.VrfMatchers.hasLayer2Vnis) Arrays(java.util.Arrays) StandardAccessListRemarkLine(org.batfish.representation.arista.StandardAccessListRemarkLine) NextHopIp(org.batfish.datamodel.route.nh.NextHopIp) AristaBgpRedistributionPolicy(org.batfish.representation.arista.eos.AristaBgpRedistributionPolicy) DataModelMatchers.hasNoUndefinedReferences(org.batfish.datamodel.matchers.DataModelMatchers.hasNoUndefinedReferences) InterfaceMatchers.hasSwitchPortEncapsulation(org.batfish.datamodel.matchers.InterfaceMatchers.hasSwitchPortEncapsulation) Matchers.not(org.hamcrest.Matchers.not) Matchers.hasItems(org.hamcrest.Matchers.hasItems) Interface(org.batfish.datamodel.Interface) AristaBgpDefaultOriginate(org.batfish.representation.arista.eos.AristaBgpDefaultOriginate) InterfaceMatchers.hasSwitchPortMode(org.batfish.datamodel.matchers.InterfaceMatchers.hasSwitchPortMode) Flow(org.batfish.datamodel.Flow) AclIpSpace(org.batfish.datamodel.AclIpSpace) INTERFACE(org.batfish.representation.arista.AristaStructureType.INTERFACE) VendorStructureId(org.batfish.vendor.VendorStructureId) MAC_ACCESS_LIST(org.batfish.representation.arista.AristaStructureType.MAC_ACCESS_LIST) Matchers.nullValue(org.hamcrest.Matchers.nullValue) AclLineMatchExprs(org.batfish.datamodel.acl.AclLineMatchExprs) Bgpv4Route(org.batfish.datamodel.Bgpv4Route) Conversions.nameOfSourceNatIpSpaceFromAcl(org.batfish.representation.arista.Conversions.nameOfSourceNatIpSpaceFromAcl) AristaBgpAggregateNetwork(org.batfish.representation.arista.eos.AristaBgpAggregateNetwork) ExpandedCommunityListLine(org.batfish.representation.arista.ExpandedCommunityListLine) DataPlane(org.batfish.datamodel.DataPlane) VrrpGroup(org.batfish.datamodel.VrrpGroup) StaticRouteManager(org.batfish.representation.arista.StaticRouteManager) MlagMatchers.hasPeerInterface(org.batfish.datamodel.matchers.MlagMatchers.hasPeerInterface) TransformationStep.assignDestinationIp(org.batfish.datamodel.transformation.TransformationStep.assignDestinationIp) Range(com.google.common.collect.Range) Set(java.util.Set) CommunityMatchExprEvaluator(org.batfish.datamodel.routing_policy.communities.CommunityMatchExprEvaluator) AristaBgpVlanAwareBundle(org.batfish.representation.arista.eos.AristaBgpVlanAwareBundle) InterfaceMatchers.hasEncapsulationVlan(org.batfish.datamodel.matchers.InterfaceMatchers.hasEncapsulationVlan) InterfaceMatchers.hasInterfaceType(org.batfish.datamodel.matchers.InterfaceMatchers.hasInterfaceType) OSPF_NSSA_EXTERNAL_TYPE_2(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF_NSSA_EXTERNAL_TYPE_2) OriginMechanism(org.batfish.datamodel.OriginMechanism) OSPF_NSSA_EXTERNAL_TYPE_1(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF_NSSA_EXTERNAL_TYPE_1) VniMatchers.hasVlan(org.batfish.datamodel.matchers.VniMatchers.hasVlan) ValueGraph(com.google.common.graph.ValueGraph) MultipathEquivalentAsPathMatchMode(org.batfish.datamodel.MultipathEquivalentAsPathMatchMode) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.is(org.hamcrest.Matchers.is) ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) Matchers.containsString(org.hamcrest.Matchers.containsString) InterfaceMatchers.hasAccessVlan(org.batfish.datamodel.matchers.InterfaceMatchers.hasAccessVlan) AristaStructureType(org.batfish.representation.arista.AristaStructureType) Matchers.aMapWithSize(org.hamcrest.Matchers.aMapWithSize) Iterables(com.google.common.collect.Iterables) AristaConfiguration.aclLineStructureName(org.batfish.representation.arista.AristaConfiguration.aclLineStructureName) AristaBgpBestpathTieBreaker(org.batfish.representation.arista.eos.AristaBgpBestpathTieBreaker) BgpActivePeerConfig(org.batfish.datamodel.BgpActivePeerConfig) RouteMapSetCommunity(org.batfish.representation.arista.RouteMapSetCommunity) DataModelMatchers.hasUndefinedReference(org.batfish.datamodel.matchers.DataModelMatchers.hasUndefinedReference) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) SilentSyntaxCollection(org.batfish.grammar.silent_syntax.SilentSyntaxCollection) BgpProcessMatchers.hasMultipathEbgp(org.batfish.datamodel.matchers.BgpProcessMatchers.hasMultipathEbgp) InterfaceMatchers.isActive(org.batfish.datamodel.matchers.InterfaceMatchers.isActive) RouteMapMatchCommunity(org.batfish.representation.arista.RouteMapMatchCommunity) ConfigurationMatchers.hasConfigurationFormat(org.batfish.datamodel.matchers.ConfigurationMatchers.hasConfigurationFormat) StandardAccessList(org.batfish.representation.arista.StandardAccessList) POLICY_MAP(org.batfish.representation.arista.AristaStructureType.POLICY_MAP) TestrigText(org.batfish.main.TestrigText) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ConcreteInterfaceAddress(org.batfish.datamodel.ConcreteInterfaceAddress) Layer2VniConfig(org.batfish.datamodel.bgp.Layer2VniConfig) StandardCommunity(org.batfish.datamodel.bgp.community.StandardCommunity) GenericRib(org.batfish.datamodel.GenericRib) OspfExternalType1Route(org.batfish.datamodel.OspfExternalType1Route) Direction(org.batfish.datamodel.routing_policy.Environment.Direction) BgpTieBreaker(org.batfish.datamodel.BgpTieBreaker) ZERO(org.batfish.datamodel.Ip.ZERO) OSPF_NSSA_EXTERNAL(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF_NSSA_EXTERNAL) SessionType(org.batfish.datamodel.BgpSessionProperties.SessionType) AclLineMatchExprs.matchSrc(org.batfish.datamodel.acl.AclLineMatchExprs.matchSrc) Matchers.hasItem(org.hamcrest.Matchers.hasItem) UNSET_ROUTE_NEXT_HOP_IP(org.batfish.datamodel.Route.UNSET_ROUTE_NEXT_HOP_IP) BgpTopologyUtils(org.batfish.datamodel.bgp.BgpTopologyUtils) ConfigurationMatchers.hasInterface(org.batfish.datamodel.matchers.ConfigurationMatchers.hasInterface) VrrpInterface(org.batfish.representation.arista.VrrpInterface) VrfMatchers.hasBgpProcess(org.batfish.datamodel.matchers.VrfMatchers.hasBgpProcess) PrefixListLine(org.batfish.representation.arista.PrefixListLine) RouteDistinguisher(org.batfish.datamodel.bgp.RouteDistinguisher) RouteMapSetCommunityDelete(org.batfish.representation.arista.RouteMapSetCommunityDelete) TransformationStep.assignSourceIp(org.batfish.datamodel.transformation.TransformationStep.assignSourceIp) Layer3VniConfig(org.batfish.datamodel.bgp.Layer3VniConfig) ARISTA(org.batfish.datamodel.ConfigurationFormat.ARISTA) IntegerSpace(org.batfish.datamodel.IntegerSpace) CommunitySet(org.batfish.datamodel.routing_policy.communities.CommunitySet) InterfaceMatchers.hasMlagId(org.batfish.datamodel.matchers.InterfaceMatchers.hasMlagId) AddressFamilyCapabilitiesMatchers.hasSendExtendedCommunity(org.batfish.datamodel.matchers.AddressFamilyCapabilitiesMatchers.hasSendExtendedCommunity) AristaBgpVrfEvpnAddressFamily(org.batfish.representation.arista.eos.AristaBgpVrfEvpnAddressFamily) InterfaceMatchers.hasVrf(org.batfish.datamodel.matchers.InterfaceMatchers.hasVrf) MlagMatchers.hasId(org.batfish.datamodel.matchers.MlagMatchers.hasId) ImmutableMap(com.google.common.collect.ImmutableMap) AristaRedistributeType(org.batfish.representation.arista.eos.AristaRedistributeType) AddressFamilyMatchers.hasAddressFamilyCapabilites(org.batfish.datamodel.matchers.AddressFamilyMatchers.hasAddressFamilyCapabilites) VrfMatchers.hasName(org.batfish.datamodel.matchers.VrfMatchers.hasName) AsPath(org.batfish.datamodel.AsPath) List(java.util.List) AbstractRouteDecoratorMatchers.hasPrefix(org.batfish.datamodel.matchers.AbstractRouteDecoratorMatchers.hasPrefix) DataModelMatchers.hasNumReferrers(org.batfish.datamodel.matchers.DataModelMatchers.hasNumReferrers) StandardCommunityList(org.batfish.representation.arista.StandardCommunityList) Warnings(org.batfish.common.Warnings) InterfaceMatchers.hasSpeed(org.batfish.datamodel.matchers.InterfaceMatchers.hasSpeed) BgpProcessMatchers.hasPassiveNeighbor(org.batfish.datamodel.matchers.BgpProcessMatchers.hasPassiveNeighbor) FlowMatchers.hasDstIp(org.batfish.datamodel.matchers.FlowMatchers.hasDstIp) Protocol(org.batfish.representation.arista.AristaStaticSourceNat.Protocol) Optional(java.util.Optional) StandardAccessListActionLine(org.batfish.representation.arista.StandardAccessListActionLine) SortedMap(java.util.SortedMap) IpWildcard(org.batfish.datamodel.IpWildcard) SwitchportEncapsulationType(org.batfish.datamodel.SwitchportEncapsulationType) BatfishLogger(org.batfish.common.BatfishLogger) BatfishTestUtils(org.batfish.main.BatfishTestUtils) ConfigurationMatchers.hasIpAccessList(org.batfish.datamodel.matchers.ConfigurationMatchers.hasIpAccessList) RoutingProtocol(org.batfish.datamodel.RoutingProtocol) Transformation(org.batfish.datamodel.transformation.Transformation) Layer3Vni(org.batfish.datamodel.vxlan.Layer3Vni) BgpProcess(org.batfish.datamodel.BgpProcess) IpAsPathAccessListLine(org.batfish.representation.arista.IpAsPathAccessListLine) AristaBgpPeerGroupNeighbor(org.batfish.representation.arista.eos.AristaBgpPeerGroupNeighbor) RouteMap(org.batfish.representation.arista.RouteMap) AbstractRoute(org.batfish.datamodel.AbstractRoute) MlagMatchers.hasPeerAddress(org.batfish.datamodel.matchers.MlagMatchers.hasPeerAddress) OSPF_EXTERNAL(org.batfish.representation.arista.eos.AristaRedistributeType.OSPF_EXTERNAL) Batfish(org.batfish.main.Batfish) InterfaceMatchers.isSwitchport(org.batfish.datamodel.matchers.InterfaceMatchers.isSwitchport) Iterator(java.util.Iterator) Matchers(org.hamcrest.Matchers) StaticRoute(org.batfish.representation.arista.StaticRoute) ConfigurationMatchers.hasDefaultVrf(org.batfish.datamodel.matchers.ConfigurationMatchers.hasDefaultVrf) NextHopInterface(org.batfish.datamodel.route.nh.NextHopInterface) SUMMARY_ONLY_SUPPRESSION_POLICY_NAME(org.batfish.datamodel.routing_policy.Common.SUMMARY_ONLY_SUPPRESSION_POLICY_NAME) AristaBgpNeighbor(org.batfish.representation.arista.eos.AristaBgpNeighbor) Matchers.emptyIterable(org.hamcrest.Matchers.emptyIterable) BgpProcessMatchers.hasActiveNeighbor(org.batfish.datamodel.matchers.BgpProcessMatchers.hasActiveNeighbor) ParseVendorConfigurationAnswerElement(org.batfish.datamodel.answers.ParseVendorConfigurationAnswerElement) AristaBgpVrfIpv4UnicastAddressFamily(org.batfish.representation.arista.eos.AristaBgpVrfIpv4UnicastAddressFamily) Rule(org.junit.Rule) MlagMatchers(org.batfish.datamodel.matchers.MlagMatchers) Matchers.anEmptyMap(org.hamcrest.Matchers.anEmptyMap) ParseWarningMatchers.hasComment(org.batfish.common.matchers.ParseWarningMatchers.hasComment) TemporaryFolder(org.junit.rules.TemporaryFolder) AristaConfiguration(org.batfish.representation.arista.AristaConfiguration) AristaBgpNetworkConfiguration(org.batfish.representation.arista.eos.AristaBgpNetworkConfiguration) MlagConfiguration(org.batfish.representation.arista.MlagConfiguration) Configuration(org.batfish.datamodel.Configuration) FlowMatchers.hasSrcIp(org.batfish.datamodel.matchers.FlowMatchers.hasSrcIp) Ip(org.batfish.datamodel.Ip) NextHopIp(org.batfish.datamodel.route.nh.NextHopIp) TransformationStep.assignDestinationIp(org.batfish.datamodel.transformation.TransformationStep.assignDestinationIp) TransformationStep.assignSourceIp(org.batfish.datamodel.transformation.TransformationStep.assignSourceIp) FlowMatchers.hasDstIp(org.batfish.datamodel.matchers.FlowMatchers.hasDstIp) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) ImmutableMap(com.google.common.collect.ImmutableMap) SortedMap(java.util.SortedMap) RouteMap(org.batfish.representation.arista.RouteMap) Matchers.anEmptyMap(org.hamcrest.Matchers.anEmptyMap) BgpPeerConfigId(org.batfish.datamodel.BgpPeerConfigId) BgpSessionProperties(org.batfish.datamodel.BgpSessionProperties) Batfish(org.batfish.main.Batfish) Test(org.junit.Test)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)9 ImmutableSet (com.google.common.collect.ImmutableSet)9 ValueGraph (com.google.common.graph.ValueGraph)9 List (java.util.List)9 Map (java.util.Map)9 Set (java.util.Set)9 Configuration (org.batfish.datamodel.Configuration)9 NetworkSnapshot (org.batfish.common.NetworkSnapshot)8 Ip (org.batfish.datamodel.Ip)8 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 Nonnull (javax.annotation.Nonnull)7 BgpPeerConfigId (org.batfish.datamodel.BgpPeerConfigId)7 BgpSessionProperties (org.batfish.datamodel.BgpSessionProperties)7 NetworkConfigurations (org.batfish.datamodel.NetworkConfigurations)7 NodeInterfacePair (org.batfish.datamodel.collections.NodeInterfacePair)7 Answerer (org.batfish.common.Answerer)6 IBatfish (org.batfish.common.plugin.IBatfish)6 AnswerElement (org.batfish.datamodel.answers.AnswerElement)6 Schema (org.batfish.datamodel.answers.Schema)6 Node (org.batfish.datamodel.pojo.Node)6