*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
import org.opendaylight.openflowplugin.openflow.md.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.extension.ActionExtensionHelper;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwDstReactor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionSetNwSrcReactor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowVersion;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+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.PopMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpAction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValuesV10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.grouping.Extension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author usha@ericsson Action List:This class takes data from SAL layer and
* converts into OF Data
* @author avishnoi@in.ibm.com Added convertor for OF bucket actions to SAL
* actions
- *
*/
public final class ActionConvertor {
private static final Logger logger = LoggerFactory.getLogger(ActionConvertor.class);
- private static final String PREFIX_SEPARATOR = "/";
- final private static Long MAXPortOF13 = new Long(4294967040L); // 0xffffff00
- final private static Long MAXPortOF10 = new Long(0xff00);
private ActionConvertor() {
// NOOP
/**
* Translates SAL actions into OF Library actions
- * @param actions SAL actions
- * @param version Openflow protocol version used
+ *
+ * @param actions SAL actions
+ * @param version Openflow protocol version used
* @param datapathid
* @return OF Library actions
*/
ofAction = SalToOFPushPbbAction(action, actionBuilder);
else if (action instanceof PopPbbActionCase)
ofAction = SalToOFPopPBB(actionBuilder);
- else if (action instanceof ExperimenterAction)
- ofAction = SalToOFExperimenter(action, actionBuilder);
- // 1.0 Actions
+ // 1.0 Actions
else if (action instanceof SetVlanIdActionCase)
ofAction = SalToOFSetVlanId(action, actionBuilder, version);
else if (action instanceof SetVlanPcpActionCase)
ofAction = SalToOFSetTpDst(action, actionBuilder, version);
else if (action instanceof SetNwTosActionCase)
ofAction = SalToOFSetNwTos(action, actionBuilder, version);
-
+ else if (action instanceof GeneralExtensionGrouping) {
+
+ /**
+ * TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
+ * - we might need sessionContext as converter input
+ *
+ */
+
+ GeneralExtensionGrouping extensionCaseGrouping = (GeneralExtensionGrouping) action;
+ Extension extAction = extensionCaseGrouping.getExtension();
+ ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionCaseGrouping.getExtensionKey(), version);
+ ConvertorToOFJava<Action> convertor =
+ OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+ if (convertor != null) {
+ ofAction = convertor.convert(extAction);
+ }
+ } else {
+ // try vendor codecs
+ TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key =
+ new TypeVersionKey<>(
+ (Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) action.getImplementedInterface(),
+ version);
+ ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor =
+ OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+ if (convertor != null) {
+ ofAction = convertor.convert(action);
+ }
+ }
+
if (ofAction != null) {
actionsList.add(ofAction);
}
return emtpyAction(actionBuilder);
}
- private static Action SalToOFExperimenter(
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
- ActionBuilder actionBuilder) {
- ExperimenterActionBuilder experimenterActionBuilder = new ExperimenterActionBuilder();
- experimenterActionBuilder.setExperimenter(((ExperimenterAction) action).getExperimenter());
- actionBuilder.setType(Experimenter.class);
- actionBuilder
- .addAugmentation(
- ExperimenterAction.class,
- (Augmentation<Action>) experimenterActionBuilder);
- return actionBuilder.build();
- }
-
private static Action SalToOFSetVlanId(
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action,
ActionBuilder actionBuilder, short version) {
matchEntriesBuilder.setOxmMatchField(VlanVid.class);
VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder();
vlanVidBuilder.setCfiBit(true);
- vlanVidBuilder.setVlanVid(new Integer(0x0000));
+ vlanVidBuilder.setVlanVid(0x0000);
matchEntriesBuilder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build());
matchEntriesBuilder.setHasMask(false);
matchEntriesList.add(matchEntriesBuilder.build());
logger.error(e.getMessage(), e);
return null;
}
-
+
return actionBuilder.build();
}
logger.error(e.getMessage(), e);
return null;
}
-
+
return actionBuilder.build();
}
private static Action SalToOFPushAction(Integer ethernetType, ActionBuilder actionBuilder) {
EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder();
- ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
+ if (ethernetType != null) {
+ ethertypeActionBuilder.setEthertype(new EtherType(ethernetType));
+ }
/* OF */
actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build());
if (outputAction.getMaxLength() != null) {
maxLenActionBuilder.setMaxLength(outputAction.getMaxLength());
} else {
- maxLenActionBuilder.setMaxLength(new Integer(0));
+ maxLenActionBuilder.setMaxLength(0);
}
actionBuilder.addAugmentation(MaxLengthAction.class, maxLenActionBuilder.build());
Uri uri = outputAction.getOutputNodeConnector();
- if (version >= OFConstants.OFP_VERSION_1_3) {
-
- if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.CONTROLLER
- .getIntValue())));
- } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ALL.getIntValue())));
- } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.ANY.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.FLOOD.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.INPORT.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.LOCAL.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.NORMAL.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
- portAction.setPort(new PortNumber(BinContent.intToUnsignedLong(PortNumberValues.TABLE.getIntValue())));
-
- } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
- logger.error("Unknown Port Type for the Version");
- } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
- .getValue()) < MAXPortOF13) {
- portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
- .getOutputNodeConnector().getValue())));
- } else {
- logger.error("Invalid Port for Output Action");
- }
- } else if (version == OFConstants.OFP_VERSION_1_0) {
-
- if (uri.getValue().equals(OutputPortValues.CONTROLLER.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.CONTROLLER.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.ALL.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.ALL.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.FLOOD.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.FLOOD.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.INPORT.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.INPORT.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.LOCAL.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.LOCAL.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.NORMAL.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.NORMAL.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.TABLE.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.TABLE.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.NONE.toString())) {
- portAction.setPort(new PortNumber((long) PortNumberValuesV10.NONE.getIntValue()));
- } else if (uri.getValue().equals(OutputPortValues.ANY.toString())) {
- logger.error("Unknown Port Type for the Version");
- } else if (InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction.getOutputNodeConnector()
- .getValue()) < MAXPortOF10) {
- portAction.setPort(new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(outputAction
- .getOutputNodeConnector().getValue())));
- } else {
- logger.error("Invalid Port for Output Action");
- }
+ OpenflowVersion ofVersion = OpenflowVersion.get(version);
+ Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(ofVersion, uri.getValue());
+ if (OpenflowPortsUtil.checkPortValidity(ofVersion, portNumber)) {
+ portAction.setPort(new PortNumber(portNumber));
+ } else {
+ logger.error("Invalid Port specified " + portNumber + " for Output Action for OF version:" + ofVersion);
}
- actionBuilder
- .setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
+ actionBuilder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class);
actionBuilder.addAugmentation(PortAction.class, portAction.build());
return actionBuilder.build();
* Method to convert OF actions associated with bucket to SAL Actions.
*
* @param actionList
+ * @param ofVersion current ofp version
+ * @param actionPath TODO
* @return List of converted SAL Actions.
*/
public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
- List<Action> actionList) {
+ List<Action> actionList, OpenflowVersion ofVersion, ActionPath actionPath) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<>();
for (Action action : actionList) {
if (action.getType().equals(
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output.class)) {
- bucketActions.add(ofToSALOutputAction(action));
+ bucketActions.add(ofToSALOutputAction(ofVersion, action));
} else if (action.getType().equals(
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group.class)) {
} else if (action.getType().equals(
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetField.class)) {
- bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.ofToSALSetField(action))
+ bucketActions.add(new SetFieldCaseBuilder().setSetField(MatchConvertorImpl.fromOFSetFieldToSALSetFieldAction(action, ofVersion))
.build());
} else if (action.getType().equals(
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb.class)) {
} else if (action.getType().equals(
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter.class)) {
- // bucketActions.add(ofToSALExperimenter(action));
- // TODO: Need to explore/discuss on how to handle experimenter
- // case.
+ /**
+ * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
+ * - we might also need a way on how to identify exact type of augmentation to be
+ * used as match can be bound to multiple models
+ */
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction =
+ ActionExtensionHelper.processAlienAction(action, ofVersion, actionPath);
+ if (processedAction != null) {
+ bucketActions.add(processedAction);
+ }
}
-
}
return bucketActions;
}
/**
* Method converts OF Output action object to SAL Output action object.
*
- * @param action
- * org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
- * action.rev130731.actions.actions.list.Action
+ * @param ofVersion
+ * @param ofVersion
+ * @param action org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.
+ * action.rev130731.actions.actions.list.Action
* @return OutputAction
*/
- public static OutputActionCase ofToSALOutputAction(Action action) {
-
+ public static OutputActionCase ofToSALOutputAction(OpenflowVersion ofVersion, Action action) {
OutputActionBuilder outputAction = new OutputActionBuilder();
PortAction port = action.getAugmentation(PortAction.class);
if (port != null) {
- outputAction.setOutputNodeConnector(new Uri(port.getPort().getValue().toString()));
+ CommonPort.PortNumber protocolAgnosticPort = OpenflowPortsUtil.getProtocolAgnosticPort(
+ ofVersion, port.getPort().getValue());
+ String portNumberAsString = OpenflowPortsUtil.portNumberToString(protocolAgnosticPort);
+ outputAction.setOutputNodeConnector(new Uri(portNumberAsString));
} else {
logger.error("Provided action is not OF Output action, no associated port found!");
}
return new PushPbbActionCaseBuilder().setPushPbbAction(pushPbbAction.build()).build();
}
- public static Object ofToSALExperimenter(Action action) {
-
- ExperimenterAction ExperimenterAction = action.getAugmentation(ExperimenterAction.class);
-
- return null;
- /*
- * TODO: Need to explore/discuss about how to handle experimenter
- */
-
- }
}