Search in sources :

Example 36 with VpnInstance

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);
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey)

Example 37 with VpnInstance

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;
}
Also used : VpnTarget(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTarget) VpnTargetKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpntargets.VpnTargetKey) ArrayList(java.util.ArrayList) VpnTargets(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnTargets)

Example 38 with VpnInstance

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);
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstanceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryBuilder) VpnInstanceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntryKey)

Example 39 with VpnInstance

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);
}
Also used : VrfTablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesBuilder) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) SubnetRouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRouteBuilder) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ExecutionException(java.util.concurrent.ExecutionException) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Example 40 with VpnInstance

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;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

ArrayList (java.util.ArrayList)62 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)40 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)36 VpnInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance)31 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)26 List (java.util.List)24 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)23 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)22 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)22 Logger (org.slf4j.Logger)22 LoggerFactory (org.slf4j.LoggerFactory)22 Inject (javax.inject.Inject)21 Singleton (javax.inject.Singleton)21 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)21 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)20 FutureCallback (com.google.common.util.concurrent.FutureCallback)19 Futures (com.google.common.util.concurrent.Futures)19 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)19 Collections (java.util.Collections)19