import org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationEth;
import org.opendaylight.genius.mdsalutil.actions.ActionMoveSourceDestinationIp;
import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack;
+import org.opendaylight.genius.mdsalutil.actions.ActionNxLoadInPort;
import org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit;
import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
import org.opendaylight.genius.mdsalutil.actions.ActionPopMpls;
}
},
+ @Deprecated
nx_load_in_port {
@Override
public Action buildAction(int newActionKey, ActionInfo actionInfo) {
- BigInteger[] actionValues = actionInfo.getBigActionValues();
- NxRegLoad rb = new NxRegLoadBuilder()
- .setDst(new DstBuilder()
- .setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(Boolean.TRUE).build())
- .setStart(0).setEnd(15).build())
- .setValue(actionValues[0]).build();
- ActionBuilder ab = new ActionBuilder();
- ab.setKey(new ActionKey(newActionKey));
- ab.setOrder(newActionKey);
- ab.setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder().setNxRegLoad(rb).build());
- return ab.build();
+ if (actionInfo instanceof ActionNxLoadInPort) {
+ return ((ActionNxLoadInPort) actionInfo).buildAction(newActionKey);
+ } else {
+ return new ActionNxLoadInPort(actionInfo).buildAction(newActionKey);
+ }
}
},
--- /dev/null
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.mdsalutil.actions;
+
+import java.math.BigInteger;
+import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoadBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.nx.reg.load.DstBuilder;
+
+/**
+ * NX load in port action.
+ */
+public class ActionNxLoadInPort extends ActionInfo {
+ private final BigInteger value;
+
+ public ActionNxLoadInPort(BigInteger value) {
+ this(0, value);
+ }
+
+ public ActionNxLoadInPort(int actionKey, BigInteger value) {
+ super(ActionType.nx_load_in_port, new BigInteger[] {value}, actionKey);
+ this.value = value;
+ }
+
+ @Deprecated
+ public ActionNxLoadInPort(ActionInfo actionInfo) {
+ this(actionInfo.getActionKey(), actionInfo.getBigActionValues()[0]);
+ }
+
+ @Override
+ public Action buildAction() {
+ return buildAction(getActionKey());
+ }
+
+ public Action buildAction(int newActionKey) {
+ return new ActionBuilder()
+ .setAction(new NxActionRegLoadNodesNodeTableFlowApplyActionsCaseBuilder()
+ .setNxRegLoad(new NxRegLoadBuilder()
+ .setDst(new DstBuilder()
+ .setDstChoice(new DstNxOfInPortCaseBuilder().setOfInPort(true).build())
+ .setStart(0)
+ .setEnd(15)
+ .build())
+ .setValue(value)
+ .build())
+ .build())
+ .setKey(new ActionKey(newActionKey))
+ .build();
+ }
+
+ public BigInteger getValue() {
+ return value;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2016, 2017 Red Hat, Inc. and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.genius.mdsalutil.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import ch.vorburger.xtendbeans.XtendBeanGenerator;
+import java.math.BigInteger;
+import org.junit.Test;
+import org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstNxOfInPortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
+
+/**
+ * Test for {@link ActionNxLoadInPort}.
+ */
+public class ActionNxLoadInPortTest {
+ private static final BigInteger VALUE = BigInteger.TEN;
+
+ private XtendBeanGenerator generator = new XtendBeanGenerator();
+
+ @Test
+ public void actionInfoTest() {
+ verifyAction(new ActionNxLoadInPort(VALUE).buildAction());
+ }
+
+ @Test
+ public void backwardsCompatibleAction() {
+ verifyAction(new ActionInfo(ActionType.nx_load_in_port, new BigInteger[] {VALUE}).buildAction());
+ }
+
+ private void verifyAction(Action action) {
+ assertTrue(action.getAction() instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase);
+ NxActionRegLoadNodesNodeTableFlowApplyActionsCase actionCase =
+ (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
+ assertNotNull(actionCase.getNxRegLoad());
+ NxRegLoad nxRegLoad = actionCase.getNxRegLoad();
+ assertTrue(nxRegLoad.getDst().getDstChoice() instanceof DstNxOfInPortCase);
+ DstNxOfInPortCase dstNxOfInPortCase = (DstNxOfInPortCase) nxRegLoad.getDst().getDstChoice();
+ assertTrue(dstNxOfInPortCase.isOfInPort());
+ assertEquals(0, nxRegLoad.getDst().getStart().intValue());
+ assertEquals(15, nxRegLoad.getDst().getEnd().intValue());
+ assertEquals(VALUE, nxRegLoad.getValue());
+ }
+
+ @Test
+ public void generateAction() {
+ ActionInfo actionInfo = new ActionNxLoadInPort(VALUE);
+ assertEquals(
+ "new ActionNxLoadInPort(0, " + VALUE + "bi)", generator.getExpression(actionInfo));
+ }
+}