@Override public String apply(VpnInstance vpnInstance) { //return vpnInstance.getVpnInstanceName(); return vpnInstance.getIpv4Family().getRouteDistinguisher(); } };
return false; if (!Objects.equals(_ipv4Family, other.getIpv4Family())) { return false;
private List<String> getExportRts(VpnInstance vpnInstance) { List<String> exportRts = new ArrayList<>(); VpnAfConfig vpnConfig = vpnInstance.getIpv4Family(); VpnTargets targets = vpnConfig.getVpnTargets(); List<VpnTarget> vpnTargets = targets.getVpnTarget(); for (VpnTarget target : vpnTargets) { if (target.getVrfRTType().equals(VpnTarget.VrfRTType.ExportExtcommunity)) { String rtValue = target.getVrfRTValue(); exportRts.add(rtValue); } } return exportRts; }
private String getRouteDistinguisher(String vpnName) { InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class) .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build(); Optional<VpnInstance> vpnInstance = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id); String rd = ""; if(vpnInstance.isPresent()) { VpnInstance instance = vpnInstance.get(); VpnAfConfig config = instance.getIpv4Family(); rd = config.getRouteDistinguisher(); } return rd; }
private String getRouteDistinguisher(String vpnName) { InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class) .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build(); Optional<VpnInstance> vpnInstance = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id); String rd = ""; if(vpnInstance.isPresent()) { VpnInstance instance = vpnInstance.get(); VpnAfConfig config = instance.getIpv4Family(); rd = config.getRouteDistinguisher(); } return rd; }
private String getRouteDistinguisher(String vpnName) { InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class) .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build(); Optional<VpnInstance> vpnInstance = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id); String rd = null; if(vpnInstance.isPresent()) { VpnInstance instance = vpnInstance.get(); VpnAfConfig config = instance.getIpv4Family(); rd = config.getRouteDistinguisher(); } return rd; }
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)); }
@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 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()); } } }
/** * Get RouterDistinguisher by VpnName * * @param vpnName Name of the VPN Instance * @return the Route-Distinguisher */ private String getRouteDistinguisher(String vpnName) { InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class) .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build(); Optional<VpnInstance> vpnInstance = MDSALDataStoreUtils.read(broker, LogicalDatastoreType.CONFIGURATION, id); String rd = ""; if (vpnInstance.isPresent()) { VpnInstance instance = vpnInstance.get(); VpnAfConfig config = instance.getIpv4Family(); rd = config.getRouteDistinguisher(); } return rd; }
/** * Get VPN Route Distinguisher from VPN Instance Configuration * * @param broker dataBroker service reference * @param vpnName Name of the VPN * @return the route-distinguisher of the VPN */ public static String getVpnRdFromVpnInstanceConfig(DataBroker broker, String vpnName) { InstanceIdentifier<VpnInstance> id = InstanceIdentifier.builder(VpnInstances.class) .child(VpnInstance.class, new VpnInstanceKey(vpnName)).build(); Optional<VpnInstance> vpnInstance = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id); String rd = null; if (vpnInstance.isPresent()) { VpnInstance instance = vpnInstance.get(); VpnAfConfig config = instance.getIpv4Family(); rd = config.getRouteDistinguisher(); } return rd; }
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; }
@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)); }
void handleVpnsExportingRoutes(String vpnName, String vpnRd) { List<VpnInstance> vpnsToExportRoute = getVpnsExportingMyRoute(vpnName); for (VpnInstance vpn : vpnsToExportRoute) { String rd = vpn.getIpv4Family().getRouteDistinguisher(); List<VrfEntry> vrfEntries = VpnUtil.getAllVrfEntries(dataBroker, vpn.getIpv4Family().getRouteDistinguisher()); WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction(); if (vrfEntries != null) { LOG.info("No vrf entries to import from vpn {} with rd {}", vpn.getVpnInstanceName(), vpn.getIpv4Family().getRouteDistinguisher());
String vpnRd = vpn.getIpv4Family().getRouteDistinguisher(); if (vpnRd != null) { LOG.info("Removing Exported route with rd {} prefix {} from VPN {}", vpnRd, nextHop.getIpAddress(), vpn.getVpnInstanceName());
@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); WriteTransaction writeTxn = broker.newWriteOnlyTransaction();
String rd = del.getIpv4Family().getRouteDistinguisher();
VpnInstance value) { LOG.trace("VPN Instance key: {}, value: {}", identifier, value); VpnAfConfig config = value.getIpv4Family(); String rd = config.getRouteDistinguisher();
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(); VrfTables importingVrfTable = new VrfTablesBuilder().setRouteDistinguisher(importingRd).setVrfEntry(importingVrfEntryList).build();