Search in sources :

Example 1 with PeerGroup

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup in project bgpcep by opendaylight.

the class PeerGroupStateCliUtils method displayState.

private static void displayState(final PeerGroup group, final ShellTable table) {
    addHeader(table, "Peer Group state");
    table.addRow().addContent("Peer Group Name", group.getPeerGroupName());
    final State state = group.getState();
    if (state == null) {
        return;
    }
    final PeerGroupStateAugmentation aug = state.getAugmentation(PeerGroupStateAugmentation.class);
    table.addRow().addContent("Total Prefixes", aug.getTotalPrefixes());
}
Also used : State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State) PeerGroupStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentation)

Example 2 with PeerGroup

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup in project bgpcep by opendaylight.

the class PeerGroupStateCliUtilsTest method testPeerGroupStateCli.

@Test
public void testPeerGroupStateCli() throws IOException {
    final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
    final PeerGroupStateAugmentation groupState = new PeerGroupStateAugmentationBuilder().setTotalPrefixes(1L).setTotalPaths(2L).build();
    peerGroup.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder().addAugmentation(PeerGroupStateAugmentation.class, groupState).build());
    PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
    final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("peer-group.txt"), UTF8);
    assertEquals(expected, this.output.toString());
}
Also used : PeerGroupStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentationBuilder) PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) PeerGroupStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentation) Test(org.junit.Test)

Example 3 with PeerGroup

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup in project bgpcep by opendaylight.

the class StateProviderImplTest method testActiveStateProvider.

@Test
public void testActiveStateProvider() throws Exception {
    doReturn(true).when(this.bgpRibState).isActive();
    doReturn(true).when(this.bgpPeerState).isActive();
    final StateProviderImpl stateProvider = new StateProviderImpl(getDataBroker(), 1, this.tableTypeRegistry, this.stateCollector, "global-bgp");
    stateProvider.init();
    final Global globalExpected = buildGlobalExpected(0);
    this.bgpRibStates.add(this.bgpRibState);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected, global);
        return bgpRib;
    });
    this.totalPathsCounter.increment();
    this.totalPrefixesCounter.increment();
    final Global globalExpected2 = buildGlobalExpected(1);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected2, global);
        return bgpRib;
    });
    this.totalPathsCounter.decrement();
    this.totalPrefixesCounter.decrement();
    final Global globalExpected3 = buildGlobalExpected(0);
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Global global = bgpRib.getGlobal();
        assertEquals(globalExpected3, global);
        Assert.assertNull(bgpRib.getNeighbors());
        Assert.assertNull(bgpRib.getPeerGroups());
        return bgpRib;
    });
    this.bgpPeerStates.add(this.bgpPeerState);
    final PeerGroup peerGroupExpected = buildGroupExpected();
    this.totalPathsCounter.increment();
    this.totalPrefixesCounter.increment();
    final AfiSafis expectedAfiSafis = buildAfiSafis();
    final ErrorHandling expectedErrorHandling = buildErrorHandling();
    final GracefulRestart expectedGracefulRestart = buildGracefulRestart();
    final Transport expectedTransport = buildTransport();
    final Timers expectedTimers = buildTimers();
    final BgpNeighborStateAugmentation expectedBgpNeighborState = buildBgpNeighborStateAugmentation();
    readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
        final Neighbors neighbors = bgpRib.getNeighbors();
        Assert.assertNotNull(neighbors);
        assertEquals(peerGroupExpected, bgpRib.getPeerGroups().getPeerGroup().get(0));
        final Neighbor neighborResult = neighbors.getNeighbor().get(0);
        assertEquals(this.neighborAddress, neighborResult.getNeighborAddress());
        assertEquals(expectedAfiSafis, neighborResult.getAfiSafis());
        assertEquals(expectedErrorHandling, neighborResult.getErrorHandling());
        assertEquals(expectedGracefulRestart, neighborResult.getGracefulRestart());
        assertEquals(expectedTransport, neighborResult.getTransport());
        assertEquals(expectedTimers, neighborResult.getTimers());
        final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State stateResult = neighborResult.getState();
        assertEquals(expectedBgpNeighborState, stateResult.getAugmentation(BgpNeighborStateAugmentation.class));
        assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.getAugmentation(NeighborStateAugmentation.class).getSessionState());
        final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.getAugmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
        Assert.assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
        return bgpRib;
    });
    this.bgpRibStates.clear();
    checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
    stateProvider.close();
}
Also used : ErrorHandling(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling) PeerGroup(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup) Neighbors(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) BgpCapability(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) GracefulRestart(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart) Transport(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation) NeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborStateAugmentation) Timers(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 4 with PeerGroup

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup in project bgpcep by opendaylight.

the class PeerGroupStateCliUtilsTest method testEmptyPeerGroupStateCli.

@Test
public void testEmptyPeerGroupStateCli() throws IOException {
    final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
    PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
    final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("empty-peer-group.txt"), UTF8);
    assertEquals(expected, this.output.toString());
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 PeerGroupBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder)2 PeerGroupStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentation)2 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)1 GracefulRestart (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart)1 AfiSafis (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis)1 ErrorHandling (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling)1 State (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State)1 Timers (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers)1 Transport (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport)1 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)1 PeerGroup (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup)1 Global (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global)1 Neighbors (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors)1 BgpCapability (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability)1 BgpNeighborStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.BgpNeighborStateAugmentation)1 NeighborStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborStateAugmentation)1 PeerGroupStateAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentationBuilder)1