Search in sources :

Example 81 with Actions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.

the class VpnServiceChainUtils method buildLPortDispFromScfToL3VpnFlow.

/**
 * Build the flow that must be inserted when there is a ScHop whose
 * egressPort is a VPN Pseudo Port. In that case, packets must be moved
 * from the SCF to VPN Pipeline.
 * <p>
 * Flow matches:  VpnPseudo port lPortTag + SI=L3VPN
 * Actions: Write vrfTag in Metadata + goto FIB Table
 * </p>
 * @param vpnId Dataplane identifier of the VPN, the Vrf Tag.
 * @param dpId The DPN where the flow must be installed/removed
 * @param lportTag Dataplane identifier for the VpnPseudoPort
 * @param addOrRemove States if it must build a Flow to be created or
 *     removed
 *
 * @return the Flow object
 */
public static Flow buildLPortDispFromScfToL3VpnFlow(Long vpnId, BigInteger dpId, Integer lportTag, int addOrRemove) {
    LOG.info("buildLPortDispFlowForScf vpnId={} dpId={} lportTag={} addOrRemove={} ", vpnId, dpId, lportTag, addOrRemove);
    List<MatchInfo> matches = buildMatchOnLportTagAndSI(lportTag, ServiceIndex.getIndex(NwConstants.L3VPN_SERVICE_NAME, NwConstants.L3VPN_SERVICE_INDEX));
    List<Instruction> instructions = buildSetVrfTagAndGotoFibInstructions(vpnId.intValue());
    String flowRef = getScfToL3VpnLportDispatcherFlowRef(lportTag);
    Flow result;
    if (addOrRemove == NwConstants.ADD_FLOW) {
        result = MDSALUtil.buildFlowNew(NwConstants.LPORT_DISPATCHER_TABLE, flowRef, CloudServiceChainConstants.DEFAULT_SCF_FLOW_PRIORITY, flowRef, 0, 0, VpnServiceChainUtils.getCookieL3(vpnId.intValue()), matches, instructions);
    } else {
        result = new FlowBuilder().setTableId(NwConstants.LPORT_DISPATCHER_TABLE).setId(new FlowId(flowRef)).build();
    }
    return result;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 82 with Actions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.

the class ExternalNetworkGroupInstaller method buildExtNetGroupEntity.

private GroupEntity buildExtNetGroupEntity(String macAddress, String subnetName, Uint32 groupId, String extInterface, Uint64 dpnId) {
    List<ActionInfo> actionList = new ArrayList<>();
    final int setFieldEthDestActionPos = 0;
    List<ActionInfo> egressActionList = new ArrayList<>();
    if (extInterface != null) {
        egressActionList = NatUtil.getEgressActionsForInterface(odlInterfaceRpcService, itmRpcService, interfaceManager, extInterface, null, setFieldEthDestActionPos + 1, false);
    }
    if (Strings.isNullOrEmpty(macAddress) || egressActionList.isEmpty()) {
        if (Strings.isNullOrEmpty(macAddress)) {
            LOG.trace("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "GW mac has not been resolved for subnet {} extInterface {}", groupId, subnetName, extInterface);
        } else {
            LOG.warn("buildExtNetGroupEntity : Building ext-net group {} entry with drop action since " + "no egress actions were found for subnet {} extInterface {}", groupId, subnetName, extInterface);
        }
        actionList.add(new ActionDrop());
    } else {
        LOG.trace("Building ext-net group {} entry for subnet {} extInterface {} macAddress {}", groupId, subnetName, extInterface, macAddress);
        actionList.add(new ActionSetFieldEthernetDestination(setFieldEthDestActionPos, new MacAddress(macAddress)));
        actionList.addAll(egressActionList);
    }
    List<BucketInfo> listBucketInfo = new ArrayList<>();
    listBucketInfo.add(new BucketInfo(actionList));
    return MDSALUtil.buildGroupEntity(dpnId, groupId.longValue(), subnetName, GroupTypes.GroupAll, listBucketInfo);
}
Also used : ActionSetFieldEthernetDestination(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldEthernetDestination) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop)

Example 83 with Actions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.

the class ExternalRoutersListener method makeTunnelTableEntry.

private void makeTunnelTableEntry(Uint64 dpnId, Uint32 serviceId, Uint32 l3Vni, List<Instruction> customInstructions, TypedWriteTransaction<Configuration> confTx, ProviderTypes extNwProvType) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    LOG.debug("makeTunnelTableEntry : DpnId = {} and serviceId = {} and actions = {}", dpnId, serviceId, customInstructions);
    if (NatUtil.isOpenStackVniSemanticsEnforcedForGreAndVxlan(elanManager, extNwProvType)) {
        mkMatches.add(new MatchTunnelId(Uint64.valueOf(l3Vni)));
    } else {
        mkMatches.add(new MatchTunnelId(Uint64.valueOf(serviceId)));
    }
    Map<InstructionKey, Instruction> customInstructionsMap = new HashMap<InstructionKey, Instruction>();
    int instructionKey = 0;
    for (Instruction instructionObj : customInstructions) {
        customInstructionsMap.put(new InstructionKey(++instructionKey), instructionObj);
    }
    Flow terminatingServiceTableFlowEntity = MDSALUtil.buildFlowNew(NwConstants.INTERNAL_TUNNEL_TABLE, getFlowRef(dpnId, NwConstants.INTERNAL_TUNNEL_TABLE, serviceId, ""), NatConstants.DEFAULT_VPN_INTERNAL_TUNNEL_TABLE_PRIORITY, String.format("%s:%s", "TST Flow Entry ", serviceId), 0, 0, Uint64.valueOf(COOKIE_TUNNEL.toJava().add(BigInteger.valueOf(serviceId.longValue()))), mkMatches, customInstructionsMap);
    mdsalManager.addFlow(confTx, dpnId, terminatingServiceTableFlowEntity);
}
Also used : MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 84 with Actions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.

the class ArpResponderUtil method getActions.

/**
 * Get List of actions for ARP Responder Flows.
 *
 * <p>
 * Actions consists of all the ARP actions and Resubmit Action to table
 * {@link NwConstants#ELAN_BASE_TABLE} such that packets can flow ELAN Rule
 *
 * @param ipAddress
 *            IP Address for which ARP Response packet is to be generated
 * @param macAddress
 *            MacAddress for which ARP Response packet is to be generated
 * @return List of ARP Responder Actions actions
 */
private static List<Action> getActions(IInterfaceManager ifaceMgrRpcService, ItmRpcService itmRpcService, String ifName, String ipAddress, String macAddress, boolean isTunnelInterface) {
    AtomicInteger actionCounter = new AtomicInteger();
    List<Action> actions = arpActions.apply(actionCounter, macAddress, ipAddress);
    actions.addAll(getEgressActionsForInterface(ifaceMgrRpcService, itmRpcService, ifName, actionCounter.get(), isTunnelInterface));
    LOG.trace("Total Number of actions is {}", actionCounter);
    return actions;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 85 with Actions

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions in project netvirt by opendaylight.

the class DhcpPktHandler method getEgressAction.

private List<Action> getEgressAction(String interfaceName, Uint64 tunnelId) {
    try {
        if (interfaceManager.isItmDirectTunnelsEnabled() && tunnelId != null) {
            GetEgressActionsForTunnelInputBuilder egressAction = new GetEgressActionsForTunnelInputBuilder().setIntfName(interfaceName);
            egressAction.setTunnelKey(tunnelId.longValue());
            RpcResult<GetEgressActionsForTunnelOutput> rpcResult = itmRpcService.getEgressActionsForTunnel(egressAction.build()).get();
            if (!rpcResult.isSuccessful()) {
                LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
            } else {
                return new ArrayList<>(rpcResult.getResult().nonnullAction().values());
            }
        } else {
            GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
            if (tunnelId != null) {
                egressAction.setTunnelKey(tunnelId.longValue());
            }
            Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
            RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
            if (!rpcResult.isSuccessful()) {
                LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
            } else {
                return new ArrayList<>(rpcResult.getResult().nonnullAction().values());
            }
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
    }
    return Collections.emptyList();
}
Also used : GetEgressActionsForTunnelInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelInputBuilder) GetEgressActionsForTunnelOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetEgressActionsForTunnelOutput) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ArrayList (java.util.ArrayList)139 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)86 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)45 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)42 Test (org.junit.Test)40 PushVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder)33 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)32 PopMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder)32 PopPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder)32 PopVlanActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder)32 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)32 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)32 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)29 ByteBuf (io.netty.buffer.ByteBuf)28 ExecutionException (java.util.concurrent.ExecutionException)28 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)27 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)26 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)24 SetMplsTtlActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder)22 SetNwTtlActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder)22