Search in sources :

Example 1 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class VpnInterfaceManager method removeAdjacencyFromBgpvpn.

private void removeAdjacencyFromBgpvpn(Adjacency nextHop, List<String> nhList, String vpnName, String primaryRd, BigInteger dpnId, String rd, String interfaceName, WriteTransaction writeConfigTxn) {
    List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
    nhList.forEach((nh) -> {
        // IRT: remove routes from other vpns importing it
        vpnManager.removePrefixFromBGP(primaryRd, rd, vpnName, nextHop.getIpAddress(), nextHop.getNextHopIpList().get(0), nh, dpnId, writeConfigTxn);
        for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
            String vpnRd = vpn.getVrfId();
            if (vpnRd != null) {
                fibManager.removeOrUpdateFibEntry(vpnRd, nextHop.getIpAddress(), nh, writeConfigTxn);
                LOG.info("removeAdjacenciesFromVpn: Removed Exported route with rd {}" + " prefix {} nextHop {} from VPN {} parentVpn {}" + " for interface {} on dpn {}", vpnRd, nextHop.getIpAddress(), nh, vpn.getVpnInstanceName(), vpnName, interfaceName, dpnId);
            }
        }
    });
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)

Example 2 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class VpnInterfaceManager method updateVpnInterfaceOnTepAdd.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateVpnInterfaceOnTepAdd(VpnInterfaceOpDataEntry vpnInterface, StateTunnelList stateTunnelList, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
    String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
    BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
    AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
    List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
    if (adjList.isEmpty()) {
        LOG.trace("updateVpnInterfaceOnTepAdd: Adjacencies are empty for vpnInterface {} on dpn {}", vpnInterface, srcDpnId);
        return;
    }
    String prefix = null;
    long label = 0;
    List<Adjacency> value = new ArrayList<>();
    boolean isNextHopAddReqd = false;
    String vpnName = vpnInterface.getVpnInstanceName();
    long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
    String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
    LOG.info("updateVpnInterfaceOnTepAdd: AdjacencyList for interface {} on dpn {} vpn {} is {}", vpnInterface.getName(), vpnInterface.getDpnId(), vpnInterface.getVpnInstanceName(), adjList);
    for (Adjacency adj : adjList) {
        String rd = adj.getVrfId();
        rd = rd != null ? rd : vpnName;
        prefix = adj.getIpAddress();
        label = adj.getLabel();
        List<String> nhList = Collections.singletonList(srcTepIp);
        List<String> nextHopList = adj.getNextHopIpList();
        // Secondary adj nexthop is already pointing to primary adj IP address.
        if (nextHopList != null && !nextHopList.isEmpty() && nextHopList.get(0).equalsIgnoreCase(srcTepIp)) {
        /* everything right already */
        } else {
            isNextHopAddReqd = true;
        }
        if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
            value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
        } else {
            Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
            if (!vrfEntryOptional.isPresent()) {
                continue;
            }
            nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
            if (!nhList.contains(srcTepIp)) {
                nhList.add(srcTepIp);
                isNextHopAddReqd = true;
            }
            value.add(adj);
        }
        if (isNextHopAddReqd) {
            updateLabelMapper(label, nhList);
            LOG.info("updateVpnInterfaceOnTepAdd: Updated label mapper : label {} dpn {} prefix {} nexthoplist {}" + " vpn {} vpnid {} rd {} interface {}", label, srcDpnId, prefix, nhList, vpnInterface.getVpnInstanceName(), vpnId, rd, vpnInterface.getName());
            // Update the VRF entry with nextHop
            fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, true, writeConfigTxn);
            // Get the list of VPN's importing this route(prefix) .
            // Then update the VRF entry with nhList
            List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
            for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
                String vpnRd = vpn.getVrfId();
                if (vpnRd != null) {
                    fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, true, writeConfigTxn);
                    LOG.info("updateVpnInterfaceOnTepAdd: Exported route with rd {} prefix {} nhList {} label {}" + " interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName, vpn.getVpnInstanceName(), vpnRd);
                }
            }
            // since there is a nexthop change.
            try {
                if (!rd.equalsIgnoreCase(vpnName)) {
                    bgpManager.advertisePrefix(rd, null, /*macAddress*/
                    prefix, nhList, VrfEntry.EncapType.Mplsgre, (int) label, 0, /*evi*/
                    0, /*l2vni*/
                    null);
                }
                LOG.info("updateVpnInterfaceOnTepAdd: Advertised rd {} prefix {} nhList {} label {}" + " for interface {} on dpn {} vpn {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName);
            } catch (Exception ex) {
                LOG.error("updateVpnInterfaceOnTepAdd: Exception when advertising prefix {} nh {} label {}" + " on rd {} for interface {} on dpn {} vpn {}", prefix, nhList, label, rd, vpnInterface.getName(), srcDpnId, vpnName, ex);
            }
        }
    }
    AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
    VpnInterfaceOpDataEntry opInterface = new VpnInterfaceOpDataEntryBuilder(vpnInterface).setKey(new VpnInterfaceOpDataEntryKey(vpnInterface.getName(), vpnName)).addAugmentation(AdjacenciesOp.class, aug).build();
    InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
    writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, WriteTransaction.CREATE_MISSING_PARENTS);
    LOG.info("updateVpnInterfaceOnTepAdd: interface {} updated successully on tep add on dpn {} vpn {}", vpnInterface.getName(), srcDpnId, vpnName);
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) ExecutionException(java.util.concurrent.ExecutionException) VpnInterfaceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInterfaceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) BigInteger(java.math.BigInteger) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 3 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class VpnInterfaceManager method delAdjFromVpnInterface.

protected void delAdjFromVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, Adjacency adj, BigInteger dpnId, WriteTransaction writeOperTxn, WriteTransaction writeConfigTxn) {
    Optional<VpnInterfaceOpDataEntry> optVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, identifier);
    if (optVpnInterface.isPresent()) {
        VpnInterfaceOpDataEntry currVpnIntf = optVpnInterface.get();
        InstanceIdentifier<AdjacenciesOp> path = identifier.augmentation(AdjacenciesOp.class);
        Optional<AdjacenciesOp> optAdjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, path);
        if (optAdjacencies.isPresent()) {
            List<Adjacency> adjacencies = optAdjacencies.get().getAdjacency();
            if (!adjacencies.isEmpty()) {
                LOG.trace("delAdjFromVpnInterface: Adjacencies are {}", adjacencies);
                Iterator<Adjacency> adjIt = adjacencies.iterator();
                while (adjIt.hasNext()) {
                    Adjacency adjElem = adjIt.next();
                    if (adjElem.getIpAddress().equals(adj.getIpAddress())) {
                        String rd = adjElem.getVrfId();
                        adjIt.remove();
                        AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
                        VpnInterfaceOpDataEntry newVpnIntf = VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(), aug, dpnId, currVpnIntf.isScheduledForRemove(), currVpnIntf.getLportTag(), currVpnIntf.getGatewayMacAddress());
                        writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
                        if (adj.getNextHopIpList() != null) {
                            for (String nh : adj.getNextHopIpList()) {
                                deleteExtraRouteFromCurrentAndImportingVpns(currVpnIntf.getVpnInstanceName(), adj.getIpAddress(), nh, rd, currVpnIntf.getName(), writeConfigTxn);
                            }
                        } else if (adj.isPhysNetworkFunc()) {
                            LOG.info("delAdjFromVpnInterface: deleting PNF adjacency prefix {} subnet {}", adj.getIpAddress(), adj.getSubnetId());
                            fibManager.removeFibEntry(adj.getSubnetId().getValue(), adj.getIpAddress(), writeConfigTxn);
                        }
                        break;
                    }
                }
            }
            LOG.info("delAdjFromVpnInterface: Removed adj {} on dpn {} rd {}", adj.getIpAddress(), dpnId, adj.getVrfId());
        } else {
            LOG.error("delAdjFromVpnInterface: Cannnot DEL adjacency, since operational interface is " + "unavailable dpnId {} adjIP {} rd {}", dpnId, adj.getIpAddress(), adj.getVrfId());
        }
    }
}
Also used : AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 4 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class VpnInterfaceManager method updateVpnInterfaceOnTepDelete.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void updateVpnInterfaceOnTepDelete(VpnInterfaceOpDataEntry vpnInterface, StateTunnelList stateTunnelList, WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn) {
    AdjacenciesOp adjacencies = vpnInterface.getAugmentation(AdjacenciesOp.class);
    List<Adjacency> adjList = adjacencies != null ? adjacencies.getAdjacency() : new ArrayList<>();
    String prefix = null;
    long label = 0;
    boolean isNextHopRemoveReqd = false;
    String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
    BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
    String vpnName = vpnInterface.getVpnInstanceName();
    long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
    String primaryRd = VpnUtil.getVpnRd(dataBroker, vpnName);
    if (adjList != null) {
        List<Adjacency> value = new ArrayList<>();
        LOG.info("updateVpnInterfaceOnTepDelete: AdjacencyList for interface {} on dpn {} vpn {} is {}", vpnInterface.getName(), vpnInterface.getDpnId(), vpnInterface.getVpnInstanceName(), adjList);
        for (Adjacency adj : adjList) {
            List<String> nhList = new ArrayList<>();
            String rd = adj.getVrfId();
            rd = rd != null ? rd : vpnName;
            prefix = adj.getIpAddress();
            List<String> nextHopList = adj.getNextHopIpList();
            label = adj.getLabel();
            if (nextHopList != null && !nextHopList.isEmpty()) {
                isNextHopRemoveReqd = true;
            }
            // Secondary adj nexthop will continue to point to primary adj IP address.
            if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
                value.add(new AdjacencyBuilder(adj).setNextHopIpList(nhList).build());
            } else {
                Optional<VrfEntry> vrfEntryOptional = FibHelper.getVrfEntry(dataBroker, primaryRd, prefix);
                if (!vrfEntryOptional.isPresent()) {
                    continue;
                }
                nhList = FibHelper.getNextHopListFromRoutePaths(vrfEntryOptional.get());
                if (nhList.contains(srcTepIp)) {
                    nhList.remove(srcTepIp);
                    isNextHopRemoveReqd = true;
                }
                value.add(adj);
            }
            if (isNextHopRemoveReqd) {
                updateLabelMapper(label, nhList);
                LOG.info("updateVpnInterfaceOnTepDelete: Updated label mapper : label {} dpn {} prefix {}" + " nexthoplist {} vpn {} vpnid {} rd {} interface {}", label, srcDpnId, prefix, nhList, vpnName, vpnId, rd, vpnInterface.getName());
                // Update the VRF entry with removed nextHop
                fibManager.updateRoutePathForFibEntry(primaryRd, prefix, srcTepIp, label, false, writeConfigTxn);
                // Get the list of VPN's importing this route(prefix) .
                // Then update the VRF entry with nhList
                List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
                for (VpnInstanceOpDataEntry vpn : vpnsToImportRoute) {
                    String vpnRd = vpn.getVrfId();
                    if (vpnRd != null) {
                        fibManager.updateRoutePathForFibEntry(vpnRd, prefix, srcTepIp, label, false, writeConfigTxn);
                        LOG.info("updateVpnInterfaceOnTepDelete: Exported route with rd {} prefix {} nhList {}" + " label {} interface {} dpn {} from vpn {} to VPN {} vpnRd {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName, vpn.getVpnInstanceName(), vpnRd);
                    }
                }
                // Withdraw prefix from BGP only for external vpn.
                try {
                    if (!rd.equalsIgnoreCase(vpnName)) {
                        bgpManager.withdrawPrefix(rd, prefix);
                    }
                    LOG.info("updateVpnInterfaceOnTepDelete: Withdrawn rd {} prefix {} nhList {} label {}" + " for interface {} on dpn {} vpn {}", rd, prefix, nhList, label, vpnInterface.getName(), srcDpnId, vpnName);
                } catch (Exception ex) {
                    LOG.error("updateVpnInterfaceOnTepDelete: Exception when withdrawing prefix {} nh {} label {}" + " on rd {} for interface {} on dpn {} vpn {}", prefix, nhList, label, rd, vpnInterface.getName(), srcDpnId, vpnName, ex);
                }
            }
        }
        AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(value);
        VpnInterfaceOpDataEntry opInterface = new VpnInterfaceOpDataEntryBuilder(vpnInterface).setKey(new VpnInterfaceOpDataEntryKey(vpnInterface.getName(), vpnName)).addAugmentation(AdjacenciesOp.class, aug).build();
        InstanceIdentifier<VpnInterfaceOpDataEntry> interfaceId = VpnUtil.getVpnInterfaceOpDataEntryIdentifier(vpnInterface.getName(), vpnName);
        writeOperTxn.put(LogicalDatastoreType.OPERATIONAL, interfaceId, opInterface, WriteTransaction.CREATE_MISSING_PARENTS);
        LOG.info("updateVpnInterfaceOnTepDelete: interface {} updated successully on tep delete on dpn {} vpn {}", vpnInterface.getName(), srcDpnId, vpnName);
    }
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) ExecutionException(java.util.concurrent.ExecutionException) VpnInterfaceOpDataEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnInterfaceOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) BigInteger(java.math.BigInteger) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)

Example 5 with Adjacency

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency in project netvirt by opendaylight.

the class VpnInterfaceManager method addNewAdjToVpnInterface.

protected void addNewAdjToVpnInterface(InstanceIdentifier<VpnInterfaceOpDataEntry> identifier, String primaryRd, Adjacency adj, BigInteger dpnId, WriteTransaction writeOperTxn, WriteTransaction writeConfigTxn) {
    Optional<VpnInterfaceOpDataEntry> optVpnInterface = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, identifier);
    if (optVpnInterface.isPresent()) {
        VpnInterfaceOpDataEntry currVpnIntf = optVpnInterface.get();
        String prefix = VpnUtil.getIpPrefix(adj.getIpAddress());
        String vpnName = currVpnIntf.getVpnInstanceName();
        VpnInstanceOpDataEntry vpnInstanceOpData = VpnUtil.getVpnInstanceOpData(dataBroker, primaryRd);
        InstanceIdentifier<AdjacenciesOp> adjPath = identifier.augmentation(AdjacenciesOp.class);
        Optional<AdjacenciesOp> optAdjacencies = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, adjPath);
        boolean isL3VpnOverVxLan = VpnUtil.isL3VpnOverVxLan(vpnInstanceOpData.getL3vni());
        VrfEntry.EncapType encapType = VpnUtil.getEncapType(isL3VpnOverVxLan);
        long l3vni = vpnInstanceOpData.getL3vni() == null ? 0L : vpnInstanceOpData.getL3vni();
        VpnPopulator populator = L3vpnRegistry.getRegisteredPopulator(encapType);
        List<Adjacency> adjacencies;
        if (optAdjacencies.isPresent()) {
            adjacencies = optAdjacencies.get().getAdjacency();
        } else {
            // This code will be hit in case of first PNF adjacency
            adjacencies = new ArrayList<>();
        }
        long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
        L3vpnInput input = new L3vpnInput().setNextHop(adj).setVpnName(vpnName).setInterfaceName(currVpnIntf.getName()).setPrimaryRd(primaryRd).setRd(primaryRd);
        Adjacency operationalAdjacency = null;
        if (adj.getNextHopIpList() != null && !adj.getNextHopIpList().isEmpty()) {
            RouteOrigin origin = adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency ? RouteOrigin.LOCAL : RouteOrigin.STATIC;
            String nh = adj.getNextHopIpList().get(0);
            String vpnPrefixKey = VpnUtil.getVpnNamePrefixKey(vpnName, prefix);
            synchronized (vpnPrefixKey.intern()) {
                java.util.Optional<String> rdToAllocate = VpnUtil.allocateRdForExtraRouteAndUpdateUsedRdsMap(dataBroker, vpnId, null, prefix, vpnName, nh, dpnId);
                if (rdToAllocate.isPresent()) {
                    input.setRd(rdToAllocate.get());
                    operationalAdjacency = populator.createOperationalAdjacency(input);
                    int label = operationalAdjacency.getLabel().intValue();
                    vpnManager.addExtraRoute(vpnName, adj.getIpAddress(), nh, rdToAllocate.get(), currVpnIntf.getVpnInstanceName(), l3vni, origin, currVpnIntf.getName(), operationalAdjacency, encapType, writeConfigTxn);
                    LOG.info("addNewAdjToVpnInterface: Added extra route ip {} nh {} rd {} vpnname {} label {}" + " Interface {} on dpn {}", adj.getIpAddress(), nh, rdToAllocate.get(), vpnName, label, currVpnIntf.getName(), dpnId);
                } else {
                    LOG.error("addNewAdjToVpnInterface: No rds to allocate extraroute vpn {} prefix {}", vpnName, prefix);
                    return;
                }
                // Keeping the MPLS check for now.
                if (encapType.equals(VrfEntryBase.EncapType.Mplsgre)) {
                    final Adjacency opAdjacency = new AdjacencyBuilder(operationalAdjacency).build();
                    List<VpnInstanceOpDataEntry> vpnsToImportRoute = VpnUtil.getVpnsImportingMyRoute(dataBroker, vpnName);
                    vpnsToImportRoute.forEach(vpn -> {
                        if (vpn.getVrfId() != null) {
                            VpnUtil.allocateRdForExtraRouteAndUpdateUsedRdsMap(dataBroker, vpn.getVpnId(), vpnId, prefix, VpnUtil.getVpnName(dataBroker, vpn.getVpnId()), nh, dpnId).ifPresent(rds -> vpnManager.addExtraRoute(VpnUtil.getVpnName(dataBroker, vpn.getVpnId()), adj.getIpAddress(), nh, rds, currVpnIntf.getVpnInstanceName(), l3vni, RouteOrigin.SELF_IMPORTED, currVpnIntf.getName(), opAdjacency, encapType, writeConfigTxn));
                        }
                    });
                }
            }
        } else if (adj.isPhysNetworkFunc()) {
            // PNF adjacency.
            LOG.trace("addNewAdjToVpnInterface: Adding prefix {} to interface {} for vpn {}", prefix, currVpnIntf.getName(), vpnName);
            String parentVpnRd = getParentVpnRdForExternalSubnet(adj);
            writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(VpnUtil.getVpnId(dataBroker, adj.getSubnetId().getValue()), prefix), VpnUtil.getPrefixToInterface(BigInteger.ZERO, currVpnIntf.getName(), prefix, adj.getSubnetId(), Prefixes.PrefixCue.PhysNetFunc), true);
            fibManager.addOrUpdateFibEntry(adj.getSubnetId().getValue(), adj.getMacAddress(), adj.getIpAddress(), Collections.emptyList(), null, /* EncapType */
            0, /* label */
            0, /*l3vni*/
            null, /* gw-mac */
            parentVpnRd, RouteOrigin.LOCAL, writeConfigTxn);
            input.setRd(adj.getVrfId());
        }
        if (operationalAdjacency == null) {
            operationalAdjacency = populator.createOperationalAdjacency(input);
        }
        adjacencies.add(operationalAdjacency);
        AdjacenciesOp aug = VpnUtil.getVpnInterfaceOpDataEntryAugmentation(adjacencies);
        VpnInterfaceOpDataEntry newVpnIntf = VpnUtil.getVpnInterfaceOpDataEntry(currVpnIntf.getName(), currVpnIntf.getVpnInstanceName(), aug, dpnId, currVpnIntf.isScheduledForRemove(), currVpnIntf.getLportTag(), currVpnIntf.getGatewayMacAddress());
        writeOperTxn.merge(LogicalDatastoreType.OPERATIONAL, identifier, newVpnIntf, true);
    }
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput)

Aggregations

ArrayList (java.util.ArrayList)38 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency)38 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)32 ExecutionException (java.util.concurrent.ExecutionException)31 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)28 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)27 AdjacencyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey)26 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)25 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)24 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)24 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)20 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)17 Adjacencies (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.Adjacencies)16 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)14 AdjacencyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder)13 BigInteger (java.math.BigInteger)12 List (java.util.List)12 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)12 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)12 Optional (java.util.Optional)10