import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
import org.opendaylight.infrautils.metrics.MetricProvider;
private static final String UPD_WARN = "Update operation not supported; Config store updated;"
+ " restore with another Update if needed.";
private static long bgp_as_num = 0;
+ private static List<Neighbors> nbrList = new ArrayList<>();
private int bgpKaTime = 0;
private int bgpHoldTime = 0;
private int bgpGrRestartTime = 0;
@Override
protected void add(InstanceIdentifier<Neighbors> iid, Neighbors val) {
+ if (nbrList != null && !nbrList.contains(val)) {
+ LOG.trace("Adding nbr {} to nbrlist", val.getAddress().getValue());
+ nbrList.add(val);
+ }
if (!isBGPEntityOwner()) {
return;
}
LOG.debug("received add Neighbors config val {}", val.getAddress().getValue());
synchronized (BgpConfigurationManager.this) {
String peerIp = val.getAddress().getValue();
+ String sourceIp = (val.getUpdateSource() == null) ? null :
+ val.getUpdateSource().getSourceIp().getValue();
+ int nhops = (val.getEbgpMultihop() == null) ? 0 :
+ val.getEbgpMultihop().getNhops().intValue();
+ List<AddressFamilies> afs = val.getAddressFamilies();
long as = val.getRemoteAs().toJava();
final String md5Secret = extractMd5Secret(val);
BgpRouter br = getClient(YANG_OBJ);
try {
//itmProvider.buildTunnelsToDCGW(new IpAddress(peerIp.toCharArray()));
br.addNeighbor(peerIp, as, md5Secret);
+ if (nhops != 0) {
+ br.addEbgpMultihop(peerIp, nhops);
+ }
+ if (sourceIp != null) {
+ br.addUpdateSource(peerIp, sourceIp);
+ }
+ if (afs != null) {
+ for (AddressFamilies af : afs) {
+ af_afi afi = af_afi.findByValue(af.getAfi().intValue());
+ af_safi safi = af_safi.findByValue(af.getSafi().intValue());
+ br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
+ }
+ }
} catch (TException | BgpRouterException e) {
LOG.error("{} Add received exception; {}", YANG_OBJ, ADD_WARN, e);
@Override
protected void remove(InstanceIdentifier<Neighbors> iid, Neighbors val) {
+ if (nbrList != null && nbrList.contains(val)) {
+ LOG.trace("Removing nbr {} from nbr list", val.getAddress().getValue());
+ nbrList.remove(val);
+ }
if (!isBGPEntityOwner()) {
return;
}
public long getStalePathtime(int defValue, AsId asId) {
long spt = 0;
try {
- spt = getConfig().getGracefulRestart().getStalepathTime().toJava();
+ InstanceIdentifier<GracefulRestart> id =
+ InstanceIdentifier.create(Bgp.class).child(GracefulRestart.class);
+ Optional<GracefulRestart> gracefulRestartOptional = MDSALUtil.read(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, id);
+ if (gracefulRestartOptional.isPresent()) {
+ spt = gracefulRestartOptional.get().getStalepathTime().toJava();
+ }
} catch (NullPointerException e) {
try {
spt = asId.getStalepathTime().toJava();
return totalCleared;
}
+ public static List<Neighbors> getNbrList() {
+ return nbrList;
+ }
+
public BgpCounters getBgpCounters() {
return bgpCountersReference.get();
}