import org.opendaylight.genius.mdsalutil.ActionInfo;
import org.opendaylight.genius.mdsalutil.ActionType;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
import org.opendaylight.genius.mdsalutil.packet.Ethernet;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
actionInfos.add(new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] {
BigInteger.valueOf(0)}));
}
- actionInfos.add(new ActionInfo(ActionType.output, new String[] { Long.toString(portNum) }));
+ actionInfos.add(new ActionOutput(portNum));
return actionInfos;
}
import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
import org.opendaylight.genius.mdsalutil.actions.ActionRegLoad;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
result.add(new ActionInfo(ActionType.set_field_vlan_vid,
new String[]{Long.toString(vlanVid)}, actionKeyStart++));
}
- result.add(new ActionInfo(ActionType.output, new String[]{portNo}, actionKeyStart++));
+ result.add(new ActionOutput(actionKeyStart++, Long.parseLong(portNo)));
}else{
long regValue = MetaDataUtil.getReg6ValueForLPortDispatcher(ifIndex, NwConstants.DEFAULT_SERVICE_INDEX);
result.add(new ActionRegLoad(actionKeyStart++, NxmNxReg6.class, IfmConstants.REG6_START_INDEX,
result.add(new ActionInfo(ActionType.set_tunnel_src_ip, new BigInteger[]{sourceIp},
actionKeyStart++));
}
- result.add(new ActionInfo(ActionType.output, new String[]{portNo}, actionKeyStart++));
+ result.add(new ActionOutput(actionKeyStart++, Long.parseLong(portNo)));
break;
default:
import java.util.List;
import org.opendaylight.genius.mdsalutil.NwConstants.LearnFlowModsType;
import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
import org.opendaylight.genius.mdsalutil.actions.ActionRegLoad;
import org.opendaylight.genius.mdsalutil.actions.ActionRegMove;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
}
},
+ @Deprecated
output {
@Override
public Action buildAction(int newActionKey, ActionInfo actionInfo) {
- String[] actionValues = actionInfo.getActionValues();
- String port = actionValues[0];
- int maxLength = 0;
-
- if (actionValues.length == 2) {
- maxLength = Integer.valueOf(actionValues[1]);
+ if (actionInfo instanceof ActionOutput) {
+ return ((ActionOutput) actionInfo).buildAction(newActionKey);
+ } else {
+ // TODO Migrate all users to ActionOutput
+ return new ActionOutput(actionInfo.getActionValues()).buildAction(newActionKey);
}
-
- return new ActionBuilder().setAction(
- new OutputActionCaseBuilder().setOutputAction(
- new OutputActionBuilder().setMaxLength(maxLength)
- .setOutputNodeConnector(new Uri(port)).build()).build())
- .setKey(new ActionKey(newActionKey)).build();
}
},
--- /dev/null
+/*
+ * Copyright © 2016 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 org.opendaylight.genius.mdsalutil.ActionInfo;
+import org.opendaylight.genius.mdsalutil.ActionType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+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;
+
+/**
+ * Output action.
+ */
+public class ActionOutput extends ActionInfo {
+ private final long portNum;
+ private final int maxLength;
+
+ public ActionOutput(long portNum) {
+ super(ActionType.output, new String[] { Long.toString(portNum) });
+ this.portNum = portNum;
+ this.maxLength = 0;
+ }
+
+ public ActionOutput(long portNum, int maxLength) {
+ super(ActionType.output, new String[] { Long.toString(portNum), Integer.toString(maxLength) });
+ this.portNum = portNum;
+ this.maxLength = maxLength;
+ }
+
+ public ActionOutput(int actionKey, long portNum) {
+ super(ActionType.output, new String[] { Long.toString(portNum) }, actionKey);
+ this.portNum = portNum;
+ this.maxLength = 0;
+ }
+
+ @Deprecated
+ public ActionOutput(String[] actionValues) {
+ this(Long.parseLong(actionValues[0]), actionValues.length == 2 ? Integer.parseInt(actionValues[1]) : 0);
+ }
+
+ @Override
+ public Action buildAction() {
+ return buildAction(getActionKey());
+ }
+
+ public Action buildAction(int newActionKey) {
+ return new ActionBuilder().setAction(
+ new OutputActionCaseBuilder().setOutputAction(
+ new OutputActionBuilder().setMaxLength(maxLength)
+ .setOutputNodeConnector(new Uri(Long.toString(portNum))).build()).build())
+ .setKey(new ActionKey(newActionKey)).build();
+ }
+}
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.genius.mdsalutil.actions.ActionOutput;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] { null }));
listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid, new String[] { String.valueOf(vlanid) }));
}
- listActionInfo.add(new ActionInfo(ActionType.output, new String[] { inport, "65535" }));
+ listActionInfo.add(new ActionOutput(Long.parseLong(inport), 65535));
listBucketInfo.add(new BucketInfo(listActionInfo));
String groupName = "Test Group";