Search in sources :

Example 96 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class ElanInterfaceManager method validateExternalTunnelStateEvent.

/**
 * Validate external tunnel state event.
 *
 * @param externalTunnel
 *            the external tunnel
 * @param intrf
 *            the intrf
 * @return true, if successful
 */
private boolean validateExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
    if (intrf.getOperStatus() == Interface.OperStatus.Up) {
        String srcDevice = externalTunnel.getDestinationDevice();
        String destDevice = externalTunnel.getSourceDevice();
        ExternalTunnel otherEndPointExtTunnel = elanUtils.getExternalTunnel(srcDevice, destDevice, LogicalDatastoreType.CONFIGURATION);
        LOG.trace("Validating external tunnel state: src tunnel {}, dest tunnel {}", externalTunnel, otherEndPointExtTunnel);
        if (otherEndPointExtTunnel != null) {
            boolean otherEndPointInterfaceOperational = ElanUtils.isInterfaceOperational(otherEndPointExtTunnel.getTunnelInterfaceName(), broker);
            if (otherEndPointInterfaceOperational) {
                return true;
            } else {
                LOG.debug("Other end [{}] of the external tunnel is not yet UP for {}", otherEndPointExtTunnel.getTunnelInterfaceName(), externalTunnel);
            }
        }
    }
    return false;
}
Also used : ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)

Example 97 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class ElanTunnelInterfaceStateListener method add.

@Override
public void add(InstanceIdentifier<StateTunnelList> key, StateTunnelList add) {
    LOG.info("processing add state for StateTunnelList {}", add);
    if (!isInternalTunnel(add)) {
        LOG.trace("tunnel {} is not a internal vxlan tunnel", add);
        return;
    }
    if (elanUtils.isTunnelInLogicalGroup(add.getTunnelInterfaceName())) {
        LOG.trace("MULTIPLE_VxLAN_TUNNELS: ignoring the tunnel event for {}", add.getTunnelInterfaceName());
        return;
    }
    TunnelOperStatus tunOpStatus = add.getOperState();
    if (tunOpStatus != TunnelOperStatus.Down && tunOpStatus != TunnelOperStatus.Up) {
        LOG.trace("Returning because unsupported tunnelOperStatus {}", tunOpStatus);
        return;
    }
    try {
        Uint64 srcDpId = Uint64.valueOf(add.getSrcInfo().getTepDeviceId());
        Uint64 dstDpId = Uint64.valueOf(add.getDstInfo().getTepDeviceId());
        jobCoordinator.enqueueJob(add.getTunnelInterfaceName(), () -> {
            LOG.info("Handling tunnel state event for srcDpId {} and dstDpId {} ", srcDpId, dstDpId);
            elanInterfaceManager.handleInternalTunnelStateEvent(srcDpId, dstDpId);
            return Collections.emptyList();
        }, ElanConstants.JOB_MAX_RETRIES);
    } catch (NumberFormatException e) {
        LOG.error("Invalid source TepDeviceId {} or destination TepDeviceId {}", add.getSrcInfo().getTepDeviceId(), add.getDstInfo().getTepDeviceId());
    }
}
Also used : TunnelOperStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelOperStatus) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 98 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method bindService.

private void bindService(String tunnelInterfaceName) {
    coordinator.enqueueJob(tunnelInterfaceName, () -> {
        LOG.info("Bind egress policy service on tunnel {}", tunnelInterfaceName);
        List<Instruction> instructions = Collections.singletonList(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, 0));
        BoundServices boundServices = getBoundServices(tunnelInterfaceName, instructions);
        interfaceManager.bindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
        return null;
    });
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 99 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method populatePolicyRoutesToDpn.

private void populatePolicyRoutesToDpn(StateTunnelList tunnelState, int addOrRemove) {
    BigInteger srcDpId = getTepDpnId(tunnelState.getSrcInfo());
    BigInteger dstDpId = getTepDpnId(tunnelState.getDstInfo());
    String tunnelInterfaceName = tunnelState.getTunnelInterfaceName();
    if (BigInteger.ZERO.equals(srcDpId) || BigInteger.ZERO.equals(dstDpId)) {
        LOG.warn("No valid DPN found for logical tunnel {}", tunnelInterfaceName);
        return;
    }
    List<PolicyProfile> policyProfiles = policyServiceUtil.getAllPolicyProfiles();
    if (policyProfiles == null || policyProfiles.isEmpty()) {
        LOG.debug("No policy profiles found on addition of {}", tunnelInterfaceName);
        return;
    }
    policyProfiles.forEach(policyProfile -> {
        String policyClassifier = policyProfile.getPolicyClassifier();
        List<String> underlayNetworks = PolicyServiceUtil.getUnderlayNetworksFromPolicyRoutes(policyProfile.getPolicyRoute());
        underlayNetworks.forEach(underlayNetwork -> {
            if (policyServiceUtil.underlayNetworkContainsDpn(underlayNetwork, srcDpId) && policyServiceUtil.underlayNetworkContainsRemoteDpn(underlayNetwork, dstDpId)) {
                routeFlowProgrammer.programPolicyClassifierFlow(policyClassifier, srcDpId, dstDpId, addOrRemove, true);
            } else {
                LOG.trace("logical tunnel {} source DPN {} dest DPN {} not associated to policy classifier {}", tunnelInterfaceName, srcDpId, dstDpId, policyClassifier);
            }
        });
    });
}
Also used : PolicyProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile) BigInteger(java.math.BigInteger)

Example 100 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev170119.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method unbindService.

private void unbindService(String tunnelInterfaceName) {
    coordinator.enqueueJob(tunnelInterfaceName, () -> {
        LOG.info("Unbind egress policy service on tunnel {}", tunnelInterfaceName);
        BoundServices boundServices = getBoundServices(tunnelInterfaceName, Collections.emptyList());
        interfaceManager.unbindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
        return null;
    });
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)

Aggregations

ArrayList (java.util.ArrayList)61 ExecutionException (java.util.concurrent.ExecutionException)48 BigInteger (java.math.BigInteger)42 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)37 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)28 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)26 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)25 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)25 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)22 List (java.util.List)21 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)21 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)21 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)20 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)18 Logger (org.slf4j.Logger)18 LoggerFactory (org.slf4j.LoggerFactory)18 Inject (javax.inject.Inject)17 Singleton (javax.inject.Singleton)17 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)17