Search in sources :

Example 1 with NeighborBuilder

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

the class NeighborStateCliUtilsTest method testFullNeighborStateCli.

@Test
public void testFullNeighborStateCli() throws IOException {
    final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder builder = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder();
    builder.addAugmentation(NeighborAfiSafiStateAugmentation.class, new NeighborAfiSafiStateAugmentationBuilder().setActive(true).setPrefixes(new PrefixesBuilder().setInstalled(1L).setReceived(1L).setSent(2L).build()).build());
    final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setState(builder.build()).build();
    final StateBuilder stateBuilder = new StateBuilder();
    stateBuilder.addAugmentation(NeighborStateAugmentation.class, new NeighborStateAugmentationBuilder().setSupportedCapabilities(Collections.singletonList(ADDPATHS.class)).setSessionState(BgpNeighborState.SessionState.ACTIVE).build());
    final Received received = new ReceivedBuilder().setNOTIFICATION(BigInteger.ONE).setUPDATE(BigInteger.TEN).build();
    final Sent sent = new SentBuilder().setNOTIFICATION(BigInteger.TEN).setUPDATE(BigInteger.ONE).build();
    stateBuilder.addAugmentation(BgpNeighborStateAugmentation.class, new BgpNeighborStateAugmentationBuilder().setMessages(new MessagesBuilder().setReceived(received).setSent(sent).build()).build());
    final Transport transport = new TransportBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.StateBuilder().addAugmentation(NeighborTransportStateAugmentation.class, new NeighborTransportStateAugmentationBuilder().setRemoteAddress(NEIGHBOR_IP_ADDRESS).setLocalPort(new PortNumber(1234)).setRemotePort(new PortNumber(4321)).build()).build()).build();
    final Timers timers = new TimersBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.StateBuilder().addAugmentation(NeighborTimersStateAugmentation.class, new NeighborTimersStateAugmentationBuilder().setNegotiatedHoldTime(BigDecimal.TEN).setUptime(new Timeticks(600L)).build()).build()).build();
    final Neighbor neighbor = new NeighborBuilder().setState(stateBuilder.build()).setAfiSafis(new AfiSafisBuilder().setAfiSafi(Collections.singletonList(afiSafi)).build()).setTransport(transport).setTimers(timers).build();
    NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
    final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("neighbor.txt"), UTF8);
    assertEquals(expected, this.output.toString());
}
Also used : NeighborTransportStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportStateAugmentationBuilder) NeighborStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborStateAugmentationBuilder) BgpNeighborStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentationBuilder) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) TransportBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TransportBuilder) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder) SentBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.SentBuilder) MessagesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.MessagesBuilder) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) NeighborTimersStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTimersStateAugmentation) AfiSafisBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder) NeighborTransportStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportStateAugmentation) TimersBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder) Sent(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) BgpNeighborStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentationBuilder) NeighborTimersStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTimersStateAugmentationBuilder) Received(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) Timeticks(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Timeticks) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) NeighborAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAfiSafiStateAugmentationBuilder) PrefixesBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder) ReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.ReceivedBuilder) Transport(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Timers(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers) Test(org.junit.Test)

Example 2 with NeighborBuilder

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

the class AppPeerTest method testAppPeer.

@Test
public void testAppPeer() {
    APP_PEER.start(this.rib, this.neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
    Mockito.verify(this.rib).getYangRibId();
    Mockito.verify(this.rib).getService();
    Mockito.verify(this.rib, times(1)).getLocalTablesKeys();
    APP_PEER.instantiateServiceInstance();
    Mockito.verify(this.rib, times(2)).getYangRibId();
    Mockito.verify(this.rib, times(2)).getRibSupportContext();
    Mockito.verify(this.rib, times(2)).getLocalTablesKeys();
    Mockito.verify(this.domTx).newWriteOnlyTransaction();
    APP_PEER.closeServiceInstance();
    APP_PEER.close();
    APP_PEER.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
    APP_PEER.instantiateServiceInstance();
    Mockito.verify(this.rib, times(4)).getYangRibId();
    Mockito.verify(this.rib, times(2)).getService();
    Mockito.verify(this.listener).close();
    assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
    assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
    APP_PEER.closeServiceInstance();
    APP_PEER.close();
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 3 with NeighborBuilder

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

the class BgpPeerTest method testBgpPeer.

@Test
public void testBgpPeer() {
    final Neighbor neighbor = new NeighborBuilder().setAfiSafis(createAfiSafi()).setConfig(createConfig()).setNeighborAddress(NEIGHBOR_ADDRESS).setRouteReflector(createRR()).setTimers(createTimers()).setTransport(createTransport()).setAddPaths(createAddPath()).build();
    this.bgpPeer.start(this.rib, neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
    Mockito.verify(this.rib).createPeerDOMChain(any());
    Mockito.verify(this.rib, times(2)).getLocalAs();
    Mockito.verify(this.rib).getLocalTables();
    this.bgpPeer.instantiateServiceInstance();
    Mockito.verify(this.bgpPeerRegistry).addPeer(any(), any(), any());
    Mockito.verify(this.dispatcher).createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(KeyMapping.class));
    try {
        this.bgpPeer.start(this.rib, neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
        fail("Expected Exception");
    } catch (final IllegalStateException expected) {
        assertEquals("Previous peer instance was not closed.", expected.getMessage());
    }
    this.bgpPeer.setServiceRegistration(this.serviceRegistration);
    this.bgpPeer.closeServiceInstance();
    this.bgpPeer.close();
    Mockito.verify(this.future).cancel(true);
    this.bgpPeer.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
    this.bgpPeer.instantiateServiceInstance();
    Mockito.verify(this.rib, times(2)).createPeerDOMChain(any());
    Mockito.verify(this.rib, times(4)).getLocalAs();
    Mockito.verify(this.rib, times(2)).getLocalTables();
    final Neighbor neighborExpected = createNeighborExpected(NEIGHBOR_ADDRESS);
    assertTrue(this.bgpPeer.containsEqualConfiguration(neighborExpected));
    assertFalse(this.bgpPeer.containsEqualConfiguration(createNeighborExpected(new IpAddress(new Ipv4Address("127.0.0.2")))));
    Mockito.verify(this.bgpPeerRegistry).removePeer(any(IpAddress.class));
    this.bgpPeer.closeServiceInstance();
    this.bgpPeer.close();
    Mockito.verify(this.serviceRegistration).unregister();
    Mockito.verify(this.future, times(2)).cancel(true);
    final Neighbor neighborDiffConfig = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setAfiSafis(createAfiSafi()).build();
    this.bgpPeer.start(this.rib, neighborDiffConfig, null, this.peerGroupLoader, this.tableTypeRegistry);
    assertTrue(this.bgpPeer.containsEqualConfiguration(neighborDiffConfig));
    this.bgpPeer.close();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 4 with NeighborBuilder

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

the class OpenConfigMappingUtilTest method toPeerRole.

@Test
public void toPeerRole() {
    Neighbor neighbor = new NeighborBuilder().setConfig(new ConfigBuilder().setPeerType(PeerType.EXTERNAL).build()).build();
    PeerRole peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.Ebgp, peerRoleResult);
    neighbor = new NeighborBuilder().setConfig(new ConfigBuilder().setPeerType(PeerType.INTERNAL).build()).build();
    peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.Ibgp, peerRoleResult);
    neighbor = new NeighborBuilder().setRouteReflector(new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder().setRouteReflectorClient(true).build()).build()).build();
    peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.RrClient, peerRoleResult);
}
Also used : PeerRole(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) RouteReflectorBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.RouteReflectorBuilder) 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) Test(org.junit.Test)

Example 5 with NeighborBuilder

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

the class OpenConfigMappingUtilTest method testGetNeighborKey.

@Test
public void testGetNeighborKey() {
    assertArrayEquals(MD5_PASSWORD.getBytes(StandardCharsets.US_ASCII), OpenConfigMappingUtil.getNeighborKey(NEIGHBOR).get(INSTANCE.inetAddressFor(NEIGHBOR_ADDRESS)));
    assertNull(OpenConfigMappingUtil.getNeighborKey(new NeighborBuilder().build()));
    assertNull(OpenConfigMappingUtil.getNeighborKey(new NeighborBuilder().setConfig(new ConfigBuilder().build()).build()));
}
Also used : 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)

Aggregations

NeighborBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder)12 Test (org.junit.Test)11 ConfigBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder)6 GlobalAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder)6 NeighborAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder)6 NeighborClusterIdConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder)6 NeighborPeerGroupConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder)6 NeighborTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder)6 PeerGroupTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder)6 PeerGroupBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder)5 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)4 TimersBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder)3 TransportBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TransportBuilder)3 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)2 AfiSafiBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder)2 AfiSafisBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder)2 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder)2 Transport (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2