+
+ public void enableBfdFlag() {
+ enableBfdFlag = 1;
+ }
+
+ public void disableBfdFlag() {
+ enableBfdFlag = 0;
+ }
+
+ public boolean isBfdEnabled() {
+ if (enableBfdFlag == 1) {
+ return true;
+ } else if (enableBfdFlag == 0) {
+ return false;
+ }
+ BfdConfig bfdConfig = getBfdConfig();
+ if (bfdConfig != null) {
+ return bfdConfig.isBfdEnabled();
+ }
+ return false;
+ }
+
+ public BfdConfig getBfdConfig() {
+ InstanceIdentifier<BfdConfig> id =
+ InstanceIdentifier.builder(BfdConfig.class).build();
+ Optional<BfdConfig> bfdConfigOptional = Optional.empty();
+ try {
+ bfdConfigOptional = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, id);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("Exception while reading BfdConfig", e);
+ }
+ if (bfdConfigOptional.isPresent()) {
+ return bfdConfigOptional.get();
+ }
+ return null;
+ }
+
+ public DcgwTepList getDcgwTepConfig() {
+ InstanceIdentifier<DcgwTepList> id =
+ InstanceIdentifier.builder(Bgp.class).child(DcgwTepList.class).build();
+ Optional<DcgwTepList> dcgwTepListOptional = Optional.empty();
+ try {
+ dcgwTepListOptional = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, id);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("getDcgwTepConfig: Exception while reading DcgwTepList", e);
+ }
+ if (dcgwTepListOptional.isPresent()) {
+ return dcgwTepListOptional.get();
+ }
+ return null;
+ }
+
+ public List<String> getDcgwTepConfig(String dcgwIp) {
+ InstanceIdentifier<DcgwTep> id =
+ InstanceIdentifier.builder(Bgp.class)
+ .child(DcgwTepList.class)
+ .child(DcgwTep.class, new DcgwTepKey(dcgwIp)).build();
+ Optional<DcgwTep> tepListOptional = Optional.empty();
+ try {
+ tepListOptional = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, id);
+ } catch (ExecutionException | InterruptedException e) {
+ LOG.error("Exception while reading DcgwTep for the IP {}", dcgwIp, e);
+ }
+ if (tepListOptional.isPresent()) {
+ return tepListOptional.get().getTepIps();
+ }
+ LOG.debug("No tep configured for DCGW {}", dcgwIp);
+ return null;
+ }
+
+ public static List<DPNTEPsInfo> getDpnTEPsInfos(DataBroker dataBroker) {
+ InstanceIdentifier<DpnEndpoints> iid = InstanceIdentifier.builder(DpnEndpoints.class).build();
+ Optional<DpnEndpoints> dpnEndpoints = MDSALUtil.read(LogicalDatastoreType.CONFIGURATION, iid, dataBroker);
+ if (dpnEndpoints.isPresent()) {
+ return dpnEndpoints.get().getDPNTEPsInfo();
+ } else {
+ return new ArrayList<>();
+ }
+ }
+
+ public void removeOrUpdateLBGroups(String tepIp, int addRemoveOrUpdate) {
+ getDpnTEPsInfos(dataBroker).forEach(dpnInfo -> {
+ if (NwConstants.MOD_FLOW == addRemoveOrUpdate) {
+ LOG.debug("Updating bucket in DPN {}", dpnInfo.getDPNID());
+ } else if (NwConstants.DEL_FLOW == addRemoveOrUpdate) {
+ LOG.debug("Deleting groups in DPN {}", dpnInfo.getDPNID());
+ }
+ Class<? extends TunnelTypeBase> tunType = TunnelTypeMplsOverGre.class;
+ fibManager.programDcGwLoadBalancingGroup(dpnInfo.getDPNID(),
+ tepIp, addRemoveOrUpdate, false, tunType);
+ });
+ }