Search in sources :

Example 31 with DpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.

the class ElanUtils method getExternalElanInterface.

public String getExternalElanInterface(String elanInstanceName, BigInteger dpnId) {
    DpnInterfaces dpnInterfaces = getElanInterfaceInfoByElanDpn(elanInstanceName, dpnId);
    if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null) {
        LOG.trace("Elan {} does not have interfaces in DPN {}", elanInstanceName, dpnId);
        return null;
    }
    for (String dpnInterface : dpnInterfaces.getInterfaces()) {
        if (interfaceManager.isExternalInterface(dpnInterface)) {
            return dpnInterface;
        }
    }
    LOG.trace("Elan {} does not have any external interace attached to DPN {}", elanInstanceName, dpnId);
    return null;
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)

Example 32 with DpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.

the class ElanUtils method isDpnAlreadyPresentInElanInstance.

/**
 * To check given dpId is already present in Elan instance. This can be used
 * to program flow entry in external tunnel table when a new access port
 * added for first time into the ELAN instance
 *
 * @param dpId
 *            the dp id
 * @param elanInstanceName
 *            the elan instance name
 * @return true if dpId is already present, otherwise return false
 */
public boolean isDpnAlreadyPresentInElanInstance(BigInteger dpId, String elanInstanceName) {
    InstanceIdentifier<ElanDpnInterfacesList> elanDpnInterfaceId = getElanDpnOperationDataPath(elanInstanceName);
    Optional<ElanDpnInterfacesList> existingElanDpnInterfaces = read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
    if (!existingElanDpnInterfaces.isPresent()) {
        return false;
    }
    List<DpnInterfaces> dpnInterfaces = existingElanDpnInterfaces.get().getDpnInterfaces();
    for (DpnInterfaces dpnInterface : dpnInterfaces) {
        if (dpnInterface.getDpId().equals(dpId)) {
            return true;
        }
    }
    return false;
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)

Example 33 with DpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces 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 34 with DpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.

the class VpnUtil method getDpnInElan.

public static Set<BigInteger> getDpnInElan(DataBroker dataBroker, Map<String, String> elanInstanceRouterPortMap) {
    Set<BigInteger> dpnIdSet = new HashSet<BigInteger>();
    for (String elanInstanceName : elanInstanceRouterPortMap.keySet()) {
        InstanceIdentifier<ElanDpnInterfacesList> elanDpnInterfaceId = getElanDpnOperationalDataPath(elanInstanceName);
        Optional<ElanDpnInterfacesList> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
        if (dpnInElanInterfaces.isPresent()) {
            List<DpnInterfaces> dpnInterfaces = dpnInElanInterfaces.get().getDpnInterfaces();
            for (DpnInterfaces dpnInterface : dpnInterfaces) {
                dpnIdSet.add(dpnInterface.getDpId());
            }
        }
    }
    return dpnIdSet;
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) BigInteger(java.math.BigInteger) HashSet(java.util.HashSet)

Example 35 with DpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces in project netvirt by opendaylight.

the class VpnUtil method removeRouterPortFromElanDpn.

public static void removeRouterPortFromElanDpn(String elanInstanceName, String routerInterfacePortId, String vpnName, BigInteger dpnId, DataBroker dataBroker) {
    InstanceIdentifier<DpnInterfaces> elanDpnInterfaceId = getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpnId);
    Optional<DpnInterfaces> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
    List<String> elanInterfaceList;
    DpnInterfaces dpnInterface;
    if (!dpnInElanInterfaces.isPresent()) {
        LOG.info("No interface in any dpn for {}", vpnName);
        return;
    } else {
        dpnInterface = dpnInElanInterfaces.get();
        elanInterfaceList = dpnInterface.getInterfaces();
    }
    if (!elanInterfaceList.contains(routerInterfacePortId)) {
        LOG.info("Router port not present in DPN {} for VPN {}", dpnId, vpnName);
        return;
    }
    elanInterfaceList.remove(routerInterfacePortId);
    dpnInterface = new DpnInterfacesBuilder().setDpId(dpnId).setInterfaces(elanInterfaceList).setKey(new DpnInterfacesKey(dpnId)).build();
    VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId, dpnInterface);
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)

Aggregations

DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)32 BigInteger (java.math.BigInteger)25 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)20 ArrayList (java.util.ArrayList)19 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)15 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)8 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)5 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 DpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)4 DpnInterfacesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey)4 Nonnull (javax.annotation.Nonnull)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3 HashSet (java.util.HashSet)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2