@Test public void testGetUnnumberedPeerRowNoRemoteAs() { BgpPeerConfigId peerId = new BgpPeerConfigId("c1", "vrf1", "iface"); BgpUnnumberedPeerConfig peer = BgpUnnumberedPeerConfig.builder() .setPeerInterface("iface") .setLocalAs(1L) .setIpv4UnicastAddressFamily(Ipv4UnicastAddressFamily.builder().build()) .build(); Row row = getUnnumberedPeerRow(peerId, peer, null); Row expected = Row.builder() .put(COL_CONFIGURED_STATUS, ConfiguredSessionStatus.NO_REMOTE_AS) .put(COL_ADDRESS_FAMILIES, ImmutableSet.of()) .put(COL_LOCAL_INTERFACE, NodeInterfacePair.of("c1", "iface")) .put(COL_LOCAL_IP, null) .put(COL_LOCAL_AS, 1L) .put(COL_NODE, new Node("c1")) .put(COL_REMOTE_AS, "") .put(COL_REMOTE_NODE, null) .put(COL_REMOTE_INTERFACE, null) .put(COL_REMOTE_IP, null) .put(COL_SESSION_TYPE, SessionType.UNSET) .put(COL_VRF, "vrf1") .build(); assertThat(row, equalTo(expected)); }
@Nonnull @VisibleForTesting static Row getUnnumberedPeerRow( BgpPeerConfigId unnumId, BgpUnnumberedPeerConfig unnumPeer, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) { ConfiguredSessionStatus status = getConfiguredStatus(unnumId, unnumPeer, configuredTopology); Node remoteNode = null; NodeInterfacePair remoteInterface = null; Long localAs = unnumPeer.getLocalAs(); String remoteAs = unnumPeer.getRemoteAsns().toString(); Set<Type> addressFamilies = ImmutableSet.of(); if (status == UNIQUE_MATCH) { BgpPeerConfigId remoteId = configuredTopology.adjacentNodes(unnumId).iterator().next(); remoteNode = new Node(remoteId.getHostname()); remoteInterface = NodeInterfacePair.of(remoteId.getHostname(), remoteId.getPeerInterface()); Optional<BgpSessionProperties> sessionProps = configuredTopology.edgeValue(unnumId, remoteId); if (sessionProps.isPresent()) { remoteAs = Long.toString(sessionProps.get().getHeadAs()); localAs = sessionProps.get().getTailAs(); addressFamilies = sessionProps.get().getAddressFamilies(); } } return Row.builder(METADATA_MAP) .put(COL_CONFIGURED_STATUS, status) .put( COL_LOCAL_INTERFACE, NodeInterfacePair.of(unnumId.getHostname(), unnumPeer.getPeerInterface())) .put(COL_LOCAL_AS, localAs) .put(COL_LOCAL_IP, null) .put(COL_NODE, new Node(unnumId.getHostname())) .put(COL_REMOTE_AS, remoteAs) .put(COL_REMOTE_NODE, remoteNode) .put(COL_REMOTE_INTERFACE, remoteInterface) .put(COL_REMOTE_IP, null) .put(COL_ADDRESS_FAMILIES, addressFamilies) .put(COL_SESSION_TYPE, getSessionType(unnumPeer)) .put(COL_VRF, unnumId.getVrfName()) .build(); }
BgpSessionCompatibilityAnswerer extends Answerer { @Nonnull @VisibleForTesting static Row getUnnumberedPeerRow( BgpPeerConfigId unnumId, BgpUnnumberedPeerConfig unnumPeer, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) { ConfiguredSessionStatus status = getConfiguredStatus(unnumId, unnumPeer, configuredTopology); Node remoteNode = null; NodeInterfacePair remoteInterface = null; Long localAs = unnumPeer.getLocalAs(); String remoteAs = unnumPeer.getRemoteAsns().toString(); Set<Type> addressFamilies = ImmutableSet.of(); if (status == UNIQUE_MATCH) { BgpPeerConfigId remoteId = configuredTopology.adjacentNodes(unnumId).iterator().next(); remoteNode = new Node(remoteId.getHostname()); remoteInterface = NodeInterfacePair.of(remoteId.getHostname(), remoteId.getPeerInterface()); Optional<BgpSessionProperties> sessionProps = configuredTopology.edgeValue(unnumId, remoteId); if (sessionProps.isPresent()) { remoteAs = Long.toString(sessionProps.get().getHeadAs()); localAs = sessionProps.get().getTailAs(); addressFamilies = sessionProps.get().getAddressFamilies(); } } return Row.builder(METADATA_MAP) .put(COL_CONFIGURED_STATUS, status) .put( COL_LOCAL_INTERFACE, NodeInterfacePair.of(unnumId.getHostname(), unnumPeer.getPeerInterface())) .put(COL_LOCAL_AS, localAs) .put(COL_LOCAL_IP, null) .put(COL_NODE, new Node(unnumId.getHostname())) .put(COL_REMOTE_AS, remoteAs) .put(COL_REMOTE_NODE, remoteNode) .put(COL_REMOTE_INTERFACE, remoteInterface) .put(COL_REMOTE_IP, null) .put(COL_ADDRESS_FAMILIES, addressFamilies) .put(COL_SESSION_TYPE, getSessionType(unnumPeer)) .put(COL_VRF, unnumId.getVrfName()) .build(); } }
BgpSessionCompatibilityAnswerer extends Answerer { @Nonnull @VisibleForTesting static Row getUnnumberedPeerRow( BgpPeerConfigId unnumId, BgpUnnumberedPeerConfig unnumPeer, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) { ConfiguredSessionStatus status = getConfiguredStatus(unnumId, unnumPeer, configuredTopology); Node remoteNode = null; NodeInterfacePair remoteInterface = null; Long localAs = unnumPeer.getLocalAs(); String remoteAs = unnumPeer.getRemoteAsns().toString(); Set<Type> addressFamilies = ImmutableSet.of(); if (status == UNIQUE_MATCH) { BgpPeerConfigId remoteId = configuredTopology.adjacentNodes(unnumId).iterator().next(); remoteNode = new Node(remoteId.getHostname()); remoteInterface = NodeInterfacePair.of(remoteId.getHostname(), remoteId.getPeerInterface()); Optional<BgpSessionProperties> sessionProps = configuredTopology.edgeValue(unnumId, remoteId); if (sessionProps.isPresent()) { remoteAs = Long.toString(sessionProps.get().getHeadAs()); localAs = sessionProps.get().getTailAs(); addressFamilies = sessionProps.get().getAddressFamilies(); } } return Row.builder(METADATA_MAP) .put(COL_CONFIGURED_STATUS, status) .put( COL_LOCAL_INTERFACE, NodeInterfacePair.of(unnumId.getHostname(), unnumPeer.getPeerInterface())) .put(COL_LOCAL_AS, localAs) .put(COL_LOCAL_IP, null) .put(COL_NODE, new Node(unnumId.getHostname())) .put(COL_REMOTE_AS, remoteAs) .put(COL_REMOTE_NODE, remoteNode) .put(COL_REMOTE_INTERFACE, remoteInterface) .put(COL_REMOTE_IP, null) .put(COL_ADDRESS_FAMILIES, addressFamilies) .put(COL_SESSION_TYPE, getSessionType(unnumPeer)) .put(COL_VRF, unnumId.getVrfName()) .build(); } BgpSessionCompatibilityAnswerer(Question question, IBatfish batfish); }
BgpSessionCompatibilityAnswerer extends Answerer { @Nonnull @VisibleForTesting static Row getUnnumberedPeerRow( BgpPeerConfigId unnumId, BgpUnnumberedPeerConfig unnumPeer, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) { ConfiguredSessionStatus status = getConfiguredStatus(unnumId, unnumPeer, configuredTopology); Node remoteNode = null; NodeInterfacePair remoteInterface = null; Long localAs = unnumPeer.getLocalAs(); String remoteAs = unnumPeer.getRemoteAsns().toString(); Set<Type> addressFamilies = ImmutableSet.of(); if (status == UNIQUE_MATCH) { BgpPeerConfigId remoteId = configuredTopology.adjacentNodes(unnumId).iterator().next(); remoteNode = new Node(remoteId.getHostname()); remoteInterface = NodeInterfacePair.of(remoteId.getHostname(), remoteId.getPeerInterface()); Optional<BgpSessionProperties> sessionProps = configuredTopology.edgeValue(unnumId, remoteId); if (sessionProps.isPresent()) { remoteAs = Long.toString(sessionProps.get().getHeadAs()); localAs = sessionProps.get().getTailAs(); addressFamilies = sessionProps.get().getAddressFamilies(); } } return Row.builder(METADATA_MAP) .put(COL_CONFIGURED_STATUS, status) .put( COL_LOCAL_INTERFACE, NodeInterfacePair.of(unnumId.getHostname(), unnumPeer.getPeerInterface())) .put(COL_LOCAL_AS, localAs) .put(COL_LOCAL_IP, null) .put(COL_NODE, new Node(unnumId.getHostname())) .put(COL_REMOTE_AS, remoteAs) .put(COL_REMOTE_NODE, remoteNode) .put(COL_REMOTE_INTERFACE, remoteInterface) .put(COL_REMOTE_IP, null) .put(COL_ADDRESS_FAMILIES, addressFamilies) .put(COL_SESSION_TYPE, getSessionType(unnumPeer)) .put(COL_VRF, unnumId.getVrfName()) .build(); } BgpSessionCompatibilityAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static TableMetadata createMetadata(Question question); }
BgpSessionCompatibilityAnswerer extends Answerer { @Nonnull @VisibleForTesting static Row getUnnumberedPeerRow( BgpPeerConfigId unnumId, BgpUnnumberedPeerConfig unnumPeer, ValueGraph<BgpPeerConfigId, BgpSessionProperties> configuredTopology) { ConfiguredSessionStatus status = getConfiguredStatus(unnumId, unnumPeer, configuredTopology); Node remoteNode = null; NodeInterfacePair remoteInterface = null; Long localAs = unnumPeer.getLocalAs(); String remoteAs = unnumPeer.getRemoteAsns().toString(); Set<Type> addressFamilies = ImmutableSet.of(); if (status == UNIQUE_MATCH) { BgpPeerConfigId remoteId = configuredTopology.adjacentNodes(unnumId).iterator().next(); remoteNode = new Node(remoteId.getHostname()); remoteInterface = NodeInterfacePair.of(remoteId.getHostname(), remoteId.getPeerInterface()); Optional<BgpSessionProperties> sessionProps = configuredTopology.edgeValue(unnumId, remoteId); if (sessionProps.isPresent()) { remoteAs = Long.toString(sessionProps.get().getHeadAs()); localAs = sessionProps.get().getTailAs(); addressFamilies = sessionProps.get().getAddressFamilies(); } } return Row.builder(METADATA_MAP) .put(COL_CONFIGURED_STATUS, status) .put( COL_LOCAL_INTERFACE, NodeInterfacePair.of(unnumId.getHostname(), unnumPeer.getPeerInterface())) .put(COL_LOCAL_AS, localAs) .put(COL_LOCAL_IP, null) .put(COL_NODE, new Node(unnumId.getHostname())) .put(COL_REMOTE_AS, remoteAs) .put(COL_REMOTE_NODE, remoteNode) .put(COL_REMOTE_INTERFACE, remoteInterface) .put(COL_REMOTE_IP, null) .put(COL_ADDRESS_FAMILIES, addressFamilies) .put(COL_SESSION_TYPE, getSessionType(unnumPeer)) .put(COL_VRF, unnumId.getVrfName()) .build(); } BgpSessionCompatibilityAnswerer(Question question, IBatfish batfish); @Override AnswerElement answer(NetworkSnapshot snapshot); static TableMetadata createMetadata(Question question); static final String COL_CONFIGURED_STATUS; }