use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class VrfListener method programLabelInAllVpnDpns.
/**
* Adds or Removes a VPN's route in all the DPNs where the VPN has footprint.
*
* @param vpnRd Route-Distinguisher of the VPN
* @param vrfEntry The route to add or remove
* @param addOrRemove States if the route must be added or removed
*/
protected void programLabelInAllVpnDpns(String vpnRd, VrfEntry vrfEntry, int addOrRemove) {
Long vpnPseudoLPortTag = vpnPseudoPortCache.get(vpnRd);
if (vpnPseudoLPortTag == null) {
LOG.debug("Vpn with rd={} not related to any VpnPseudoPort", vpnRd);
return;
}
Optional<VpnInstanceOpDataEntry> vpnOpData = VpnServiceChainUtils.getVpnInstanceOpData(broker, vpnRd);
if (!vpnOpData.isPresent()) {
if (addOrRemove == NwConstants.ADD_FLOW) {
LOG.error("VrfEntry added: Could not find operational data for VPN with RD={}", vpnRd);
} else {
LOG.warn("VrfEntry removed: No Operational data found for VPN with RD={}. No further action", vpnRd);
}
return;
}
Collection<VpnToDpnList> vpnToDpnList = vpnOpData.get().getVpnToDpnList();
if (vpnToDpnList == null || vpnToDpnList.isEmpty()) {
LOG.warn("Empty VpnToDpnlist found in Operational for VPN with RD={}. No label will be {}", vpnRd, addOrRemove == NwConstants.ADD_FLOW ? "programmed" : "cleaned");
return;
}
for (VpnToDpnList dpnInVpn : vpnToDpnList) {
BigInteger dpnId = dpnInVpn.getDpnId();
VpnServiceChainUtils.programLFibEntriesForSCF(mdsalMgr, dpnId, Collections.singletonList(vrfEntry), (int) vpnPseudoLPortTag.longValue(), addOrRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class VPNServiceChainHandlerTest method stubGetVpnInstance.
private void stubGetVpnInstance(String rd, String ipAddress, String ifaceName) throws Exception {
IpAddresses ipAddr = new IpAddressesBuilder().setIpAddress(ipAddress).setKey(new IpAddressesKey(ipAddress)).build();
List<VpnInterfaces> ifacesList = Collections.singletonList(new VpnInterfacesBuilder().setInterfaceName(ifaceName).build());
VpnToDpnListBuilder vtdlb = new VpnToDpnListBuilder().setKey(new VpnToDpnListKey(DPN_ID)).setDpnId(DPN_ID).setIpAddresses(Collections.singletonList(ipAddr)).setVpnInterfaces(ifacesList);
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = new VpnInstanceOpDataEntryBuilder().setKey(new VpnInstanceOpDataEntryKey(rd)).setVpnId(VPN_ID).setVpnToDpnList(Collections.singletonList(vtdlb.build())).setVrfId("1").build();
CheckedFuture chkdFuture = mock(CheckedFuture.class);
when(chkdFuture.checkedGet()).thenReturn(Optional.of(vpnInstanceOpDataEntry));
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(VpnServiceChainUtils.getVpnInstanceOpDataIdentifier(rd)))).thenReturn(chkdFuture);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class VPNServiceChainHandlerTest method stubNoVpnInstanceForRD.
private void stubNoVpnInstanceForRD(String rd) throws Exception {
CheckedFuture<Optional<VpnInstanceOpDataEntry>, ReadFailedException> chkdFuture = mock(CheckedFuture.class);
when(chkdFuture.checkedGet()).thenReturn(Optional.absent());
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.create(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd));
when(readTx.read(eq(LogicalDatastoreType.OPERATIONAL), eq(id))).thenReturn(chkdFuture);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class VPNServiceChainHandler method programVpnToScfPipeline.
/**
* Programs the necessary flows in LFIB and LPortDispatcher table so that
* the packets coming from a given VPN are delivered to a given
* ServiceChain Pipeline.
*
* @param vpnName Name of the VPN. Typically the UUID
* @param tableId Table to which the LPortDispatcher table sends the packet
* to (Uplink or Downlink Subsc table)
* @param scfTag Scf tag to the SCF to which the Vpn is linked to.
* @param lportTag VpnPseudo Port lportTag
* @param addOrRemove States if the VPN2SCF Pipeline must be installed or
* removed
*/
public void programVpnToScfPipeline(String vpnName, short tableId, long scfTag, int lportTag, int addOrRemove) {
// This entries must be created in the DPN where the CGNAT is installed. Since it is not possible
// to know where CGNAT is located, this entries are installed in all the VPN footprint.
// LFIB:
// - Match: cgnatLabel Instr: lportTag=vpnPseudoPortTag + SI=SCF + GOTO 17
// LportDisp:
// - Match: vpnPseudoPortTag + SI==SCF Instr: scfTag + GOTO 70
LOG.info("programVpnToScfPipeline ({}) : Parameters VpnName:{} tableId:{} scftag:{} lportTag:{}", addOrRemove == NwConstants.ADD_FLOW ? "Creation" : "Removal", vpnName, tableId, scfTag, lportTag);
String rd = VpnServiceChainUtils.getVpnRd(dataBroker, vpnName);
LOG.debug("Router distinguisher (rd):{}", rd);
if (rd == null || rd.isEmpty()) {
LOG.warn("programVpnToScfPipeline: Could not find Router-distinguisher for VPN {}. No further actions", vpnName);
return;
}
VpnInstanceOpDataEntry vpnInstance = getVpnInstance(rd);
if (vpnInstance == null) {
LOG.warn("Could not find a suitable VpnInstance for Route-Distinguisher={}", rd);
return;
}
// Find out the set of DPNs for the given VPN ID
Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
List<VrfEntry> vrfEntries = VpnServiceChainUtils.getAllVrfEntries(dataBroker, rd);
if (vrfEntries != null) {
if (addOrRemove == NwConstants.ADD_FLOW) {
AddVpnPseudoPortDataJob updateVpnToPseudoPortTask = new AddVpnPseudoPortDataJob(dataBroker, rd, lportTag, tableId, (int) scfTag);
jobCoordinator.enqueueJob(updateVpnToPseudoPortTask.getDsJobCoordinatorKey(), updateVpnToPseudoPortTask);
} else {
RemoveVpnPseudoPortDataJob removeVpnPseudoPortDataTask = new RemoveVpnPseudoPortDataJob(dataBroker, rd);
jobCoordinator.enqueueJob(removeVpnPseudoPortDataTask.getDsJobCoordinatorKey(), removeVpnPseudoPortDataTask);
}
for (VpnToDpnList dpnInVpn : vpnToDpnList) {
BigInteger dpnId = dpnInVpn.getDpnId();
programVpnToScfPipelineOnDpn(dpnId, vrfEntries, tableId, (int) scfTag, lportTag, addOrRemove);
if (dpnInVpn.getVpnInterfaces() != null) {
long vpnId = vpnInstance.getVpnId();
Flow flow = VpnServiceChainUtils.buildLPortDispFromScfToL3VpnFlow(vpnId, dpnId, lportTag, NwConstants.ADD_FLOW);
if (addOrRemove == NwConstants.ADD_FLOW) {
mdsalManager.installFlow(dpnId, flow);
} else {
mdsalManager.removeFlow(dpnId, flow);
}
dpnInVpn.getVpnInterfaces().forEach(vpnIf -> {
if (addOrRemove == NwConstants.ADD_FLOW) {
bindScfOnVpnInterface(vpnIf.getInterfaceName(), (int) scfTag);
} else {
unbindScfOnVpnInterface(vpnIf.getInterfaceName());
}
});
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class NeutronvpnUtils method updateVpnInstanceOpWithType.
public void updateVpnInstanceOpWithType(VpnInstanceOpDataEntry.BgpvpnType choice, @Nonnull Uuid vpn) {
String primaryRd = getVpnRd(vpn.getValue());
if (primaryRd == null) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "Primary RD not found", choice, vpn.getValue());
return;
}
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(primaryRd)).build();
Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional = read(LogicalDatastoreType.OPERATIONAL, id);
if (!vpnInstanceOpDataEntryOptional.isPresent()) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry not found", choice, vpn.getValue());
return;
}
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = vpnInstanceOpDataEntryOptional.get();
if (vpnInstanceOpDataEntry.getBgpvpnType().equals(choice)) {
LOG.debug("updateVpnInstanceOpWithType: Update BgpvpnType {} for {}." + "VpnInstanceOpDataEntry already set", choice, vpn.getValue());
return;
}
VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
builder.setBgpvpnType(choice);
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
try {
writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("updateVpnInstanceOpWithType: on merge execution, error: {}", e);
}
return;
}
Aggregations