@Override public String apply(VpnInstance vpnInstance) { return vpnInstance.getVpnInstanceName(); } };
@Override public boolean apply(VpnInstance input) { return !input.getVpnInstanceName().equals(vpnName); } };
@Override public boolean apply(VpnInstance input) { return !input.getVpnInstanceName().equals(vpnName); } };
return false; if (!Objects.equals(_vpnInstanceName, other.getVpnInstanceName())) { return false;
public VpnInstanceBuilder(VpnInstance base) { if (base.getKey() == null) { this._key = new VpnInstanceKey( base.getVpnInstanceName() ); this._vpnInstanceName = base.getVpnInstanceName(); } else { this._key = base.getKey(); this._vpnInstanceName = _key.getVpnInstanceName(); } this._description = base.getDescription(); this._ipv4Family = base.getIpv4Family(); this._ipv6Family = base.getIpv6Family(); if (base instanceof VpnInstanceImpl) { VpnInstanceImpl impl = (VpnInstanceImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
@Override public List<ListenableFuture<Void>> call() throws Exception { // If another renderer(for eg : CSS) needs to be supported, check can be performed here // to call the respective helpers. final VpnAfConfig config = vpnInstance.getIpv4Family(); final String rd = config.getRouteDistinguisher(); WriteTransaction writeConfigTxn = broker.newWriteOnlyTransaction(); WriteTransaction writeOperTxn = broker.newWriteOnlyTransaction(); addVpnInstance(vpnInstance, writeConfigTxn, writeOperTxn); CheckedFuture<Void, TransactionCommitFailedException> checkFutures = writeOperTxn.submit(); try { checkFutures.get(); } catch (InterruptedException | ExecutionException e) { LOG.error("Error creating vpn {} ", vpnInstance.getVpnInstanceName()); throw new RuntimeException(e.getMessage()); } List<ListenableFuture<Void>> futures = new ArrayList<>(); futures.add(writeConfigTxn.submit()); ListenableFuture<List<Void>> listenableFuture = Futures.allAsList(futures); if (rd != null) { Futures.addCallback(listenableFuture, new AddBgpVrfWorker(config , vpnInstance.getVpnInstanceName())); } return futures; } }
public synchronized void deleteSubnetRouteFibEntryFromDS(String rd, String prefix, String vpnName){ fibManager.removeFibEntry(dataBroker, rd, prefix, null); List<VpnInstance> vpnsToImportRoute = getVpnsImportingMyRoute(vpnName); for (VpnInstance vpnInstance : vpnsToImportRoute) { String importingRd = vpnInstance.getIpv4Family().getRouteDistinguisher(); LOG.info("Deleting imported subnet route rd {} prefix {} from vpn {}", rd, prefix, vpnInstance.getVpnInstanceName()); fibManager.removeFibEntry(dataBroker, importingRd, prefix, null); } }
@Override protected void add(final InstanceIdentifier<VpnInstance> identifier, final VpnInstance value) { LOG.trace("Add VPN event key: {}, value: {}", identifier, value); final VpnAfConfig config = value.getIpv4Family(); final String rd = config.getRouteDistinguisher(); final String vpnName = value.getVpnInstanceName(); DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance(); dataStoreCoordinator.enqueueJob("VPN-" + vpnName, new AddVpnInstanceWorker(idManager, vpnInterfaceManager, dataBroker, value)); }
private List<String> getRts(VpnInstance vpnInstance, VpnTarget.VrfRTType rtType) { String name = vpnInstance.getVpnInstanceName(); List<String> rts = new ArrayList<>(); VpnAfConfig vpnConfig = vpnInstance.getIpv4Family(); if (vpnConfig == null) { LOG.trace("vpn config is not available for {}", name); return rts; } VpnTargets targets = vpnConfig.getVpnTargets(); if (targets == null) { LOG.trace("vpn targets not available for {}", name); return rts; } List<VpnTarget> vpnTargets = targets.getVpnTarget(); if (vpnTargets == null) { LOG.trace("vpnTarget values not available for {}", name); return rts; } for (VpnTarget target : vpnTargets) { //TODO: Check for RT type is Both if(target.getVrfRTType().equals(rtType) || target.getVrfRTType().equals(VpnTarget.VrfRTType.Both)) { String rtValue = target.getVrfRTValue(); rts.add(rtValue); } } return rts; }
String rd = config.getRouteDistinguisher(); long vpnId = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, value.getVpnInstanceName()); LOG.trace("VPN instance to ID generated."); org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance vpnInstanceToVpnId = VpnUtil.getVpnInstanceToVpnId(value.getVpnInstanceName(), vpnId, (rd != null) ? rd : value.getVpnInstanceName()); VpnUtil.getVpnInstanceToVpnIdIdentifier(value.getVpnInstanceName()), vpnInstanceToVpnId, DEFAULT_CALLBACK); VpnUtil.getVpnInstanceOpDataIdentifier(value.getVpnInstanceName()), VpnUtil.getVpnInstanceOpDataBuilder(value.getVpnInstanceName(), vpnId), DEFAULT_CALLBACK); List<VpnInterface> vpnInterfaces = optionalVpnInterfaces.get().getVpnInterface(); for(VpnInterface vpnInterface : vpnInterfaces) { if(vpnInterface.getVpnInstanceName().equals(value.getVpnInstanceName())) { LOG.debug("VpnInterface {} will be added from VPN {}", vpnInterface.getName(), value.getVpnInstanceName()); vpnInterfaceManager.add( VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface);
@Override protected void remove(InstanceIdentifier<VpnInstance> identifier, VpnInstance del) { LOG.trace("Remove VPN event key: {}, value: {}", identifier, del); final String vpnName = del.getVpnInstanceName(); final String rd = del.getIpv4Family().getRouteDistinguisher(); final long vpnId = VpnUtil.getVpnId(dataBroker, vpnName); Optional<VpnInstanceOpDataEntry> vpnOpValue = null; //TODO(vpnteam): Entire code would need refactoring to listen only on the parent object - VPNInstance try { if ((rd != null) && (!rd.isEmpty())) { vpnOpValue = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(rd)); } else { vpnOpValue = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getVpnInstanceOpDataIdentifier(vpnName)); } } catch (Exception e) { LOG.error("Exception when attempting to retrieve VpnInstanceOpDataEntry for VPN {}. ", vpnName, e); return; } if (vpnOpValue == null || !vpnOpValue.isPresent()) { LOG.error("Unable to retrieve VpnInstanceOpDataEntry for VPN {}. ", vpnName); return; } DataStoreJobCoordinator dataStoreCoordinator = DataStoreJobCoordinator.getInstance(); dataStoreCoordinator.enqueueJob("VPN-" + vpnName, new DeleteVpnInstanceWorker(idManager, dataBroker, del)); }
for (String nh : nextHops) { if (route != null) { LOG.info("Importing subnet route fib entry rd {} prefix {} nexthop {} label {} to vpn {}", vpnRd, prefix, nh, label, vpn.getVpnInstanceName()); importSubnetRouteForNewVpn(rd, prefix, nh, (int)label, route, writeConfigTxn); } else { LOG.info("Importing fib entry rd {} prefix {} nexthop {} label {} to vpn {}", vpnRd, prefix, nh, label, vpn.getVpnInstanceName()); fibManager.addOrUpdateFibEntry(dataBroker, vpnRd, prefix, Arrays.asList(nh), (int)label, RouteOrigin.SELF_IMPORTED, writeConfigTxn); LOG.error("Exception occurred while importing route with prefix {} label {} nexthop {} from vpn {} to vpn {}", vrfEntry.getDestPrefix(), vrfEntry.getLabel(), vrfEntry.getNextHopAddressList(), vpn.getVpnInstanceName(), vpnName); LOG.info("No vrf entries to import from vpn {} with rd {}", vpn.getVpnInstanceName(), vpn.getIpv4Family().getRouteDistinguisher());
String rd = vpnConfig.getRouteDistinguisher(); if (rd == null || rd.isEmpty()) { rd = vpnInstance.getVpnInstanceName(); LOG.error("updatePrefixesForDPN {} in vpn {} failed", dpnId, vpnInstance.getVpnInstanceName(), e);
String vpnRd = vpn.getIpv4Family().getRouteDistinguisher(); if (vpnRd != null) { LOG.info("Removing Exported route with rd {} prefix {} from VPN {}", vpnRd, nextHop.getIpAddress(), vpn.getVpnInstanceName()); fibManager.removeOrUpdateFibEntry(dataBroker, vpnRd, nextHop.getIpAddress(), nh, writeConfigTxn);
@Override public List<ListenableFuture<Void>> call() throws Exception { final String vpnName = vpnInstance.getVpnInstanceName(); final String rd = vpnInstance.getIpv4Family().getRouteDistinguisher(); final long vpnId = VpnUtil.getVpnId(broker, vpnName);
VpnInstance vpnInstance = vpnInstIter.next(); LOG.trace("vpnInstance {}", vpnInstance); vpnId = VpnUtil.getVpnId(dataBroker, vpnInstance.getVpnInstanceName()); try { VpnAfConfig vpnConfig = vpnInstance.getIpv4Family(); String rd = vpnConfig.getRouteDistinguisher(); if (rd == null || rd.isEmpty()) { rd = vpnInstance.getVpnInstanceName(); LOG.trace("rd is null or empty. Assigning VpnInstanceName to rd {}", rd); destDpnInVpn.isPresent())) { LOG.trace(" srcDpn {} - destDPN {}, do not share the VPN {} with rd {}.", srcDpnId, destDpnId, vpnInstance.getVpnInstanceName(), rd); continue; new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId()), new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId()), VpnUtil.getVpnId(dataBroker, vpnInstance.getVpnInstanceName()), rd, adjacency.getIpAddress(), srcTepIp, destTepIp); LOG.error("updatePrefixesForDPN {} in vpn {} failed", 0, vpnInstance.getVpnInstanceName(), e);
@Override protected void remove(InstanceIdentifier<VpnInstance> identifier, VpnInstance del) { LOG.trace("Remove VPN event - Key: {}, value: {}", identifier, del); String vpnName = del.getVpnInstanceName();
Uuid vpnId = new Uuid(vpnInstance.getVpnInstanceName());
VpnAfConfig config = value.getIpv4Family(); String rd = config.getRouteDistinguisher(); String vpnInstanceName = value.getVpnInstanceName(); VpnIds vpnIdToVpnInstance = VpnUtil.getVpnIdToVpnInstance(vpnId, value.getVpnInstanceName(), (rd != null) ? rd : value.getVpnInstanceName(), (rd != null)/*isExternalVpn*/);
List<VrfEntry> importingVrfEntryList = Arrays.asList(importingVrfEntry); for (VpnInstance vpnInstance : vpnsToImportRoute) { LOG.info("Exporting subnet route rd {} prefix {} nexthop {} label {} to vpn {}", rd, prefix, nextHop, label, vpnInstance.getVpnInstanceName()); String importingRd = vpnInstance.getIpv4Family().getRouteDistinguisher(); InstanceIdentifier<VrfTables> importingVrfTableId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(importingRd)).build();