Search in sources :

Example 31 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.

the class ElanServiceChainHandler method programElanScfPipeline.

/**
 * Programs the needed flows for sending traffic to the SCF pipeline when
 * it is comming from an L2-GW (ELAN) and also for handing over that
 * traffic from SCF to ELAN when the packets does not match any Service
 * Chain.
 *
 * @param elanName Name of the ELAN to be considered
 * @param tableId Table id, in the SCF Pipeline, to which the traffic must
 *        go to.
 * @param scfTag Tag of the ServiceChain
 * @param elanLportTag LPortTag of the ElanPseudoPort that participates in
 *        the ServiceChain
 * @param addOrRemove States if the flows must be created or removed
 */
public void programElanScfPipeline(String elanName, short tableId, long scfTag, int elanLportTag, int addOrRemove) {
    LOG.info("programElanScfPipeline:  elanName={}   scfTag={}   elanLportTag={}    addOrRemove={}", elanName, scfTag, elanLportTag, addOrRemove);
    // There are 3 rules to be considered:
    // 1. LportDispatcher To Scf. Matches on elanPseudoPort + SI=1. Goes to DL Subscriber table
    // 2. LportDispatcher From Scf. Matches on elanPseudoPort + SI=3. Goes to ELAN DMAC
    // 3. ExtTunnelTable From L2GwDevice. Matches on VNI + SI=1. Sets ElanPseudoPort tag and goes
    // to LportDispatcher table.
    // And these rules must be programmed in all the Elan footprint
    // Find the ElanInstance
    Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
    if (!elanInstance.isPresent()) {
        LOG.debug("Could not find an Elan Instance with name={}", elanName);
        return;
    }
    Collection<BigInteger> elanDpnsOpc = ElanServiceChainUtils.getElanDpnsByName(broker, elanName);
    if (elanDpnsOpc.isEmpty()) {
        LOG.debug("Could not find any DPN related to Elan {}", elanName);
        return;
    }
    // updates map which stores relationship between elan and elanLPortTag and scfTag
    ElanServiceChainUtils.updateElanToLportTagMap(broker, elanName, elanLportTag, scfTag, addOrRemove);
    Long vni = elanInstance.get().getSegmentationId();
    if (vni == null) {
        LOG.warn("There is no VNI for elan {}. VNI is mandatory. Returning", elanName);
        return;
    }
    int elanTag = elanInstance.get().getElanTag().intValue();
    LOG.debug("elanName={}  ->  vni={}  elanTag={}", elanName, vni, elanTag);
    // Program ExtTunnelTable.
    for (BigInteger dpnId : elanDpnsOpc) {
        ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, tableId, scfTag, addOrRemove);
        ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, addOrRemove);
        ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, addOrRemove);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) BigInteger(java.math.BigInteger)

Example 32 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.

the class QosInterfaceStateChangeListener method getNeutronPortForRemove.

private Optional<Port> getNeutronPortForRemove(Interface intrf) {
    final String portName = intrf.getName();
    Optional<Uuid> uuid = uuidUtil.newUuidIfValidPattern(portName);
    if (uuid.isPresent()) {
        Port port = neutronVpnManager.getNeutronPort(portName);
        if (port != null) {
            return Optional.fromJavaUtil(uuid.toJavaUtil().map(neutronVpnManager::getNeutronPort));
        }
        LOG.trace("Qos Service : interface {} clearing stale flow entries if any", portName);
        qosNeutronUtils.removeStaleFlowEntry(intrf);
    }
    return Optional.absent();
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)

Example 33 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.

the class QosNeutronUtils method setPortDscpMarking.

public void setPortDscpMarking(Port port, DscpmarkingRules dscpMark) {
    if (!qosEosHandler.isQosClusterOwner()) {
        LOG.trace("Not Qos Cluster Owner. Ignoring setting DSCP marking");
        return;
    }
    LOG.trace("Setting DSCP value {} on Port {}", port, dscpMark);
    BigInteger dpnId = getDpnForInterface(port.getUuid().getValue());
    String ifName = port.getUuid().getValue();
    IpAddress ipAddress = port.getFixedIps().get(0).getIpAddress();
    Short dscpValue = dscpMark.getDscpMark();
    if (dpnId.equals(BigInteger.ZERO)) {
        LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
        return;
    }
    // 1. OF rules
    addFlow(dpnId, dscpValue, ifName, ipAddress, getInterfaceStateFromOperDS(ifName));
    if (qosServiceConfiguredPorts.add(port.getUuid())) {
        // bind qos service to interface
        bindservice(ifName);
    }
}
Also used : BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 34 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.

the class GeniusProvider method getDpnIdFromInterfaceName.

public Optional<DpnIdType> getDpnIdFromInterfaceName(String interfaceName) {
    LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
    GetDpidFromInterfaceInputBuilder builder = new GetDpidFromInterfaceInputBuilder();
    builder.setIntfName(interfaceName);
    GetDpidFromInterfaceInput input = builder.build();
    if (interfaceManagerRpcService == null) {
        LOG.error("getDpnIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
        return Optional.empty();
    }
    try {
        LOG.debug("getDpnIdFromInterfaceName: invoking rpc");
        RpcResult<GetDpidFromInterfaceOutput> output = interfaceManagerRpcService.getDpidFromInterface(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getDpnIdFromInterfaceName({}) failed: {}", input, output);
            return Optional.empty();
        }
        BigInteger dpnId = output.getResult().getDpid();
        if (dpnId == null) {
            return Optional.empty();
        }
        LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
        return Optional.of(new DpnIdType(dpnId));
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
    }
    return Optional.empty();
}
Also used : GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) GetDpidFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput) GetDpidFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException) DpnIdType(org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType)

Example 35 with Service

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.

the class GeniusProvider method getNodeConnectorIdFromInterfaceName.

public Optional<String> getNodeConnectorIdFromInterfaceName(String interfaceName) {
    LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
    GetNodeconnectorIdFromInterfaceInputBuilder builder = new GetNodeconnectorIdFromInterfaceInputBuilder();
    builder.setIntfName(interfaceName);
    GetNodeconnectorIdFromInterfaceInput input = builder.build();
    if (interfaceManagerRpcService == null) {
        LOG.error("getNodeConnectorIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
        return Optional.empty();
    }
    try {
        LOG.debug("getNodeConnectorIdFromInterfaceName: invoking rpc");
        RpcResult<GetNodeconnectorIdFromInterfaceOutput> output = interfaceManagerRpcService.getNodeconnectorIdFromInterface(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getNodeConnectorIdFromInterfaceName({}) failed: {}", input, output);
            return Optional.empty();
        }
        NodeConnectorId nodeConnId = output.getResult().getNodeconnectorId();
        if (nodeConnId == null) {
            return Optional.empty();
        }
        LOG.debug("getNodeConnectorIdFromInterfaceName({}) succeeded: {}", input, output);
        return Optional.ofNullable(nodeConnId.getValue());
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getNodeConnectorIdFromInterfaceName failed to retrieve target interface name: ", e);
    }
    return Optional.empty();
}
Also used : GetNodeconnectorIdFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) GetNodeconnectorIdFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput) ExecutionException(java.util.concurrent.ExecutionException) GetNodeconnectorIdFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput)

Aggregations

ArrayList (java.util.ArrayList)36 BigInteger (java.math.BigInteger)33 Connector (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Connector)22 Service (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Service)22 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)21 ExecutionException (java.util.concurrent.ExecutionException)19 CoreException (org.eclipse.core.runtime.CoreException)18 List (java.util.List)15 Test (org.junit.Test)15 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)15 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 BoundServices (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)12 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)10 ServerPort (org.eclipse.wst.server.core.ServerPort)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)9 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)9