Search in sources :

Example 41 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces in project netvirt by opendaylight.

the class VpnFootprintService method removeOrUpdateVpnToDpnListForIpAddress.

private void removeOrUpdateVpnToDpnListForIpAddress(long vpnId, String rd, BigInteger dpnId, ImmutablePair<IpAddresses.IpAddressSource, String> ipAddressSourceValuePair, String vpnName) {
    Boolean lastDpnOnVpn = Boolean.FALSE;
    synchronized (vpnName.intern()) {
        InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(rd, dpnId);
        VpnToDpnList dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id).orNull();
        if (dpnInVpn == null) {
            LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={} rd={} id={}]" + " and dpnId={}", vpnName, rd, id, dpnId);
            return;
        }
        List<IpAddresses> ipAddresses = dpnInVpn.getIpAddresses();
        if (ipAddresses == null) {
            LOG.info("Could not find ipAddresses for DpnInVpn map for VPN=[name={} rd={} id={}] and dpnId={}", vpnName, rd, id, dpnId);
            return;
        }
        IpAddresses currIpAddress = new IpAddressesBuilder().setKey(new IpAddressesKey(ipAddressSourceValuePair.getValue())).setIpAddressSource(ipAddressSourceValuePair.getKey()).build();
        if (ipAddresses.remove(currIpAddress)) {
            WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
            if (ipAddresses.isEmpty()) {
                List<VpnInterfaces> vpnInterfaces = dpnInVpn.getVpnInterfaces();
                VpnToDpnListBuilder dpnInVpnBuilder = new VpnToDpnListBuilder(dpnInVpn).setIpAddresses(null);
                if (vpnInterfaces == null || vpnInterfaces.isEmpty()) {
                    dpnInVpnBuilder.setDpnState(VpnToDpnList.DpnState.Inactive);
                    lastDpnOnVpn = Boolean.TRUE;
                } else {
                    LOG.warn("ip addresses are empty but vpn interfaces are present for the vpn {} in dpn {}", vpnName, dpnId);
                }
                writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(), true);
            } else {
                writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(IpAddresses.class, new IpAddressesKey(ipAddressSourceValuePair.getValue())));
            }
            try {
                writeTxn.submit().get();
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("Error removing from dpnToVpnList for vpn {} Ipaddress {} dpn {}", vpnName, ipAddressSourceValuePair.getValue(), dpnId, e);
                throw new RuntimeException(e.getMessage(), e);
            }
        }
    }
    if (lastDpnOnVpn) {
        LOG.debug("Sending cleanup event for dpn {} in VPN {}", dpnId, vpnName);
        fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false));
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder) 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) IpAddressesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesKey) IpAddressesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.IpAddressesBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 42 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces in project netvirt by opendaylight.

the class VpnFootprintService method removeOrUpdateVpnToDpnListForInterfaceName.

private void removeOrUpdateVpnToDpnListForInterfaceName(long vpnId, String rd, BigInteger dpnId, String intfName, String vpnName) {
    Boolean lastDpnOnVpn = Boolean.FALSE;
    synchronized (vpnName.intern()) {
        InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(rd, dpnId);
        VpnToDpnList dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id).orNull();
        if (dpnInVpn == null) {
            LOG.error("removeOrUpdateVpnToDpnList: Could not find DpnToVpn map for VPN=[name={} rd={} id={}]" + " and dpnId={}", vpnName, rd, id, dpnId);
            return;
        }
        List<VpnInterfaces> vpnInterfaces = dpnInVpn.getVpnInterfaces();
        if (vpnInterfaces == null) {
            LOG.error("Could not find vpnInterfaces for DpnInVpn map for VPN=[name={} rd={} id={}] and dpnId={}", vpnName, rd, id, dpnId);
            return;
        }
        VpnInterfaces currVpnInterface = new VpnInterfacesBuilder().setInterfaceName(intfName).build();
        if (vpnInterfaces.remove(currVpnInterface)) {
            WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
            if (vpnInterfaces.isEmpty()) {
                List<IpAddresses> ipAddresses = dpnInVpn.getIpAddresses();
                VpnToDpnListBuilder dpnInVpnBuilder = new VpnToDpnListBuilder(dpnInVpn).setVpnInterfaces(null);
                if (ipAddresses == null || ipAddresses.isEmpty()) {
                    dpnInVpnBuilder.setDpnState(VpnToDpnList.DpnState.Inactive);
                    lastDpnOnVpn = Boolean.TRUE;
                } else {
                    LOG.error("removeOrUpdateVpnToDpnList: vpn interfaces are empty but ip addresses are present" + " for the vpn {} in dpn {} interface {}", vpnName, dpnId, intfName);
                }
                LOG.debug("removeOrUpdateVpnToDpnList: Removing vpn footprint for vpn {} vpnId {} interface {}," + " on dpn {}", vpnName, vpnName, intfName, dpnId);
                writeTxn.put(LogicalDatastoreType.OPERATIONAL, id, dpnInVpnBuilder.build(), WriteTransaction.CREATE_MISSING_PARENTS);
            } else {
                writeTxn.delete(LogicalDatastoreType.OPERATIONAL, id.child(VpnInterfaces.class, new VpnInterfacesKey(intfName)));
                LOG.debug("removeOrUpdateVpnToDpnList: Updating vpn footprint for vpn {} vpnId {} interface {}," + " on dpn {}", vpnName, vpnName, intfName, dpnId);
            }
            try {
                writeTxn.submit().get();
            } catch (InterruptedException | ExecutionException e) {
                LOG.error("removeOrUpdateVpnToDpnList: Error removing from dpnToVpnList for vpn {} vpnId {}" + " interface {} dpn {}", vpnName, vpnId, intfName, dpnId, e);
                throw new RuntimeException(e.getMessage(), e);
            }
        }
    }
    // Ends synchronized block
    LOG.info("removeOrUpdateVpnToDpnList: Updated/Removed vpn footprint for vpn {} vpnId {} interface {}," + " on dpn {}", vpnName, vpnName, intfName, dpnId);
    if (lastDpnOnVpn) {
        fibManager.cleanUpDpnForVpn(dpnId, vpnId, rd, new DpnEnterExitVpnWorker(dpnId, vpnName, rd, false));
        LOG.info("removeOrUpdateVpnToDpnList: Sent cleanup event for dpn {} in VPN {} vpnId {} interface {}", dpnId, vpnName, vpnId, intfName);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesKey) VpnToDpnListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder) 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) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 43 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces in project netvirt by opendaylight.

the class VpnManagerImpl method addArpResponderFlowsToExternalNetworkIps.

@Override
public void addArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId, WriteTransaction writeTx) {
    if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
        LOG.warn("Failed to install arp responder flows for router {}. DPN id is missing.", id);
        return;
    }
    String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
    if (extInterfaceName != null) {
        doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, writeTx, extInterfaceName);
        return;
    }
    LOG.warn("Failed to install responder flows for {}. No external interface found for DPN id {}", id, dpnId);
    if (!upgradeState.isUpgradeInProgress()) {
        return;
    }
    // The following through the end of the function deals with an upgrade scenario where the neutron configuration
    // is restored before the OVS switches reconnect. In such a case, the elan-dpn-interfaces entries will be
    // missing from the operational data store. In order to mitigate this we use DataTreeEventCallbackRegistrar
    // to wait for the exact operational md-sal object we need to contain the external interface we need.
    LOG.info("Upgrade in process, waiting for an external interface to appear on dpn {} for elan {}", dpnId, extNetworkId.getValue());
    InstanceIdentifier<DpnInterfaces> dpnInterfacesIid = elanService.getElanDpnInterfaceOperationalDataPath(extNetworkId.getValue(), dpnId);
    eventCallbacks.onAddOrUpdate(LogicalDatastoreType.OPERATIONAL, dpnInterfacesIid, (unused, alsoUnused) -> {
        LOG.info("Reattempting write of arp responder for external interfaces for external network {}", extNetworkId);
        DpnInterfaces dpnInterfaces = elanService.getElanInterfaceInfoByElanDpn(extNetworkId.getValue(), dpnId);
        if (dpnInterfaces == null) {
            LOG.error("Could not retrieve DpnInterfaces for {}, {}", extNetworkId.getValue(), dpnId);
            return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
        }
        String extIfc = null;
        for (String dpnInterface : dpnInterfaces.getInterfaces()) {
            if (interfaceManager.isExternalInterface(dpnInterface)) {
                extIfc = dpnInterface;
                break;
            }
        }
        if (extIfc == null) {
            if (upgradeState.isUpgradeInProgress()) {
                LOG.info("External interface not found yet in elan {} on dpn {}, keep waiting", extNetworkId.getValue(), dpnInterfaces);
                return DataTreeEventCallbackRegistrar.NextAction.CALL_AGAIN;
            } else {
                return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
            }
        }
        final String extIfcFinal = extIfc;
        ListenableFuture<Void> listenableFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            doAddArpResponderFlowsToExternalNetworkIps(id, fixedIps, macAddress, dpnId, extNetworkId, tx, extIfcFinal);
        });
        ListenableFutures.addErrorLogging(listenableFuture, LOG, "Error while configuring arp responder for ext. interface");
        return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
    });
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)

Example 44 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces in project netvirt by opendaylight.

the class ElanDpnInterfacesListener method update.

@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
    LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
    BigInteger dpnId = update.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
        List<String> interfaces = update.getInterfaces();
        // trigger deletion for vlan provider intf on the DPN for the vlan provider network
        if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
            LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
            jobCoordinator.enqueueJob(dpnId.toString(), () -> {
                elanService.deleteExternalElanNetwork(elanInstance, dpnId);
                return Collections.emptyList();
            });
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 45 with Interfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces in project netvirt by opendaylight.

the class ElanInterfaceManager method remove.

@Override
protected void remove(InstanceIdentifier<ElanInterface> identifier, ElanInterface del) {
    String interfaceName = del.getName();
    ElanInstance elanInfo = elanInstanceCache.get(del.getElanInstanceName()).orNull();
    /*
         * Handling in case the elan instance is deleted.If the Elan instance is
         * deleted, there is no need to explicitly delete the elan interfaces
         */
    if (elanInfo == null) {
        return;
    }
    InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
    if (interfaceInfo == null && elanInfo.isExternal()) {
        // In deleting external network, the underlying ietf Inteface might have been removed
        // from the config DS prior to deleting the ELAN interface. We try to get the InterfaceInfo
        // from Operational DS instead
        interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName);
    }
    String elanInstanceName = elanInfo.getElanInstanceName();
    InterfaceRemoveWorkerOnElan configWorker = new InterfaceRemoveWorkerOnElan(elanInstanceName, elanInfo, interfaceName, interfaceInfo, this);
    jobCoordinator.enqueueJob(elanInstanceName, configWorker, ElanConstants.JOB_MAX_RETRIES);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)24 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 HashSet (java.util.HashSet)7 ExecutionException (java.util.concurrent.ExecutionException)7 HashMap (java.util.HashMap)4 List (java.util.List)4 Test (org.junit.Test)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)4 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)4 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)4 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.Ports)4 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)4