Search in sources :

Example 71 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronvpnUtils method getExistingRDs.

public List<String> getExistingRDs() {
    List<String> existingRDs = new ArrayList<>();
    InstanceIdentifier<VpnInstances> path = InstanceIdentifier.builder(VpnInstances.class).build();
    Optional<VpnInstances> vpnInstancesOptional = read(LogicalDatastoreType.CONFIGURATION, path);
    if (vpnInstancesOptional.isPresent() && vpnInstancesOptional.get().getVpnInstance() != null) {
        for (VpnInstance vpnInstance : vpnInstancesOptional.get().getVpnInstance()) {
            if (vpnInstance.getIpv4Family() == null) {
                continue;
            }
            List<String> rds = vpnInstance.getIpv4Family().getRouteDistinguisher();
            if (rds != null) {
                existingRDs.addAll(rds);
            }
        }
    }
    return existingRDs;
}
Also used : VpnInstances(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInstances) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList)

Example 72 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronvpnUtils method shouldVpnHandleIpVersionChangeToRemove.

public boolean shouldVpnHandleIpVersionChangeToRemove(Subnetmap sm, Uuid vpnId) {
    if (sm == null) {
        return false;
    }
    InstanceIdentifier<Subnetmaps> subnetMapsId = InstanceIdentifier.builder(Subnetmaps.class).build();
    Optional<Subnetmaps> allSubnetMaps = read(LogicalDatastoreType.CONFIGURATION, subnetMapsId);
    // calculate and store in list IpVersion for each subnetMap, belonging to current VpnInstance
    List<IpVersionChoice> snIpVersions = new ArrayList<>();
    for (Subnetmap snMap : allSubnetMaps.get().getSubnetmap()) {
        if (snMap.getId().equals(sm.getId())) {
            continue;
        }
        if (snMap.getVpnId() != null && snMap.getVpnId().equals(vpnId)) {
            snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
        }
        if (snMap.getInternetVpnId() != null && snMap.getInternetVpnId().equals(vpnId)) {
            snIpVersions.add(getIpVersionFromString(snMap.getSubnetIp()));
        }
    }
    IpVersionChoice ipVersion = getIpVersionFromString(sm.getSubnetIp());
    if (!snIpVersions.contains(ipVersion)) {
        return true;
    }
    return false;
}
Also used : Subnetmaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 73 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronEvpnUtils method updateElanWithVpnInfo.

public void updateElanWithVpnInfo(String elanInstanceName, VpnInstance vpnInstance, Operation operation) {
    String vpnName = vpnInstance.getVpnInstanceName();
    InstanceIdentifier<ElanInstance> elanIid = ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName);
    ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
    Optional<ElanInstance> elanInstanceOptional = Optional.absent();
    try {
        elanInstanceOptional = transaction.read(LogicalDatastoreType.CONFIGURATION, elanIid).checkedGet();
    } catch (ReadFailedException e) {
        LOG.error("updateElanWithVpnInfo throws ReadFailedException e {}", e);
    }
    if (!elanInstanceOptional.isPresent()) {
        return;
    }
    EvpnAugmentationBuilder evpnAugmentationBuilder = new EvpnAugmentationBuilder();
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceOptional.get());
    if (elanInstanceBuilder.getAugmentation(EvpnAugmentation.class) != null) {
        evpnAugmentationBuilder = new EvpnAugmentationBuilder(elanInstanceBuilder.getAugmentation(EvpnAugmentation.class));
    }
    if (operation == Operation.ADD) {
        evpnAugmentationBuilder.setEvpnName(vpnName);
        LOG.debug("Writing Elan-EvpnAugmentation with key {}", elanInstanceName);
    } else {
        evpnAugmentationBuilder.setEvpnName(null);
        LOG.debug("Deleting Elan-EvpnAugmentation with key {}", elanInstanceName);
    }
    elanInstanceBuilder.addAugmentation(EvpnAugmentation.class, evpnAugmentationBuilder.build());
    transaction.put(LogicalDatastoreType.CONFIGURATION, elanIid, elanInstanceBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
    transaction.submit();
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) EvpnAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentationBuilder) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) EvpnAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.EvpnAugmentation)

Example 74 with VpnInstance

use of org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance in project netvirt by opendaylight.

the class NeutronEvpnUtils method updateVpnWithElanInfo.

public void updateVpnWithElanInfo(VpnInstance vpnInstance, String elanInstanceName, Operation operation) {
    String rd = vpnManager.getPrimaryRdFromVpnInstance(vpnInstance);
    InstanceIdentifier<EvpnRdToNetwork> rdToNetworkIdentifier = getRdToNetworkIdentifier(rd);
    jobCoordinator.enqueueJob("EVPN_ASSOCIATE-" + rd, () -> {
        ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (operation == Operation.DELETE) {
            LOG.debug("Deleting Evpn-Network with key {}", rd);
            transaction.delete(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier);
        } else {
            EvpnRdToNetworkBuilder evpnRdToNetworkBuilder = new EvpnRdToNetworkBuilder().setKey(new EvpnRdToNetworkKey(rd));
            evpnRdToNetworkBuilder.setRd(rd);
            evpnRdToNetworkBuilder.setNetworkId(elanInstanceName);
            LOG.info("updating Evpn {} with elaninstance {} and rd {}", vpnInstance.getVpnInstanceName(), elanInstanceName, rd);
            transaction.put(LogicalDatastoreType.CONFIGURATION, rdToNetworkIdentifier, evpnRdToNetworkBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
        }
        futures.add(transaction.submit());
        return futures;
    });
}
Also used : ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) EvpnRdToNetworkKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkKey) EvpnRdToNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetwork) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) EvpnRdToNetworkBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.evpn.rd.to.networks.EvpnRdToNetworkBuilder)

Aggregations

ArrayList (java.util.ArrayList)39 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)23 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)19 BigInteger (java.math.BigInteger)18 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)17 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)16 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)14 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)13 VpnInstanceNames (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.vpn._interface.VpnInstanceNames)13 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)13 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)12 List (java.util.List)10 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)9 Optional (com.google.common.base.Optional)7 PostConstruct (javax.annotation.PostConstruct)7 Inject (javax.inject.Inject)7 Singleton (javax.inject.Singleton)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)7