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());
}
}
}
}
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);
}
}
Aggregations