use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class VpnSubnetRouteHandler method deleteSubnetRouteFibEntryFromDS.
public void deleteSubnetRouteFibEntryFromDS(String rd, String prefix, String vpnName) {
fibManager.removeFibEntry(rd, prefix, null);
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
for (VpnInstanceOpDataEntry vpnInstance : vpnsToImportRoute) {
String importingRd = vpnInstance.getVrfId();
fibManager.removeFibEntry(importingRd, prefix, null);
LOG.info("SUBNETROUTE: deleteSubnetRouteFibEntryFromDS: Deleted imported subnet route rd {} prefix {}" + " from vpn {} importingRd {}", rd, prefix, vpnInstance.getVpnInstanceName(), importingRd);
}
LOG.info("SUBNETROUTE: deleteSubnetRouteFibEntryFromDS: Removed subnetroute FIB for prefix {} rd {}" + " vpnName {}", prefix, rd, vpnName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class L3vpnOverMplsGrePopulator method populateFib.
@Override
public void populateFib(L3vpnInput input, WriteTransaction writeConfigTxn) {
if (input.getRouteOrigin() == RouteOrigin.CONNECTED) {
LOG.info("populateFib : Found SubnetRoute for subnet {} rd {}", input.getSubnetIp(), input.getPrimaryRd());
addSubnetRouteFibEntry(input);
return;
}
Adjacency nextHop = input.getNextHop();
long label = nextHop.getLabel();
String vpnName = input.getVpnName();
String primaryRd = input.getPrimaryRd();
String rd = input.getRd();
String nextHopIp = input.getNextHopIp();
VrfEntry.EncapType encapType = input.getEncapType();
LOG.info("populateFib : Found Interface Adjacency with prefix {} rd {}", nextHop.getIpAddress(), primaryRd);
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
long vpnId = VpnUtil.getVpnId(broker, vpnName);
// it is a valid case for nextHopIpAddress to be null
String nextHopIpAddress = nextHop.getIpAddress();
// and internalVpnForExtraRoute (where rd is DpnId)
if (VpnUtil.isEligibleForBgp(primaryRd, input.getVpnName(), input.getDpnId(), input.getNetworkName())) {
// the DpnId is set as rd in case of extra routes present in router based VPN
addToLabelMapper(label, input.getDpnId(), nextHopIpAddress, Arrays.asList(nextHopIp), vpnId, input.getInterfaceName(), null, false, primaryRd);
Objects.requireNonNull(input.getRouteOrigin(), "RouteOrigin is mandatory");
addPrefixToBGP(rd, primaryRd, null, /*macAddress*/
nextHopIpAddress, nextHopIp, encapType, label, 0, /*l3vni*/
input.getGatewayMac(), input.getRouteOrigin(), writeConfigTxn);
// TODO: ERT - check for VPNs importing my route
for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
String vpnRd = vpn.getVrfId();
if (vpnRd != null) {
fibManager.addOrUpdateFibEntry(vpnRd, null, /*macAddress*/
nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
input.getGatewayMac(), null, /*parentVpnRd*/
RouteOrigin.SELF_IMPORTED, writeConfigTxn);
LOG.info("populateFib: Exported route with rd {} prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nextHopIp, label, vpn, input.getInterfaceName(), input.getDpnId());
}
}
} else {
// ### add FIB route directly
fibManager.addOrUpdateFibEntry(vpnName, null, /*macAddress*/
nextHopIpAddress, Arrays.asList(nextHopIp), encapType, (int) label, 0, /*l3vni*/
input.getGatewayMac(), null, /*parentVpnRd*/
input.getRouteOrigin(), writeConfigTxn);
LOG.info("populateFib: Added internal FIB entry for prefix {} nexthop {} label {}" + " to VPN {} for interface {} on dpn {}", nextHop.getIpAddress(), nextHopIp, label, vpnName, input.getInterfaceName(), input.getDpnId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class L3vpnPopulator method addSubnetRouteFibEntry.
public void addSubnetRouteFibEntry(L3vpnInput input) {
String rd = input.getRd();
String vpnName = input.getVpnName();
String prefix = input.getSubnetIp();
String nextHop = input.getNextHopIp();
long label = input.getLabel();
long l3vni = input.getL3vni();
long elantag = input.getElanTag();
BigInteger dpnId = input.getDpnId();
String networkName = input.getNetworkName();
String gwMacAddress = input.getGatewayMac();
SubnetRoute route = new SubnetRouteBuilder().setElantag(elantag).build();
// Only case when a route is considered as directly connected
RouteOrigin origin = RouteOrigin.CONNECTED;
VrfEntry vrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, origin, networkName).addAugmentation(SubnetRoute.class, route).setL3vni(l3vni).setGatewayMacAddress(gwMacAddress).build();
LOG.debug("Created vrfEntry for {} nexthop {} label {} and elantag {}", prefix, nextHop, label, elantag);
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(prefix)).build();
Optional<VrfEntry> entry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (!entry.isPresent()) {
List<VrfEntry> vrfEntryList = Collections.singletonList(vrfEntry);
InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
InstanceIdentifier<VrfTables> vrfTableId = idBuilder.build();
VrfTables vrfTableNew = new VrfTablesBuilder().setRouteDistinguisher(rd).setVrfEntry(vrfEntryList).build();
VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfTableId, vrfTableNew);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Added vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
} else {
// Found in MDSAL database
VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Updated vrfEntry for {} nexthop {} label {} rd {}" + " vpnName {}", prefix, nextHop, label, rd, vpnName);
}
// Will be handled appropriately with the iRT patch for EVPN
if (input.getEncapType().equals(VrfEntryBase.EncapType.Mplsgre)) {
long vpnId = VpnUtil.getVpnId(broker, vpnName);
addToLabelMapper(label, dpnId, prefix, Collections.singletonList(nextHop), vpnId, null, elantag, true, rd);
List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(broker, vpnName);
if (vpnsToImportRoute.size() > 0) {
VrfEntry importingVrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, RouteOrigin.SELF_IMPORTED, networkName).addAugmentation(SubnetRoute.class, route).build();
List<VrfEntry> importingVrfEntryList = Collections.singletonList(importingVrfEntry);
for (VpnInstanceOpDataEntry vpnInstance : vpnsToImportRoute) {
String importingRd = vpnInstance.getVrfId();
InstanceIdentifier<VrfTables> importingVrfTableId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(importingRd)).build();
VrfTables importingVrfTable = new VrfTablesBuilder().setRouteDistinguisher(importingRd).setVrfEntry(importingVrfEntryList).build();
VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, importingVrfTableId, importingVrfTable);
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Exported route rd {} prefix {} nexthop {}" + " label {} to vpn {} importingRd {}", rd, prefix, nextHop, label, vpnInstance.getVpnInstanceName(), importingRd);
}
}
}
LOG.info("SUBNETROUTE: addSubnetRouteFibEntryToDS: Created vrfEntry for {} nexthop {} label {} and elantag {}" + "rd {} vpnName {}", prefix, nextHop, label, elantag, rd, vpnName);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class ShowVpnInstanceOpData method getVpnInstanceOpData.
private void getVpnInstanceOpData() {
List<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryList = new ArrayList<>();
InstanceIdentifier<VpnInstances> vpnsIdentifier = InstanceIdentifier.builder(VpnInstances.class).build();
InstanceIdentifier<VpnInstanceOpData> vpnInstanceOpDataEntryIdentifier = InstanceIdentifier.builder(VpnInstanceOpData.class).build();
Optional<VpnInstances> optionalVpnInstances = read(LogicalDatastoreType.CONFIGURATION, vpnsIdentifier);
if (!optionalVpnInstances.isPresent() || optionalVpnInstances.get().getVpnInstance() == null || optionalVpnInstances.get().getVpnInstance().isEmpty()) {
LOG.trace("No VPNInstances configured.");
session.getConsole().println("No VPNInstances configured.");
} else {
vpnInstanceList = optionalVpnInstances.get().getVpnInstance();
}
Optional<VpnInstanceOpData> optionalOpData = read(LogicalDatastoreType.OPERATIONAL, vpnInstanceOpDataEntryIdentifier);
if (!optionalOpData.isPresent()) {
LOG.trace("No VPNInstanceOpDataEntry present.");
session.getConsole().println("No VPNInstanceOpDataEntry present.");
} else {
vpnInstanceOpDataEntryList = optionalOpData.get().getVpnInstanceOpDataEntry();
}
for (VpnInstanceOpDataEntry vpnInstanceOpDataEntry : vpnInstanceOpDataEntryList) {
vpnInstanceOpDataEntryMap.put(vpnInstanceOpDataEntry.getVpnInstanceName(), vpnInstanceOpDataEntry);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry in project netvirt by opendaylight.
the class ShowVpnInstanceOpData method doExecute.
@Override
protected Object doExecute() {
if (detail == null) {
getVpnInstanceOpData();
session.getConsole().println("For following vpnInstances vpnInstanceOpDataEntry is present: \n");
for (VpnInstance vpnInstance : vpnInstanceList) {
VpnInstanceOpDataEntry check = vpnInstanceOpDataEntryMap.get(vpnInstance.getVpnInstanceName());
if (check != null) {
session.getConsole().println(vpnInstance.getVpnInstanceName() + "\n");
}
}
session.getConsole().println("\n\nFor following vpnInstances vpnInstanceOpDataEntry is not present: \n");
for (VpnInstance vpnInstance : vpnInstanceList) {
VpnInstanceOpDataEntry check = vpnInstanceOpDataEntryMap.get(vpnInstance.getVpnInstanceName());
if (check == null) {
session.getConsole().println(vpnInstance.getVpnInstanceName() + "\n");
}
}
session.getConsole().println(getshowVpnCLIHelp());
} else {
getVpnInstanceOpData();
session.getConsole().println("Fetching details of given vpnInstance\n");
session.getConsole().println("------------------------------------------------------------------------------");
VpnInstanceOpDataEntry check = vpnInstanceOpDataEntryMap.get(detail);
Long intfCount = 0L;
List<VpnToDpnList> dpnToVpns = check.getVpnToDpnList();
if (dpnToVpns != null) {
for (VpnToDpnList dpn : dpnToVpns) {
if (dpn.getVpnInterfaces() != null) {
intfCount = intfCount + dpn.getVpnInterfaces().size();
}
}
}
session.getConsole().println("VpnInstanceName: " + check.getVpnInstanceName() + "\nVpnId: " + check.getVpnId() + "\nVrfId: " + check.getVrfId() + "\nKey: " + check.getKey() + "\nVpnInterfaceCount: " + intfCount + "\nVpnToDpnList: " + check.getVpnToDpnList() + "\n");
session.getConsole().println("------------------------------------------------------------------------------");
}
return null;
}
Aggregations