Search in sources :

Example 16 with Neighbors

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors in project netvirt by opendaylight.

the class BgpAlarms method processNeighborStatusMap.

private void processNeighborStatusMap(Map<String, String> nbrStatusMap, List<Neighbors> nbrs) {
    if (nbrs == null || nbrs.isEmpty()) {
        LOG.trace("No BGP neighbors configured.");
        return;
    }
    LOG.debug("Fetching neighbor status' from BGP, #of neighbors: {}", nbrList.size());
    for (Neighbors nbr : nbrList) {
        boolean alarmToRaise = false;
        try {
            LOG.trace("nbr {} checking status, AS num: {}", nbr.getAddress().getValue(), nbr.getRemoteAs());
            bgpMgr.getPeerStatus(nbr.getAddress().getValue(), nbr.getRemoteAs().longValue());
            LOG.trace("nbr {} status is: PEER UP", nbr.getAddress().getValue());
        } catch (BgpRouterException bre) {
            if (bre.getErrorCode() == BgpRouterException.BGP_PEER_DOWN) {
                LOG.error("nbr {} status is: DOWN", nbr.getAddress().getValue());
                alarmToRaise = true;
            } else if (bre.getErrorCode() == BgpRouterException.BGP_PEER_NOTCONFIGURED) {
                LOG.info("nbr {} status is: NOT CONFIGURED", nbr.getAddress().getValue());
            } else if (bre.getErrorCode() == BgpRouterException.BGP_PEER_UNKNOWN) {
                LOG.info("nbr {} status is: Unknown", nbr.getAddress().getValue());
            } else {
                LOG.info("nbr {} status is: Unknown, invalid BgpRouterException: ", nbr.getAddress().getValue(), bre);
            }
        } catch (TException tae) {
            LOG.error("nbr {} status is: Unknown, received TException: ", nbr.getAddress().getValue(), tae);
        }
        final BgpAlarmStatus alarmStatus = neighborsRaisedAlarmStatusMap.get(nbr.getAddress().getValue());
        if (alarmToRaise) {
            if (alarmStatus == null || alarmStatus != BgpAlarmStatus.RAISED) {
                LOG.trace("alarm raised for {}.", nbr.getAddress().getValue());
                raiseBgpNbrDownAlarm(nbr.getAddress().getValue());
            } else {
                LOG.trace("alarm raised already for {}", nbr.getAddress().getValue());
            }
        } else {
            if (alarmStatus == null || alarmStatus != BgpAlarmStatus.CLEARED) {
                clearBgpNbrDownAlarm(nbr.getAddress().getValue());
                LOG.trace("alarm cleared for {}", nbr.getAddress().getValue());
            } else {
                LOG.trace("alarm cleared already for {}", nbr.getAddress().getValue());
            }
        }
    }
}
Also used : TException(org.apache.thrift.TException) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) Neighbors(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors)

Example 17 with Neighbors

use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors 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();
    try (StateProviderImpl stateProvider = // FIXME: use a properly-controlled executor service
    new StateProviderImpl(getDataBroker(), 1, tableTypeRegistry, this.stateProvider, "global-bgp")) {
        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);
            assertNull(bgpRib.getNeighbors());
            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(), bgpInstanceIdentifier, bgpRib -> {
            final Neighbors neighbors = bgpRib.getNeighbors();
            assertNotNull(neighbors);
            assertEquals(peerGroupExpected, bgpRib.getPeerGroups().nonnullPeerGroup().values().iterator().next());
            final Neighbor neighborResult = neighbors.nonnullNeighbor().values().iterator().next();
            assertEquals(new IpAddress(neighborAddress.getIpv4AddressNoZone()), 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.augmentation(BgpNeighborStateAugmentation.class));
            assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.augmentation(NeighborStateAugmentation.class).getSessionState());
            final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.augmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
            assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
            return bgpRib;
        });
        this.bgpRibStates.clear();
        checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
    }
}
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.rev180329.network.instance.protocol.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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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.rev180329.network.instance.protocol.BgpNeighborStateAugmentation) NeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborStateAugmentation) Timers(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Aggregations

Neighbors (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors)12 NeighborsKey (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.NeighborsKey)9 Bgp (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp)7 TException (org.apache.thrift.TException)5 BgpRouterException (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException)5 TApplicationException (org.apache.thrift.TApplicationException)3 Global (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global)3 Neighbors (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 SocketException (java.net.SocketException)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)2 CandidateAlreadyRegisteredException (org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException)2 BgpRouter (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouter)2 org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi (org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi)2 org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi (org.opendaylight.netvirt.bgpmanager.thrift.gen.af_safi)2 AsId (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.AsId)2 GracefulRestart (org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.GracefulRestart)2