Search in sources :

Example 1 with VpnToDpnList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.

the class DpnInVpnChangeListener method onRemoveDpnEvent.

@Override
public void onRemoveDpnEvent(RemoveDpnEvent notification) {
    RemoveEventData eventData = notification.getRemoveEventData();
    final String rd = eventData.getRd();
    final String vpnName = eventData.getVpnName();
    BigInteger dpnId = eventData.getDpnId();
    LOG.trace("Remove Dpn Event notification received for rd {} VpnName {} DpnId {}", rd, vpnName, dpnId);
    synchronized (vpnName.intern()) {
        InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(rd);
        Optional<VpnInstanceOpDataEntry> vpnOpValue = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
        if (vpnOpValue.isPresent()) {
            VpnInstanceOpDataEntry vpnInstOpData = vpnOpValue.get();
            List<VpnToDpnList> vpnToDpnList = vpnInstOpData.getVpnToDpnList();
            boolean flushDpnsOnVpn = true;
            for (VpnToDpnList dpn : vpnToDpnList) {
                if (dpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                    flushDpnsOnVpn = false;
                    break;
                }
            }
            if (flushDpnsOnVpn) {
                WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
                deleteDpn(vpnToDpnList, rd, writeTxn);
                try {
                    writeTxn.submit().get();
                } catch (InterruptedException | ExecutionException e) {
                    LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
                    throw new RuntimeException(e.getMessage(), e);
                }
            }
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RemoveEventData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.remove.dpn.event.RemoveEventData) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with VpnToDpnList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.

the class DpnInVpnChangeListener method deleteDpn.

protected void deleteDpn(Collection<VpnToDpnList> vpnToDpnList, String rd, WriteTransaction writeTxn) {
    for (final VpnToDpnList curDpn : vpnToDpnList) {
        InstanceIdentifier<VpnToDpnList> vpnToDpnId = VpnUtil.getVpnToDpnListIdentifier(rd, curDpn.getDpnId());
        writeTxn.delete(LogicalDatastoreType.OPERATIONAL, vpnToDpnId);
    }
}
Also used : VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Example 3 with VpnToDpnList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.

the class NatUtil method isFloatingIpPresentForDpn.

public static Boolean isFloatingIpPresentForDpn(DataBroker dataBroker, BigInteger dpnId, String rd, String vpnName, String externalIp, Boolean isMoreThanOneFipCheckOnDpn) {
    InstanceIdentifier<VpnToDpnList> id = getVpnToDpnListIdentifier(rd, dpnId);
    Optional<VpnToDpnList> dpnInVpn = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
    if (dpnInVpn.isPresent()) {
        LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list is not empty for vpnName {}, dpn id {}, " + "rd {} and floatingIp {}", vpnName, dpnId, rd, externalIp);
        try {
            List<IpAddresses> ipAddressList = dpnInVpn.get().getIpAddresses();
            if (ipAddressList != null && !ipAddressList.isEmpty()) {
                int floatingIpPresentCount = 0;
                for (IpAddresses ipAddress : ipAddressList) {
                    if (!ipAddress.getIpAddress().equals(externalIp) && IpAddresses.IpAddressSource.FloatingIP.equals(ipAddress.getIpAddressSource())) {
                        floatingIpPresentCount++;
                        // Add tunnel table check
                        if (isMoreThanOneFipCheckOnDpn && floatingIpPresentCount > 1) {
                            return Boolean.TRUE;
                        }
                        // Remove tunnel table check
                        if (!isMoreThanOneFipCheckOnDpn) {
                            return Boolean.TRUE;
                        }
                    }
                }
            } else {
                LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list does not contain any floating IP for DPN {}", dpnId);
                return Boolean.FALSE;
            }
        } catch (NullPointerException e) {
            LOG.error("isFloatingIpPresentForDpn: Exception occurred on getting external IP address from " + "vpn-to-dpn-list on Dpn {}", dpnId, e);
            return Boolean.FALSE;
        }
    }
    return Boolean.FALSE;
}
Also used : IpAddresses(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Example 4 with VpnToDpnList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.

the class SNATDefaultRouteProgrammer method addOrDelDefaultFibRouteToSNATForSubnet.

void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
    String subnetId = subnet.getId().getValue();
    InstanceIdentifier<VpnInstanceOpDataEntry> networkVpnInstanceIdentifier = NatUtil.getVpnInstanceOpDataIdentifier(networkId);
    Optional<VpnInstanceOpDataEntry> networkVpnInstanceOp = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, networkVpnInstanceIdentifier);
    if (!networkVpnInstanceOp.isPresent()) {
        LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Cannot create/remove default FIB route to SNAT flow " + "for subnet {} vpn-instance-op-data entry for network {} does not exist", subnetId, networkId);
        return;
    }
    List<VpnToDpnList> dpnListInVpn = networkVpnInstanceOp.get().getVpnToDpnList();
    if (dpnListInVpn == null) {
        LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Will not add/remove default NAT flow for subnet {} " + "no dpn set for vpn instance {}", subnetId, networkVpnInstanceOp.get());
        return;
    }
    for (VpnToDpnList dpn : dpnListInVpn) {
        String macAddress = NatUtil.getSubnetGwMac(dataBroker, subnet.getId(), networkId);
        extNetGroupInstaller.installExtNetGroupEntry(new Uuid(networkId), subnet.getId(), dpn.getDpnId(), macAddress);
        FlowEntity flowEntity = NatUtil.buildDefaultNATFlowEntityForExternalSubnet(dpn.getDpnId(), vpnId, subnetId, idManager);
        if (flowAction == NwConstants.ADD_FLOW || flowAction == NwConstants.MOD_FLOW) {
            LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Installing flow {} for subnetId {}," + "vpnId {} on dpn {}", flowEntity, subnetId, vpnId, dpn.getDpnId());
            mdsalManager.installFlow(flowEntity);
        } else {
            LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Removing flow for subnetId {}," + "vpnId {} with dpn {}", subnetId, vpnId, dpn);
            mdsalManager.removeFlow(flowEntity);
        }
    }
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 5 with VpnToDpnList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.

the class RouterInterfaceVrfEntryHandler method installRouterFibEntries.

private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove, RouterInterface routerInterface) {
    final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
    Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
    Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
    synchronized (vpnInstance.getVpnInstanceName().intern()) {
        final Collection<VpnToDpnList> vpnToDpnList;
        if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
            VpnInstanceOpDataEntry parentVpnInstance = getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
            vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
        } else {
            vpnToDpnList = vpnInstance.getVpnToDpnList();
        }
        final Long vpnId = vpnInstance.getVpnId();
        if (vpnToDpnList != null) {
            String routerId = routerInterface.getUuid();
            String macAddress = routerInterface.getMacAddress();
            String ipValue = routerInterface.getIpAddress();
            LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}", routerId, ipValue, macAddress);
            for (VpnToDpnList vpnDpn : vpnToDpnList) {
                if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
                    installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, ipValue, new MacAddress(macAddress), addOrRemove);
                }
            }
        }
    }
    return true;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Aggregations

VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)24 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)15 BigInteger (java.math.BigInteger)12 ArrayList (java.util.ArrayList)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)11 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ExecutionException (java.util.concurrent.ExecutionException)6 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)4 IpAddresses (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddresses)4 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)4 Optional (com.google.common.base.Optional)3 Collections (java.util.Collections)3 List (java.util.List)3 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)3 SubnetRoute (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute)3 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 Logger (org.slf4j.Logger)3