use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase in project openflowplugin by opendaylight.
the class SalToOfSetFieldCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final short version = data.getVersion();
final SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
// convert and inject match
final Optional<Object> conversionMatch = convertorExecutor.convert(source.getSetField(), data);
MatchInjector.inject(conversionMatch, setFieldBuilder, version);
return Optional.of(new ActionBuilder().setActionChoice(new SetFieldCaseBuilder().setSetFieldAction(setFieldBuilder.build()).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase in project openflowplugin by opendaylight.
the class ActionConvertorTest method outputActions.
// TODO - check if this method is needed (private and never used locally) - see line 94
private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> ofActionsList) {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action : ofActionsList) {
if (action.getActionChoice() instanceof OutputActionCase) {
OutputActionCase outputActionCase = (OutputActionCase) action.getActionChoice();
Assert.assertEquals((Integer) 10, outputActionCase.getOutputAction().getMaxLength());
long port = 4294967293L;
Assert.assertEquals(port, (long) outputActionCase.getOutputAction().getPort().getValue());
}
if (action.getActionChoice() instanceof CopyTtlInCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlInCase.class.getName());
}
if (action.getActionChoice() instanceof CopyTtlOutCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlOutCase.class.getName());
}
if (action.getActionChoice() instanceof SetMplsTtlCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetMplsTtlCase.class.getName());
}
if (action.getActionChoice() instanceof DecMplsTtlCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), DecMplsTtlCase.class.getName());
}
if (action.getActionChoice() instanceof PushMplsCase) {
PushMplsCase pushMplsCase = (PushMplsCase) action.getActionChoice();
EtherType etherType = pushMplsCase.getPushMplsAction().getEthertype();
if (etherType != null) {
Assert.assertEquals((Integer) 10, etherType.getValue());
}
}
if (action.getActionChoice() instanceof PopMplsCase) {
PopMplsCase popMplsCase = (PopMplsCase) action.getActionChoice();
Assert.assertEquals((Integer) 10, popMplsCase.getPopMplsAction().getEthertype().getValue());
}
if (action.getActionChoice() instanceof SetQueueCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetQueueCase.class.getName());
}
if (action.getActionChoice() instanceof GroupCase) {
GroupCase groupCase = (GroupCase) action.getActionChoice();
Assert.assertEquals(98, (long) groupCase.getGroupAction().getGroupId());
}
if (action.getActionChoice() instanceof PushVlanCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PushVlanCase.class.getName());
}
if (action.getActionChoice() instanceof PopVlanCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopVlanCase.class.getName());
}
if (action.getActionChoice() instanceof SetNwTtlCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetNwTtlCase.class.getName());
}
if (action.getActionChoice() instanceof DecNwTtlCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), DecNwTtlCase.class.getName());
}
if (action.getActionChoice() instanceof PushPbbCase) {
PushPbbCase pushPbbCase = (PushPbbCase) action.getActionChoice();
if (pushPbbCase.getPushPbbAction().getEthertype() != null) {
Assert.assertEquals((Integer) 10, pushPbbCase.getPushPbbAction().getEthertype().getValue());
}
}
if (action.getActionChoice() instanceof PopMplsCase) {
Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopMplsCase.class.getName());
}
if (action.getActionChoice() instanceof SetFieldCase) {
SetFieldCase setFieldCase = (SetFieldCase) action.getActionChoice();
Assert.assertNotNull(setFieldCase.getSetFieldAction());
/*
Assert.assertEquals(OpenflowBasicClass.class, sf.getMatchEntry().get(0).getOxmClass());
if (sf.getMatchEntry().get(0).getOxmMatchField().equals(InPort.class)) {
InPortCase inPortCase = ((InPortCase) sf.getMatchEntry().get(0).getMatchEntryValue());
Assert.assertEquals(2125, inPortCase.getInPort().getPortNumber().getValue().intValue());
}
*/
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase in project netvirt by opendaylight.
the class NatUtil method getEgressActionsForInterface.
@Nonnull
public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService interfaceManager, String ifName, Long tunnelKey, int pos) {
LOG.debug("getEgressActionsForInterface : called for interface {}", ifName);
GetEgressActionsForInterfaceInputBuilder egressActionsBuilder = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName);
if (tunnelKey != null) {
egressActionsBuilder.setTunnelKey(tunnelKey);
}
List<ActionInfo> listActionInfo = new ArrayList<>();
try {
Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManager.getEgressActionsForInterface(egressActionsBuilder.build());
RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("getEgressActionsForInterface : RPC Call to Get egress actions for interface {} " + "returned with Errors {}", ifName, rpcResult.getErrors());
} else {
List<Action> actions = rpcResult.getResult().getAction();
for (Action action : actions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
if (actionClass instanceof OutputActionCase) {
listActionInfo.add(new ActionOutput(pos++, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
} else if (actionClass instanceof PushVlanActionCase) {
listActionInfo.add(new ActionPushVlan(pos++));
} else if (actionClass instanceof SetFieldCase) {
if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue();
listActionInfo.add(new ActionSetFieldVlanVid(pos++, vlanVid));
}
} else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
listActionInfo.add(new ActionNxResubmit(pos++, tableId));
} else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
listActionInfo.add(new ActionRegLoad(pos++, NxmNxReg6.class, nxRegLoad.getDst().getStart(), nxRegLoad.getDst().getEnd(), nxRegLoad.getValue().longValue()));
}
}
}
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception when egress actions for interface {}", ifName, e);
}
return listActionInfo;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase in project openflowplugin by opendaylight.
the class ActionConvertorV13Test method testGetActions.
/**
* Test {@link ActionConvertor#convert(List, ActionConvertorData)} }.
*/
@Test
public void testGetActions() {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetVlanPcpActionCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpActionCaseBuilder();
SetVlanPcpActionBuilder pcpBuilder = new SetVlanPcpActionBuilder();
pcpBuilder.setVlanPcp(new VlanPcp((short) 7));
vlanPcpCaseBuilder.setSetVlanPcpAction(pcpBuilder.build());
actionBuilder.setAction(vlanPcpCaseBuilder.build());
actionBuilder.setOrder(0);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> salActions = new ArrayList<>();
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
StripVlanActionCaseBuilder stripCaseBuilder = new StripVlanActionCaseBuilder();
StripVlanActionBuilder stripBuilder = new StripVlanActionBuilder();
stripCaseBuilder.setStripVlanAction(stripBuilder.build());
actionBuilder.setAction(stripCaseBuilder.build());
actionBuilder.setOrder(1);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetDlDstActionCaseBuilder dlDstCaseBuilder = new SetDlDstActionCaseBuilder();
SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
dlDstBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
actionBuilder.setAction(dlDstCaseBuilder.build());
actionBuilder.setOrder(2);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetDlSrcActionCaseBuilder dlSrcCaseBuilder = new SetDlSrcActionCaseBuilder();
SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
dlSrcBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));
dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
actionBuilder.setAction(dlSrcCaseBuilder.build());
actionBuilder.setOrder(3);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
Ipv4Builder ipv4Builder = new Ipv4Builder();
/* Correct canonical form for v4 prefix!!! */
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));
nwSrcBuilder.setAddress(ipv4Builder.build());
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
actionBuilder.setAction(nwSrcCaseBuilder.build());
actionBuilder.setOrder(4);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
ipv4Builder = new Ipv4Builder();
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.2/32"));
nwDstBuilder.setAddress(ipv4Builder.build());
SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setAction(nwDstCaseBuilder.build());
actionBuilder.setOrder(5);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetTpSrcActionCaseBuilder tpSrcCaseBuilder = new SetTpSrcActionCaseBuilder();
SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
tpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(54));
tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
actionBuilder.setAction(tpSrcCaseBuilder.build());
actionBuilder.setOrder(6);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetTpDstActionCaseBuilder tpDstCaseBuilder = new SetTpDstActionCaseBuilder();
SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
tpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber(45));
tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
actionBuilder.setAction(tpDstCaseBuilder.build());
actionBuilder.setOrder(7);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetNwTosActionCaseBuilder tosCaseBuilder = new SetNwTosActionCaseBuilder();
SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
tosBuilder.setTos(16);
tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
actionBuilder.setAction(tosCaseBuilder.build());
actionBuilder.setOrder(8);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
SetVlanIdActionCaseBuilder vlanIdCaseBuilder = new SetVlanIdActionCaseBuilder();
SetVlanIdActionBuilder vlanIdBuilder = new SetVlanIdActionBuilder();
vlanIdBuilder.setVlanId(new VlanId(22));
vlanIdCaseBuilder.setSetVlanIdAction(vlanIdBuilder.build());
actionBuilder.setAction(vlanIdCaseBuilder.build());
actionBuilder.setOrder(9);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();
nwSrcBuilder = new SetNwSrcActionBuilder();
Ipv6Builder ipv6Builder = new Ipv6Builder();
/* Use canonical form, 00:00:0000 is not a valid v6 notation */
ipv6Builder.setIpv6Address(new Ipv6Prefix("::5/128"));
nwSrcBuilder.setAddress(ipv6Builder.build());
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
actionBuilder.setAction(nwSrcCaseBuilder.build());
actionBuilder.setOrder(10);
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
nwDstBuilder = new SetNwDstActionBuilder();
ipv6Builder = new Ipv6Builder();
/* Use canonical form, 00:00:0006/64 is not a valid v6 notation - this equates to ::/64 */
ipv6Builder.setIpv6Address(new Ipv6Prefix("::/64"));
nwDstBuilder.setAddress(ipv6Builder.build());
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setAction(nwDstCaseBuilder.build());
actionBuilder.setOrder(11);
salActions.add(actionBuilder.build());
IpMatchBuilder ipMatchBld = new IpMatchBuilder().setIpProtocol((short) 6);
MatchBuilder matchBld = new MatchBuilder().setIpMatch(ipMatchBld.build());
FlowBuilder flowBld = new FlowBuilder().setMatch(matchBld.build());
Flow flow = flowBld.build();
ActionConvertorData data = new ActionConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(new BigInteger("42"));
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
Optional<List<Action>> actionsOptional = convertorManager.convert(salActions, data);
List<Action> actions = actionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of actions", 12, actions.size());
Action action = actions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
MatchEntry entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue()).getVlanPcp().getVlanPcp().intValue());
action = actions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
Assert.assertEquals("Wrong vlan vid", 0, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
action = actions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst.class, false);
Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06", ((EthDstCase) entry.getMatchEntryValue()).getEthDst().getMacAddress().getValue());
action = actions.get(3);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc.class, false);
Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05", ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc().getMacAddress().getValue());
action = actions.get(4);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);
Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
action = actions.get(5);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst.class, false);
Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
action = actions.get(6);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc.class, false);
Assert.assertEquals("Wrong tcp src", 54, ((TcpSrcCase) entry.getMatchEntryValue()).getTcpSrc().getPort().getValue().intValue());
action = actions.get(7);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst.class, false);
Assert.assertEquals("Wrong tcp dst", 45, ((TcpDstCase) entry.getMatchEntryValue()).getTcpDst().getPort().getValue().intValue());
action = actions.get(8);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp.class, false);
Assert.assertEquals("Wrong ip dscp", 4, ((IpDscpCase) entry.getMatchEntryValue()).getIpDscp().getDscp().getValue().intValue());
action = actions.get(9);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
Assert.assertEquals("Wrong vlan id", 22, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
action = actions.get(10);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);
Assert.assertEquals("Wrong ipv6 src", "::5", ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
action = actions.get(11);
setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);
Assert.assertEquals("Wrong ipv6 dst", "::", ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase in project openflowplugin by opendaylight.
the class ActionConvertorV13Test method testToMDSalActions2.
/**
* Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
// @Test
public void testToMDSalActions2() {
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
setMplsTtlBuilder.setMplsTtl((short) 4);
setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
pushVlanBuilder.setEthertype(new EtherType(new EtherType(16)));
pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
pushMplsBuilder.setEthertype(new EtherType(new EtherType(17)));
pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
popMplsBuilder.setEthertype(new EtherType(new EtherType(18)));
popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
actionBuilder.setActionChoice(popMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
setQueueBuilder.setQueueId(1234L);
setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
actionBuilder.setActionChoice(setQueueCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroupId(555L);
groupCaseBuilder.setGroupAction(groupActionBuilder.build());
actionBuilder.setActionChoice(groupCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
nwTtlBuilder.setNwTtl((short) 8);
nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(InPort.class);
matchBuilder.setHasMask(false);
InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
InPortBuilder inPortBuilder = new InPortBuilder();
inPortBuilder.setPortNumber(new PortNumber(1L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
matchBuilder.setMatchEntryValue(inPortCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
pushPbbBuilder.setEthertype(new EtherType(new EtherType(19)));
pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
// Add some unsupported actions and check if they are missing from results
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);
data.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> mdSalActionsOptional = convertorManager.convert(actions, data);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());
OutputActionCase output = (OutputActionCase) action;
Assert.assertEquals("Wrong output port", "42", output.getOutputAction().getOutputNodeConnector().getValue());
Assert.assertEquals("Wrong max length", 52, output.getOutputAction().getMaxLength().intValue());
action = mdSalActions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlOutCase", action.getImplementedInterface().getName());
action = mdSalActions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlInCase", action.getImplementedInterface().getName());
action = mdSalActions.get(3);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetMplsTtlActionCase", action.getImplementedInterface().getName());
SetMplsTtlActionCase setMplsTtl = (SetMplsTtlActionCase) action;
Assert.assertEquals("Wrong mpls ttl", 4, setMplsTtl.getSetMplsTtlAction().getMplsTtl().intValue());
action = mdSalActions.get(4);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecMplsTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushVlanActionCase", action.getImplementedInterface().getName());
PushVlanActionCase pushVlan = (PushVlanActionCase) action;
Assert.assertEquals("Wrong ethertype", 16, pushVlan.getPushVlanAction().getEthernetType().intValue());
action = mdSalActions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());
action = mdSalActions.get(7);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushMplsActionCase", action.getImplementedInterface().getName());
PushMplsActionCase pushMpls = (PushMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 17, pushMpls.getPushMplsAction().getEthernetType().intValue());
action = mdSalActions.get(8);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopMplsActionCase", action.getImplementedInterface().getName());
PopMplsActionCase popMpls = (PopMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 18, popMpls.getPopMplsAction().getEthernetType().intValue());
action = mdSalActions.get(9);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetQueueActionCase", action.getImplementedInterface().getName());
SetQueueActionCase setQueue = (SetQueueActionCase) action;
Assert.assertEquals("Wrong queue-id", 1234, setQueue.getSetQueueAction().getQueueId().intValue());
action = mdSalActions.get(10);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.GroupActionCase", action.getImplementedInterface().getName());
GroupActionCase groupAction = (GroupActionCase) action;
Assert.assertEquals("Wrong group-id", 555, groupAction.getGroupAction().getGroupId().intValue());
action = mdSalActions.get(11);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetNwTtlActionCase", action.getImplementedInterface().getName());
SetNwTtlActionCase setNwTtl = (SetNwTtlActionCase) action;
Assert.assertEquals("Wrong nw ttl", 8, setNwTtl.getSetNwTtlAction().getNwTtl().intValue());
action = mdSalActions.get(12);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecNwTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(13);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetFieldCase", action.getImplementedInterface().getName());
SetFieldCase setField = (SetFieldCase) action;
Assert.assertEquals("Wrong in port", "openflow:null:1", setField.getSetField().getInPort().getValue());
action = mdSalActions.get(14);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushPbbActionCase", action.getImplementedInterface().getName());
PushPbbActionCase pushPbb = (PushPbbActionCase) action;
Assert.assertEquals("Wrong ethertype", 19, pushPbb.getPushPbbAction().getEthernetType().intValue());
action = mdSalActions.get(15);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());
}
Aggregations