use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebfd.rev190219.BfdConfig in project netvirt by opendaylight.
the class BfdCache method doExecute.
@SuppressWarnings("resource")
@Override
protected Object doExecute() throws Exception {
PrintStream ps = session.getConsole();
BfdConfig bfdConfig = bgpUtil.getBfdConfig();
if (bfdConfig != null) {
boolean bfdEnabled = bfdConfig.isBfdEnabled();
ps.printf("%nbfd-enabled %s%n", bfdEnabled ? "yes" : "no");
int minrx = bfdConfig.getMinRx().intValue();
int mintx = bfdConfig.getMinTx().intValue();
int detectmult = bfdConfig.getDetectMult().intValue();
boolean multihop = bfdConfig.isMultihop();
ps.printf("%n\t%-15s %d%n\t%-15s %d%n\t%-15s %d%n\t%-15s %s%n", MINRX, minrx, MINTX, mintx, DMULT, detectmult, MLHOP, multihop ? "yes" : "no");
} else {
ps.printf("%nbfd-enabled %s%n", "no");
}
DcgwTepList dcgwTepList = bgpUtil.getDcgwTepConfig();
if (dcgwTepList != null) {
dcgwTepList.getDcgwTep().values().forEach(dcgwTep -> {
ps.printf("%n%n%-15s %s", DCGWIP, dcgwTep.getDcGwIp());
dcgwTep.getTepIps().forEach(tep -> {
ps.printf("%n\t%-15s %s", TEPIP, tep);
});
});
ps.printf("%n");
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebfd.rev190219.BfdConfig in project netvirt by opendaylight.
the class BgpConfigurationManager method startBfd.
public void startBfd(long detectMult, long minRx, long minTx, boolean multiHop) {
InstanceIdentifier.InstanceIdentifierBuilder<BfdConfig> iib = InstanceIdentifier.builder(BfdConfig.class);
InstanceIdentifier<BfdConfig> iid = iib.build();
BfdConfig dto = new BfdConfigBuilder().setBfdEnabled(true).setMultihop(multiHop).setMinRx(minRx).setMinTx(minTx).setDetectMult(detectMult).build();
update(iid, dto);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebfd.rev190219.BfdConfig in project netvirt by opendaylight.
the class BgpConfigurationManager method replay.
@SuppressWarnings("checkstyle:IllegalCatch")
public synchronized boolean replay() throws InterruptedException, TimeoutException, ExecutionException {
boolean replaySucceded = true;
boolean doRouteSync = false;
String host = getConfigHost();
int port = getConfigPort();
LOG.error("connecting to bgp host {} ", host);
boolean res = bgpRouter.connect(host, port);
if (!res) {
LOG.error("Cannot connect to BGP config server at {} {}", host, port);
return replaySucceded;
}
config = getConfig();
if (config == null) {
LOG.error("bgp config is empty nothing to push to bgp");
return replaySucceded;
}
BgpRouter br = bgpRouter;
AsId asId = config.getAsId();
if (asId == null) {
LOG.error("bgp as-id is null");
return replaySucceded;
}
long asNum = asId.getLocalAs().toJava();
IpAddress routerId = asId.getRouterId();
String rid = routerId == null ? "" : routerId.stringValue();
int stalepathTime = (int) getStalePathtime(bgpGrRestartTime, config.getAsId());
boolean announceFbit = true;
boolean replayDone = false;
final int numberOfStartBgpRetries = 3;
RetryOnException startBgpRetry = new RetryOnException(numberOfStartBgpRetries);
do {
try {
LOG.debug("Replaying BGPConfig ");
br.startBgp(asNum, rid, bgpKaTime, bgpHoldTime, stalepathTime, announceFbit);
LOG.debug("Replay BGPConfig successful");
replayDone = true;
break;
} catch (BgpRouterException bre) {
if (bre.getErrorCode() == BgpRouterException.BGP_ERR_ACTIVE) {
LOG.debug("Starting the routesync for exception", bre);
startBgpRetry.errorOccured();
if (!startBgpRetry.shouldRetry()) {
doRouteSync = true;
replayDone = true;
}
} else {
LOG.error("Replay: startBgp() received exception error {} : ", bre.getErrorCode(), bre);
startBgpRetry.errorOccured();
}
} catch (TApplicationException tae) {
if (tae.getType() == BgpRouterException.BGP_ERR_ACTIVE) {
LOG.debug("Starting the routesync for exception", tae);
startBgpRetry.errorOccured();
if (!startBgpRetry.shouldRetry()) {
doRouteSync = true;
replayDone = true;
}
} else if (tae.getType() == BgpRouterException.BGP_ERR_COMMON_FAILURE) {
LOG.debug("Starting the routesync for AS-ID started exception", tae);
startBgpRetry.errorOccured();
if (!startBgpRetry.shouldRetry()) {
doRouteSync = true;
replayDone = true;
}
} else {
LOG.error("Replay: startBgp() received exception type {}: ", tae.getType(), tae);
startBgpRetry.errorOccured();
}
} catch (Exception e) {
// not unusual. We may have restarted & BGP is already on
LOG.error("Replay:startBgp() received exception: ", e);
startBgpRetry.errorOccured();
}
} while (startBgpRetry.shouldRetry());
replaySucceded = replayDone;
startBgpCountersTask();
startBgpAlarmsTask();
/*
* commenting this due to a bug with QBGP. Will uncomment once QBGP fix is done.
* This wont have any functional impacts
*/
// try {
// br.delayEOR(delayEorSeconds);
// } catch (TException | BgpRouterException e) {
// LOG.error("Replay: delayEOR() number of seconds to wait for EOR from ODL:", e);
// }
BfdConfig bfdConfig = bgpUtil.getBfdConfig();
if (bfdConfig != null) {
if (bfdConfig.isBfdEnabled()) {
LOG.debug("Replaying bfd config min-rx {} min-tx {} detect-mul {} mhop {}", bfdConfig.getMinRx(), bfdConfig.getMinTx(), bfdConfig.getDetectMult(), bfdConfig.isMultihop());
try {
br.addBfd(bfdConfig.getDetectMult().intValue(), bfdConfig.getMinRx().intValue(), bfdConfig.getMinTx().intValue(), bfdConfig.isMultihop());
} catch (TApplicationException tae) {
if (tae.getType() == BgpRouterException.BGP_ERR_PEER_EXISTS) {
LOG.debug("Replay:addBfd() received exception", tae);
} else {
LOG.error("Replay:addBfd() received exception", tae);
}
} catch (TException | BgpRouterException e) {
LOG.error("Replay:addBfd() received exception", e);
}
}
}
Map<NeighborsKey, Neighbors> keyNeighborsMap = config.getNeighborsContainer() == null ? null : config.getNeighborsContainer().getNeighbors();
if (keyNeighborsMap != null) {
LOG.error("configuring existing Neighbors present for replay total keyNeighborsMap {}", keyNeighborsMap.values().size());
boolean neighborConfigReplayResult = replayNbrConfig(new ArrayList<Neighbors>(keyNeighborsMap.values()), br);
if (neighborConfigReplayResult == false) {
replaySucceded = false;
}
} else {
LOG.error("no Neighbors present for replay config ");
}
Logging logging = config.getLogging();
if (logging != null) {
try {
br.setLogging(logging.getFile(), logging.getLevel());
} catch (TException | BgpRouterException e) {
LOG.error("Replay:setLogging() received exception", e);
}
}
GracefulRestart gracefulRestart = config.getGracefulRestart();
bgpGrRestartTime = ((gracefulRestart != null) ? gracefulRestart.getStalepathTime().intValue() : bgpGrRestartTime);
try {
br.addGracefulRestart(bgpGrRestartTime);
} catch (Exception e) {
LOG.error("Replay:addGr() received exception: ", e);
}
Map<VrfsKey, Vrfs> keyVrfsMap = config.getVrfsContainer() == null ? null : config.getVrfsContainer().getVrfs();
if (keyVrfsMap == null) {
keyVrfsMap = new HashMap<VrfsKey, Vrfs>();
}
for (Vrfs vrf : keyVrfsMap.values()) {
for (AddressFamiliesVrf adf : vrf.getAddressFamiliesVrf().values()) {
try {
br.addVrf(BgpUtil.getLayerType(adf), vrf.getRd(), vrf.getImportRts(), vrf.getExportRts(), adf.getAfi().toJava(), adf.getSafi().toJava());
} catch (TException | BgpRouterException e) {
LOG.error("Replay:addVrf() received exception", e);
}
}
}
Map<NetworksKey, Networks> keyNetworksMap = config.getNetworksContainer() == null ? null : config.getNetworksContainer().getNetworks();
if (keyNetworksMap != null) {
for (Networks net : keyNetworksMap.values()) {
String rd = net.getRd();
String pfxlen = net.getPrefixLen();
String nh = net.getNexthop().getValue();
Long label = net.getLabel().toJava();
int lbl = label == null ? 0 : label.intValue();
int l3vni = net.getL3vni() == null ? 0 : net.getL3vni().intValue();
int l2vni = net.getL2vni() == null ? 0 : net.getL2vni().intValue();
if (rd == null && lbl > 0) {
// LU prefix is being deleted.
rd = Integer.toString(lbl);
}
BgpControlPlaneType protocolType = net.getBgpControlPlaneType();
int ethernetTag = net.getEthtag().intValue();
String esi = net.getEsi();
String macaddress = net.getMacaddress();
EncapType encapType = net.getEncapType();
String routerMac = net.getRoutermac();
try {
br.addPrefix(rd, pfxlen, nh, lbl, l3vni, l2vni, BgpUtil.convertToThriftProtocolType(protocolType), ethernetTag, esi, macaddress, BgpUtil.convertToThriftEncapType(encapType), routerMac);
} catch (TException | BgpRouterException e) {
LOG.error("Replay:addPfx() received exception", e);
}
}
}
Map<MultipathKey, Multipath> keyMultipathMap = config.getMultipathContainer() == null ? null : config.getMultipathContainer().getMultipath();
if (keyMultipathMap != null) {
for (Multipath multipath : keyMultipathMap.values()) {
if (multipath != null) {
af_afi afi = af_afi.findByValue(multipath.getAfi().intValue());
af_safi safi = af_safi.findByValue(multipath.getSafi().intValue());
try {
if (multipath.isMultipathEnabled()) {
br.enableMultipath(afi, safi);
} else {
br.disableMultipath(afi, safi);
}
} catch (TException | BgpRouterException e) {
LOG.info("Replay:keyMultipathMap() received exception", e);
}
}
}
}
Map<VrfMaxpathKey, VrfMaxpath> keyVrfMaxpathMap = config.getVrfMaxpathContainer() == null ? null : config.getVrfMaxpathContainer().getVrfMaxpath();
if (keyVrfMaxpathMap != null) {
for (VrfMaxpath vrfMaxpath : keyVrfMaxpathMap.values()) {
try {
br.multipaths(vrfMaxpath.getRd(), vrfMaxpath.getMaxpaths().toJava());
} catch (TException | BgpRouterException e) {
LOG.info("Replay:vrfMaxPath() received exception", e);
}
}
}
// send End of Rib Marker to Qthriftd.
final int numberOfEORRetries = 3;
RetryOnException eorRetry = new RetryOnException(numberOfEORRetries);
do {
try {
br.sendEOR();
LOG.debug("Replay sendEOR() successful");
break;
} catch (Exception e) {
eorRetry.errorOccured();
LOG.error("Replay:sedEOR() received exception:", e);
}
} while (eorRetry.shouldRetry());
if (doRouteSync) {
LOG.debug("starting route sync for Thrift BGP_ERR_COMMON_FAILURE exception " + "happened earlier");
doRouteSync();
}
return replaySucceded;
}
Aggregations