use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VpnUtil method updateVpnInstanceOpDataWithVpnType.
public void updateVpnInstanceOpDataWithVpnType(String vpnName, VpnInstance.BgpvpnType bgpvpnType, WriteTransaction writeOperTxn) {
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnName(vpnName);
if (vpnInstanceOpDataEntry == null) {
LOG.error("updateVpnInstanceOpDataWithVpnType: VpnInstance {} with BGPVPN Type {} update Failed." + "Since vpnInstanceOpData is not yet ready.", vpnName, bgpvpnType);
return;
}
if (vpnInstanceOpDataEntry.getType() == VpnInstanceOpDataEntry.Type.L2) {
LOG.error("updateVpnInstanceOpDataWithVpnType: Unable to update the VpnInstance {} with BGPVPN Type {}." + "Since VPN type is L2 flavour. Do Nothing.", vpnName, bgpvpnType);
return;
}
synchronized (vpnName.intern()) {
VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(vpnInstanceOpDataEntry.getVrfId());
builder.setBgpvpnType(VpnInstanceOpDataEntry.BgpvpnType.forValue(bgpvpnType.getIntValue()));
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnInstanceOpDataEntry.getVrfId())).build();
writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
LOG.info("updateVpnInstanceOpDataWithVpnType: Successfully updated vpn-instance-op-data with BGPVPN type " + "{} for the Vpn {}", bgpvpnType, vpnName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VpnUtil method getRts.
static List<String> getRts(VpnInstanceOpDataEntry vpnInstance, VpnTarget.VrfRTType rtType) {
String name = vpnInstance.getVpnInstanceName();
List<String> rts = new ArrayList<>();
VpnTargets targets = vpnInstance.getVpnTargets();
if (targets == null) {
LOG.debug("getRts: vpn targets not available for {}", name);
return rts;
}
Map<VpnTargetKey, VpnTarget> keyVpnTargetMap = targets.getVpnTarget();
if (keyVpnTargetMap == null) {
LOG.debug("getRts: vpnTarget values not available for {}", name);
return rts;
}
for (VpnTarget target : keyVpnTargetMap.values()) {
// 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class VpnUtil method setVpnInstanceOpDataWithAddressFamily.
public void setVpnInstanceOpDataWithAddressFamily(String vpnName, VpnInstance.IpAddressFamilyConfigured ipVersion, WriteTransaction writeOperTxn) {
VpnInstanceOpDataEntry vpnInstanceOpDataEntry = getVpnInstanceOpDataEntryFromVpnName(vpnName);
if (vpnInstanceOpDataEntry == null) {
LOG.error("setVpnInstanceOpDataWithAddressFamily: Unable to set IP address family {} for the " + "VPN {}. Since VpnInstanceOpData is not yet ready", ipVersion, vpnName);
return;
}
if (vpnInstanceOpDataEntry.getType() == VpnInstanceOpDataEntry.Type.L2) {
LOG.error("setVpnInstanceOpDataWithAddressFamily: Unable to set IP address family {} for the " + "VPN {}. Since VPN type is L2 flavour. Do Nothing.", ipVersion, vpnName);
return;
}
synchronized (vpnName.intern()) {
VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder().setVrfId(vpnInstanceOpDataEntry.getVrfId());
builder.setIpAddressFamilyConfigured(VpnInstanceOpDataEntry.IpAddressFamilyConfigured.forValue(ipVersion.getIntValue()));
InstanceIdentifier<VpnInstanceOpDataEntry> id = InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(vpnInstanceOpDataEntry.getVrfId())).build();
writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build());
LOG.info("setVpnInstanceOpDataWithAddressFamily: Successfully set vpnInstanceOpData with " + "IP Address family {} for VpnInstance {}", ipVersion.getName(), vpnName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance 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();
Uint32 label = Uint32.valueOf(input.getLabel());
Uint32 l3vni = Uint32.valueOf(input.getL3vni());
Uint32 elantag = Uint32.valueOf(input.getElanTag());
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(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 = Optional.empty();
try {
entry = SingleTransactionDataBroker.syncReadOptional(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
} catch (ExecutionException | InterruptedException e) {
LOG.error("addSubnetRouteFibEntry: Exception while reading vrfEntry for the prefix {} rd {}", prefix, rd, e);
}
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(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(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)) {
List<VpnInstanceOpDataEntry> vpnsToImportRoute = vpnUtil.getVpnsImportingMyRoute(vpnName);
if (vpnsToImportRoute.size() > 0) {
VrfEntry importingVrfEntry = FibHelper.getVrfEntryBuilder(prefix, label, nextHop, RouteOrigin.SELF_IMPORTED, rd).addAugmentation(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(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.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance in project netvirt by opendaylight.
the class ShowVpnInstanceOpData method doExecute.
@Override
@Nullable
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;
Map<VpnToDpnListKey, VpnToDpnList> vpnToDpnListKeyVpnToDpnListMap = check.getVpnToDpnList();
if (vpnToDpnListKeyVpnToDpnListMap != null) {
for (VpnToDpnList dpn : vpnToDpnListKeyVpnToDpnListMap.values()) {
if (dpn.getVpnInterfaces() != null) {
intfCount = intfCount + dpn.getVpnInterfaces().size();
}
}
}
session.getConsole().println("VpnInstanceName: " + check.getVpnInstanceName() + "\nVpnId: " + check.getVpnId() + "\nVrfId: " + check.getVrfId() + "\nKey: " + check.key() + "\nVpnInterfaceCount: " + intfCount + "\nVpnToDpnList: " + check.getVpnToDpnList() + "\n");
session.getConsole().println("------------------------------------------------------------------------------");
}
return null;
}
Aggregations