Search in sources :

Example 21 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetPeerAs.

@Test
public void testGetPeerAs() {
    assertEquals(AS, OpenConfigMappingUtil.getPeerAs(NEIGHBOR, null, null));
    assertEquals(AS, OpenConfigMappingUtil.getPeerAs(new NeighborBuilder().build(), null, this.rib.getLocalAs()));
    assertEquals(AS, OpenConfigMappingUtil.getPeerAs(NEIGHBOR, new PeerGroupBuilder().build(), null));
    assertEquals(AS, OpenConfigMappingUtil.getPeerAs(new NeighborBuilder().build(), new PeerGroupBuilder().build(), this.rib.getLocalAs()));
    assertEquals(AS, OpenConfigMappingUtil.getPeerAs(null, new PeerGroupBuilder().setConfig(new ConfigBuilder().setPeerAs(AS).build()).build(), null));
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) NeighborPeerGroupConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder) PeerGroupTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder) NeighborAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder) NeighborTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder) GlobalAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder) NeighborClusterIdConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Test(org.junit.Test)

Example 22 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetHoldTimer.

@Test
public void testGetHoldTimer() {
    TimersBuilder builder = new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(BigDecimal.TEN).build());
    assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getHoldTimer(NEIGHBOR, null));
    assertEquals(HOLDTIMER, OpenConfigMappingUtil.getHoldTimer(new NeighborBuilder().build(), null));
    assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getHoldTimer(NEIGHBOR, new PeerGroupBuilder().build()));
    assertEquals(BigDecimal.TEN.intValue(), OpenConfigMappingUtil.getHoldTimer(NEIGHBOR, new PeerGroupBuilder().setTimers(builder.build()).build()));
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) TimersBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Test(org.junit.Test)

Example 23 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetPort.

@Test
public void testGetPort() {
    final TransportBuilder transport = new TransportBuilder();
    assertEquals(PORT, OpenConfigMappingUtil.getPort(NEIGHBOR, null));
    assertEquals(PORT, OpenConfigMappingUtil.getPort(new NeighborBuilder().setTransport(transport.build()).build(), null));
    assertEquals(PORT, OpenConfigMappingUtil.getPort(new NeighborBuilder().setTransport(transport.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().build()).build()).build(), null));
    final PortNumber newPort = new PortNumber(111);
    final Config portConfig = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().addAugmentation(NeighborTransportConfig.class, new NeighborTransportConfigBuilder().setRemotePort(newPort).build()).build();
    assertEquals(newPort, OpenConfigMappingUtil.getPort(new NeighborBuilder().setTransport(transport.setConfig(portConfig).build()).build(), null));
    assertEquals(newPort, OpenConfigMappingUtil.getPort(new NeighborBuilder().setTransport(transport.setConfig(portConfig).build()).build(), new PeerGroupBuilder().build()));
    final Config portConfigGroup = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().addAugmentation(PeerGroupTransportConfig.class, new PeerGroupTransportConfigBuilder().setRemotePort(newPort).build()).build();
    assertEquals(newPort, OpenConfigMappingUtil.getPort(new NeighborBuilder().build(), new PeerGroupBuilder().setTransport(transport.setConfig(portConfigGroup).build()).build()));
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config) NeighborTransportConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfig) PeerGroupTransportConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfig) NeighborPeerGroupConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfig) NeighborClusterIdConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfig) NeighborAddPathsConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfig) GlobalAddPathsConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfig) PeerGroupTransportConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfig) PeerGroupTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder) TransportBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TransportBuilder) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) NeighborTransportConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfig) NeighborTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder) NeighborPeerGroupConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder) PeerGroupTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder) NeighborAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder) NeighborTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder) GlobalAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder) NeighborClusterIdConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Test(org.junit.Test)

Example 24 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class BgpPeer method containsEqualConfiguration.

@Override
public synchronized Boolean containsEqualConfiguration(final Neighbor neighbor) {
    if (this.currentConfiguration == null) {
        return false;
    }
    final AfiSafis actAfiSafi = this.currentConfiguration.getAfiSafis();
    final AfiSafis extAfiSafi = neighbor.getAfiSafis();
    final List<AfiSafi> actualSafi = actAfiSafi != null ? actAfiSafi.getAfiSafi() : Collections.emptyList();
    final List<AfiSafi> extSafi = extAfiSafi != null ? extAfiSafi.getAfiSafi() : Collections.emptyList();
    return actualSafi.containsAll(extSafi) && extSafi.containsAll(actualSafi) && Objects.equals(this.currentConfiguration.getConfig(), neighbor.getConfig()) && Objects.equals(this.currentConfiguration.getNeighborAddress(), neighbor.getNeighborAddress()) && Objects.equals(this.currentConfiguration.getAddPaths(), neighbor.getAddPaths()) && Objects.equals(this.currentConfiguration.getApplyPolicy(), neighbor.getApplyPolicy()) && Objects.equals(this.currentConfiguration.getAsPathOptions(), neighbor.getAsPathOptions()) && Objects.equals(this.currentConfiguration.getEbgpMultihop(), neighbor.getEbgpMultihop()) && Objects.equals(this.currentConfiguration.getGracefulRestart(), neighbor.getGracefulRestart()) && Objects.equals(this.currentConfiguration.getErrorHandling(), neighbor.getErrorHandling()) && Objects.equals(this.currentConfiguration.getLoggingOptions(), neighbor.getLoggingOptions()) && Objects.equals(this.currentConfiguration.getRouteReflector(), neighbor.getRouteReflector()) && Objects.equals(this.currentConfiguration.getState(), neighbor.getState()) && Objects.equals(this.currentConfiguration.getTimers(), neighbor.getTimers()) && Objects.equals(this.currentConfiguration.getTransport(), neighbor.getTransport());
}
Also used : AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis)

Example 25 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class NeighborStateCliUtils method displayNeighborOperationalState.

static void displayNeighborOperationalState(@NonNull final String neighborId, @NonNull final Neighbor neighbor, @NonNull final PrintStream stream) {
    final State neighborState = neighbor.getState();
    if (neighborState == null) {
        stream.println(String.format("No BgpSessionState found for [%s]", neighborId));
        return;
    }
    final ShellTable table = new ShellTable();
    table.column("Attribute").alignLeft();
    table.column("Value").alignLeft();
    table.addRow().addContent("Neighbor Address", neighborId);
    final NeighborStateAugmentation stateAug = neighborState.getAugmentation(NeighborStateAugmentation.class);
    if (stateAug != null) {
        table.addRow().addContent("Session State", stateAug.getSessionState());
        printCapabilitiesState(stateAug.getSupportedCapabilities(), table);
    }
    printTimerState(neighbor.getTimers(), table);
    printTransportState(neighbor.getTransport(), table);
    printMessagesState(neighborState, table);
    printAfiSafisState(neighbor.getAfiSafis().getAfiSafi(), table);
    table.print(stream);
}
Also used : ShellTable(org.apache.karaf.shell.table.ShellTable) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State) NeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborStateAugmentation) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation)

Aggregations

Test (org.junit.Test)20 NeighborBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder)10 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 ConfigBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder)5 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)5 GlobalAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder)5 NeighborAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder)5 NeighborClusterIdConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder)5 NeighborPeerGroupConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder)5 NeighborTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder)5 PeerGroupTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder)5 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)4 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)4 PeerGroupBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder)4 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)4 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)4 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)4 PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)4 BigInteger (java.math.BigInteger)3 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder)3