private boolean deleteLabelRouteInfo(LabelRouteInfo lri, String vpnInstanceName) { LOG.debug("deleting LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName); InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class) .child(LabelRouteInfo.class, new LabelRouteInfoKey((long) lri.getLabel())).build(); if (lri == null) { return true; } List<String> vpnInstancesList = lri.getVpnInstanceList(); if (vpnInstancesList.contains(vpnInstanceName)) { LOG.debug("vpninstance {} name is present", vpnInstanceName); vpnInstancesList.remove(vpnInstanceName); } if (vpnInstancesList.size() == 0) { LOG.debug("deleting LRI instance object for label {}", lri.getLabel()); FibUtil.delete(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId); return true; } else { LOG.debug("updating LRI instance object for label {}", lri.getLabel()); LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri).setVpnInstanceList(vpnInstancesList); FibUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build(), FibUtil.DEFAULT_CALLBACK); } return false; }
if (vpnInstanceOpDataEntry != null) { List<String> vpnInstanceNames = Arrays.asList(vpnInstanceOpDataEntry.getVpnInstanceName()); lriBuilder.setVpnInstanceList(vpnInstanceNames);
private Prefixes updateVpnReferencesInLri(LabelRouteInfo lri, String vpnInstanceName, boolean isPresentInList) { LOG.debug("updating LRI : for label {} vpninstancename {}", lri.getLabel(), vpnInstanceName); PrefixesBuilder prefixBuilder = new PrefixesBuilder(); prefixBuilder.setDpnId(lri.getDpnId()); prefixBuilder.setVpnInterfaceName(lri.getVpnInterfaceName()); prefixBuilder.setIpAddress(lri.getPrefix()); // Increment the refCount here InstanceIdentifier<LabelRouteInfo> lriId = InstanceIdentifier.builder(LabelRouteMap.class) .child(LabelRouteInfo.class, new LabelRouteInfoKey((long)lri.getLabel())).build(); LabelRouteInfoBuilder builder = new LabelRouteInfoBuilder(lri); if (!isPresentInList) { LOG.debug("vpnName {} is not present in LRI with label {}..", vpnInstanceName, lri.getLabel()); List<String> vpnInstanceNames = lri.getVpnInstanceList(); vpnInstanceNames.add(vpnInstanceName); builder.setVpnInstanceList(vpnInstanceNames); FibUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId, builder.build(), FibUtil.DEFAULT_CALLBACK); } else { LOG.debug("vpnName {} is present in LRI with label {}..", vpnInstanceName, lri.getLabel()); } return prefixBuilder.build(); }