Merge "Improve flow collection"
authorJozef Bacigal <jozef.bacigal@pantheon.tech>
Thu, 1 Jun 2017 11:16:32 +0000 (11:16 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 1 Jun 2017 11:16:32 +0000 (11:16 +0000)
31 files changed:
applications/bulk-o-matic/src/main/yang/sal-bulk-flow.yang
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/ForwardingRulesManager.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/AbstractListeningCommiter.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/DeviceMastership.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/ForwardingRulesManagerImpl.java
applications/forwardingrules-manager/src/main/resources/org/opendaylight/blueprint/forwardingrules-manager.xml
applications/forwardingrules-manager/src/test/java/test/mock/FlowListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/GroupListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/MeterListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/NodeListenerTest.java
applications/forwardingrules-manager/src/test/java/test/mock/TableFeaturesListenerTest.java
openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/extension/ActionExtensionHelper.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalPopPbbCase.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetFieldCase.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwDstCase.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTosCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpDstCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpSrcCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanIdCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanPcpCase.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalStripVlanCase.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/data/ActionResponseConvertorData.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/flow/FlowStatsResponseConvertor.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/ActionConvertorV13Test.java

index 3eda3a0342bd1430af041fc255bb3b4b2a1ab37d..1915e8c760c7a3cd002c66a0cbb5dd5085045312 100644 (file)
@@ -77,6 +77,7 @@ module sal-bulk-flow {
             leaf create-parents {
                 type boolean;
                 mandatory true;
+                default true;
                 status current;
                 description "Create parents if doesn't exist";
             }
index bef847c025e96e7ba4bbc6b5a1861d586ae9be9f..0dcd3aa17674830a51a07021b36f6d7fb6ab7e47 100644 (file)
@@ -119,10 +119,22 @@ public interface ForwardingRulesManager extends AutoCloseable {
     ForwardingRulesCommiter<TableFeatures> getTableFeaturesCommiter();
 
     /**
-     * Returns the config-subsystem/fallback configuration of FRM
-     * @return ForwardingRulesManagerConfig
+     * Check if reconciliation is disabled by user.
+     * @return true if reconciliation is disabled, else false
      */
-    ForwardingRulesManagerConfig getConfiguration();
+    boolean isReconciliationDisabled();
+
+    /**
+     * Check if stale marking is enabled for switch reconciliation.
+     * @return true if stale marking is enabled, else false
+     */
+    boolean isStaleMarkingEnabled();
+
+    /**
+     * Return number of reconciliation retry are allowed.
+     * @return number of retries.
+     */
+    int getReconciliationRetryCount();
 
     /**
      * Method checks if *this* instance of openflowplugin is owner of
index 5a77d9e1cd76341c9464809715ec79021ee3a789..c3df34644ca33d6038041a80bf482e48c058da94 100644 (file)
@@ -64,7 +64,7 @@ public abstract class AbstractListeningCommiter <T extends DataObject> implement
                 }
             }
             else{
-                if (provider.getConfiguration().isStaleMarkingEnabled()) {
+                if (provider.isStaleMarkingEnabled()) {
                     LOG.info("Stale-Marking ENABLED and switch {} is NOT connected, storing stale entities",
                             nodeIdent.toString());
                     // Switch is NOT connected
index 182b95343cae338eedaecb6acdc057677f69dd43..82aec1cba4138fd81906638e414fe4b77695a797 100644 (file)
@@ -77,7 +77,6 @@ public class DeviceMastership implements ClusterSingletonService, AutoCloseable
     public void setDeviceOperationalStatus(boolean inOperDS) {
         isDeviceInOperDS.set(inOperDS);
         if(canReconcile()) {
-            LOG.info("Triggering reconciliation for device {}", nodeId.getValue());
             reconcliationAgent.reconcileConfiguration(fcnIID);
         }
     }
index 52522f7230330072bc05c64a7fa850b4a822eafc..c530713c59c3ca7ddfbafcfb19acd8502930c708 100644 (file)
@@ -106,8 +106,14 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
 
     @Override
     public void reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode) {
+        if (provider.isReconciliationDisabled()) {
+            LOG.debug("Reconciliation is disabled by user. Skipping reconciliation of node : {}", connectedNode
+                    .firstKeyOf(Node.class));
+            return;
+        }
         if (provider.isNodeOwner(connectedNode)) {
-            if (provider.getConfiguration().isStaleMarkingEnabled()) {
+            LOG.info("Triggering reconciliation for device {}", connectedNode.firstKeyOf(Node.class));
+            if (provider.isStaleMarkingEnabled()) {
                 LOG.info("Stale-Marking is ENABLED and proceeding with deletion of stale-marked entities on switch {}",
                         connectedNode.toString());
                 reconciliationPreProcess(connectedNode);
@@ -164,7 +170,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                 Map<Long, ListenableFuture<?>> groupFutures = new HashMap<>();
 
                 while ((!(toBeInstalledGroups.isEmpty()) || !(suspectedGroups.isEmpty())) &&
-                        (counter <= provider.getConfiguration().getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
+                        (counter <= provider.getReconciliationRetryCount())) { //also check if the counter has not crossed the threshold
 
                     if (toBeInstalledGroups.isEmpty() && !suspectedGroups.isEmpty()) {
                         LOG.error("These Groups are pointing to node-connectors that are not up yet {}", suspectedGroups.toString());
@@ -249,7 +255,7 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                 if (!toBeInstalledGroups.isEmpty()) {
                     for (Group group : toBeInstalledGroups) {
                         LOG.error("Installing the group {} finally although the port is not up after checking for {} times "
-                                , group.getGroupId().toString(), provider.getConfiguration().getReconciliationRetryCount());
+                                , group.getGroupId().toString(), provider.getReconciliationRetryCount());
                         addGroup(groupFutures, group);
                     }
                 }
index d055ca260d5e7a8cc44eacd3fca92066ba3a59ea..9bfa94363938c9942216c7044c0ba9c51c051447 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicLong;
+import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -62,6 +63,9 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     private final ForwardingRulesManagerConfig forwardingRulesManagerConfig;
     private final ClusterSingletonServiceProvider clusterSingletonServiceProvider;
     private final NotificationProviderService notificationService;
+    private final boolean disableReconciliation;
+    private final boolean staleMarkingEnabled;
+    private final int reconciliationRetryCount;
 
     private ForwardingRulesCommiter<Flow> flowListener;
     private ForwardingRulesCommiter<Group> groupListener;
@@ -75,7 +79,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
                                       final RpcConsumerRegistry rpcRegistry,
                                       final ForwardingRulesManagerConfig config,
                                       final ClusterSingletonServiceProvider clusterSingletonService,
-                                      final NotificationProviderService notificationService) {
+                                      final NotificationProviderService notificationService,
+                                      final boolean disableReconciliation,
+                                      final boolean staleMarkingEnabled,
+                                      final int reconciliationRetryCount) {
         this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
         this.forwardingRulesManagerConfig = Preconditions.checkNotNull(config, "Configuration for FRM cannot be null");
         this.clusterSingletonServiceProvider = Preconditions.checkNotNull(clusterSingletonService,
@@ -93,6 +100,10 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
                 "RPC SalMeterService not found.");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
+
+        this.disableReconciliation = disableReconciliation;
+        this.staleMarkingEnabled = staleMarkingEnabled;
+        this.reconciliationRetryCount = reconciliationRetryCount;
     }
 
     @Override
@@ -217,8 +228,18 @@ public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
     }
 
     @Override
-    public ForwardingRulesManagerConfig getConfiguration() {
-        return forwardingRulesManagerConfig;
+    public boolean isReconciliationDisabled() {
+        return this.disableReconciliation;
+    }
+
+    @Override
+    public boolean isStaleMarkingEnabled() {
+        return this.staleMarkingEnabled;
+    }
+
+    @Override
+    public int getReconciliationRetryCount() {
+        return this.reconciliationRetryCount;
     }
 
     @Override
index c7d81bdc0213e165b918b736508f7a142e1c9387..34a6dc8f455f03674fa1e5cf9caaaabcbced241f 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
         odl:use-default-for-reference-types="true">
 
   <odl:clustered-app-config id="frmConfig"
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
 
+  <cm:property-placeholder persistent-id="org.opendaylight.openflowplugin"
+                           placeholder-prefix="${frm-"
+                           update-strategy="none">
+    <cm:default-properties>
+      <!-- Disable switch reconciliation -->
+      <cm:property name="disable-reconciliation" value="false"/>
+      <!-- Enable stale marking for switch reconciliation -->
+      <cm:property name="stale-marking-enabled" value="false"/>
+      <!-- Number of retries for switch reconciliation -->
+      <cm:property name="reconciliation-retry-count" value="5"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
   <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
           init-method="start" destroy-method="close">
     <argument ref="dataBroker"/>
@@ -18,5 +32,9 @@
     <argument ref="frmConfig"/>
     <argument ref="clusterSingletonService"/>
     <argument ref="notificationService"/>
+    <argument value="${frm-disable-reconciliation}"/>
+    <argument value="${frm-stale-marking-enabled}"/>
+    <argument value="${frm-reconciliation-retry-count}"/>
+
   </bean>
 </blueprint>
\ No newline at end of file
index 997c556f756b412a5e40e2427ba0e8e70eb4d5e8..5246750de9afd6c176b3536549adb85a14f5b350 100644 (file)
@@ -74,7 +74,7 @@ public class FlowListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 91f437c955a4bde97c7f71fae0064a37b601aca5..7c990531d340a4bddfa1effa77d693a2b0d77938 100644 (file)
@@ -64,7 +64,7 @@ public class GroupListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 1afff7b91405f82da35a5d9596b07948becd4274..6fca053ef61ad0963ad6c6863784116a17d5a334 100644 (file)
@@ -64,7 +64,7 @@ public class MeterListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false, 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 4834f9f84037d24bb8892fbfd1f5e93cf4c10317..cfae7190217fe69c057187610ce58b7435a220f1 100644 (file)
@@ -46,7 +46,7 @@ public class NodeListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false ,false ,5);
         forwardingRulesManager.start();
     }
 
index 1060e795bde9eb1268effc99027183eb3840d5b9..52e0b851697eaf02f53dc9dda16945aa999f7127 100644 (file)
@@ -59,7 +59,7 @@ public class TableFeaturesListenerTest extends FRMTest {
                 rpcProviderRegistryMock,
                 getConfig(),
                 clusterSingletonService,
-                notificationService);
+                notificationService, false, false , 5);
         forwardingRulesManager.start();
         // TODO consider tests rewrite (added because of complicated access)
         forwardingRulesManager.setDeviceMastershipManager(deviceMastershipManager);
index 0adf815b8aa561f08ca932bbf3a6f5186655e9ee..a3759234c52c00aa9cd9d3aecb8f0d18870d06aa 100644 (file)
 # then to format supported by device, and reversed when deserializing.
 #
 # use-single-layer-serialization=true
+
+#############################################################################
+#                                                                           #
+#            Forwarding Rule Manager Application Configuration              #
+#                                                                           #
+#############################################################################
+
+# Disable the default switch reconciliation mechanism
+# disable-reconciliation=false
+
+# Enable stale marking for switch reconciliation. Once user enable this feature
+# forwarding rule manager will keep track of any change to the config data store
+# while the switch is disconnected from controller. Once switch reconnect to the
+# controller it will apply those changes to the switch and do the reconciliation
+# of other configuration as well.
+# NOTE: This option will be effective only if disable_reconciliation=false.
+# stale-marking-enabled=false
+
+# Number of time forwarding rules manager should retry to reconcile any specific
+# configuration.
+# reconciliation-retry-count=5
index 3b53c96815adbaab1586f1263ed7aab618164689..c919099948de5c035f3686c5da1c5a53d6a13e63 100644 (file)
@@ -457,7 +457,6 @@ public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenF
                     modifiable = false;
                     break;
                 default:
-                    LOG.warn("Unsupported configuration property '{}={}'", key, sValue);
                     return;
             }
 
index 994e223e0ca35451339ee5d415614fb848a44109..80afdd46dc6e2df500309f182ef5383007be94b4 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.extension;
 
+import java.util.Objects;
 import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
@@ -41,6 +43,12 @@ public final class ActionExtensionHelper {
     processAlienAction(final Action action, final OpenflowVersion ofVersion, final ActionPath actionPath) {
         ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
+        final ExtensionConverterProvider extensionConvertorProvider = OFSessionUtil.getExtensionConvertorProvider();
+
+        if (Objects.isNull(extensionConvertorProvider)) {
+            return null;
+        }
+
         if(action.getActionChoice() instanceof ExperimenterIdCase) {
             ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
             /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
@@ -48,15 +56,16 @@ public final class ActionExtensionHelper {
                     ofVersion.getVersion(),
                     actionCase.getExperimenter().getExperimenter().getValue(),
                     actionCase.getExperimenter().getSubType());
-            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+            convertor = extensionConvertorProvider.getActionConverter(key);
         } else if (action.getActionChoice() != null){
             ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
-            convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+            convertor = extensionConvertorProvider.getActionConverter(key);
         }
+
         if (convertor != null) {
-            alienAction = convertor.convert(
-                    action, actionPath);
+            alienAction = convertor.convert(action, actionPath);
         }
+
         return alienAction;
     }
 }
index c689b0c8a512de75addd2fca8435f7f0e7a8dce6..f9e75fd93a764c0e0a15514c8ce50ab8207c294a 100644 (file)
@@ -28,11 +28,19 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cas
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushMplsCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushPbbCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalPushVlanCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetDlDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetDlSrcCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetFieldCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetMplsTtlCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTosCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetNwTtlCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetQueueCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetTpDstCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetTpSrcCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetVlanIdCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalSetVlanPcpCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.cases.OfToSalStripVlanCase;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
@@ -70,16 +78,26 @@ public final class ActionResponseConvertor extends Convertor<
             .addCase(new OfToSalGroupCase())
             .addCase(new OfToSalOutputActionCase())
             .addCase(new OfToSalPopMplsCase())
-            .addCase(new OfToSalPopPbbCase())
             .addCase(new OfToSalPopVlanCase())
             .addCase(new OfToSalPushMplsCase())
             .addCase(new OfToSalPushPbbCase())
             .addCase(new OfToSalPushVlanCase())
-            .addCase(new OfToSalSetFieldCase())
             .addCase(new OfToSalSetMplsTtlCase())
-            .addCase(new OfToSalSetNwDstCase())
             .addCase(new OfToSalSetNwTtlCase())
             .addCase(new OfToSalSetQueueCase())
+            // OpenFlow 1.3 specific actions
+            .addCase(new OfToSalPopPbbCase())
+            .addCase(new OfToSalSetFieldCase())
+            // OpenFlow 1.0 specific actions
+            .addCase(new OfToSalSetNwSrcCase())
+            .addCase(new OfToSalSetNwDstCase())
+            .addCase(new OfToSalSetNwTosCase())
+            .addCase(new OfToSalSetDlSrcCase())
+            .addCase(new OfToSalSetDlDstCase())
+            .addCase(new OfToSalSetTpSrcCase())
+            .addCase(new OfToSalSetTpDstCase())
+            .addCase(new OfToSalSetVlanPcpCase())
+            .addCase(new OfToSalSetVlanIdCase())
             .addCase(new OfToSalStripVlanCase());
     private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(Action.class);
 
index 0867b7724d451043f749e194d9c31a0ec6f355f5..910351c5071b0c983421cc18031b2047f4db8bb6 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 
 public class OfToSalPopPbbCase extends ConvertorCase<PopPbbCase, Action, ActionResponseConvertorData> {
     public OfToSalPopPbbCase() {
-        super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+        super(PopPbbCase.class, true, OFConstants.OFP_VERSION_1_3);
     }
 
     @Override
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlDstCase.java
new file mode 100644 (file)
index 0000000..9701afa
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+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.SetDlDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlDstCase;
+
+public class OfToSalSetDlDstCase extends ConvertorCase<SetDlDstCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetDlDstCase() {
+        super(SetDlDstCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetDlDstActionCaseBuilder()
+                .setSetDlDstAction(new SetDlDstActionBuilder()
+                        .setAddress(source.getSetDlDstAction().getDlDstAddress())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetDlSrcCase.java
new file mode 100644 (file)
index 0000000..3a1ae64
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+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.SetDlSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetDlSrcCase;
+
+public class OfToSalSetDlSrcCase extends ConvertorCase<SetDlSrcCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetDlSrcCase() {
+        super(SetDlSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetDlSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetDlSrcActionCaseBuilder()
+                .setSetDlSrcAction(new SetDlSrcActionBuilder()
+                        .setAddress(source.getSetDlSrcAction().getDlSrcAddress())
+                        .build())
+                .build());
+    }
+}
index 3672d3f0302e8af87a1c69ccbd932df875bfeebc..9a3def349ccb9bebe6663ba66ff176b6a2abc5bb 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 
 public class OfToSalSetFieldCase extends ConvertorCase<SetFieldCase, Action, ActionResponseConvertorData> {
     public OfToSalSetFieldCase() {
-        super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+        super(SetFieldCase.class, true, OFConstants.OFP_VERSION_1_3);
     }
 
     @Override
index 2f7d1710baf795206154a2fd9b311cc8edc0b003..98eccff4e503e3d99fc0d874ba86c36f17728ec6 100644 (file)
@@ -14,19 +14,26 @@ import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 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.SetNwDstActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwDstCase;
 
 public class OfToSalSetNwDstCase extends ConvertorCase<SetNwDstCase, Action, ActionResponseConvertorData> {
     public OfToSalSetNwDstCase() {
-        super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+        super(SetNwDstCase.class, true, OFConstants.OFP_VERSION_1_0);
     }
 
     @Override
     public Optional<Action> process(@Nonnull final SetNwDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
-        SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
-        return Optional.of(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
+        return Optional.of(new SetNwDstActionCaseBuilder()
+                .setSetNwDstAction(new SetNwDstActionBuilder()
+                        .setAddress(new Ipv4Builder()
+                                .setIpv4Address(IpConversionUtil.createPrefix(source.getSetNwDstAction().getIpAddress()))
+                                .build())
+                        .build())
+                .build());
     }
 }
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwSrcCase.java
new file mode 100644 (file)
index 0000000..32b3753
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
+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.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
+
+public class OfToSalSetNwSrcCase extends ConvertorCase<SetNwSrcCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetNwSrcCase() {
+        super(SetNwSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetNwSrcActionCaseBuilder()
+                .setSetNwSrcAction(new SetNwSrcActionBuilder()
+                        .setAddress(new Ipv4Builder()
+                                .setIpv4Address(IpConversionUtil.createPrefix(source.getSetNwSrcAction().getIpAddress()))
+                                .build())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTosCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetNwTosCase.java
new file mode 100644 (file)
index 0000000..cbf4cb3
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+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.SetNwTosActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwTosCase;
+
+public class OfToSalSetNwTosCase extends ConvertorCase<SetNwTosCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetNwTosCase() {
+        super(SetNwTosCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetNwTosCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetNwTosActionCaseBuilder()
+                .setSetNwTosAction(new SetNwTosActionBuilder()
+                        .setTos((int) source.getSetNwTosAction().getNwTos())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpDstCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpDstCase.java
new file mode 100644 (file)
index 0000000..22ec78f
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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.SetTpDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpDstCase;
+
+public class OfToSalSetTpDstCase extends ConvertorCase<SetTpDstCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetTpDstCase() {
+        super(SetTpDstCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpDstCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetTpDstActionCaseBuilder()
+                .setSetTpDstAction(new SetTpDstActionBuilder()
+                        .setPort(new PortNumber(source.getSetTpDstAction().getPort().getValue().intValue()))
+                        .setIpProtocol(data.getIpProtocol())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpSrcCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetTpSrcCase.java
new file mode 100644 (file)
index 0000000..25e4f08
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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.SetTpSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCase;
+
+public class OfToSalSetTpSrcCase extends ConvertorCase<SetTpSrcCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetTpSrcCase() {
+        super(SetTpSrcCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetTpSrcCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetTpSrcActionCaseBuilder()
+                .setSetTpSrcAction(new SetTpSrcActionBuilder()
+                        .setPort(new PortNumber(source.getSetTpSrcAction().getPort().getValue().intValue()))
+                        .setIpProtocol(data.getIpProtocol())
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanIdCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanIdCase.java
new file mode 100644 (file)
index 0000000..93b29a7
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
+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.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanVidCase;
+
+public class OfToSalSetVlanIdCase extends ConvertorCase<SetVlanVidCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetVlanIdCase() {
+        super(SetVlanVidCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanVidCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetVlanIdActionCaseBuilder()
+                .setSetVlanIdAction(new SetVlanIdActionBuilder()
+                        .setVlanId(new VlanId(source.getSetVlanVidAction().getVlanVid()))
+                        .build())
+                .build());
+    }
+}
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanPcpCase.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/action/cases/OfToSalSetVlanPcpCase.java
new file mode 100644 (file)
index 0000000..a2f036c
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.openflow.md.core.sal.convertor.action.cases;
+
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorCase;
+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.SetVlanPcpActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetVlanPcpCase;
+
+public class OfToSalSetVlanPcpCase extends ConvertorCase<SetVlanPcpCase, Action, ActionResponseConvertorData> {
+    public OfToSalSetVlanPcpCase() {
+        super(SetVlanPcpCase.class, true, OFConstants.OFP_VERSION_1_0);
+    }
+
+    @Override
+    public Optional<Action> process(@Nonnull final SetVlanPcpCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
+        return Optional.of(new SetVlanPcpActionCaseBuilder()
+                .setSetVlanPcpAction(new SetVlanPcpActionBuilder()
+                        .setVlanPcp(new VlanPcp(source.getSetVlanPcpAction().getVlanPcp()))
+                        .build())
+                .build());
+    }
+}
index c000a980532164dab16b6ab7941d6b3b44b62165..e8f091a5aab2553216e615b8d5aabf7e9b786f7a 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 
 public class OfToSalStripVlanCase extends ConvertorCase<StripVlanCase, Action, ActionResponseConvertorData> {
     public OfToSalStripVlanCase() {
-        super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0, OFConstants.OFP_VERSION_1_3);
+        super(StripVlanCase.class, true, OFConstants.OFP_VERSION_1_0);
     }
 
     @Override
index 0b0d5b885f328a5fbc7ddd6d004b4d6b9361c67c..4782ee908cc967eb1ea74c765869cb7f9288fda0 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Con
  */
 public class ActionResponseConvertorData extends ConvertorData {
     private ActionPath actionPath;
+    private Short ipProtocol;
 
     /**
      * Instantiates a new Action response convertor data.
@@ -44,4 +45,22 @@ public class ActionResponseConvertorData extends ConvertorData {
     public void setActionPath(ActionPath actionPath) {
         this.actionPath = actionPath;
     }
+
+    /**
+     * Gets ip protocol.
+     *
+     * @return the ip protocol
+     */
+    public Short getIpProtocol() {
+        return ipProtocol;
+    }
+
+    /**
+     * Sets ip protocol.
+     *
+     * @param ipProtocol the ip protocol
+     */
+    public void setIpProtocol(final Short ipProtocol) {
+        this.ipProtocol = ipProtocol;
+    }
 }
index 8de54d9a908dffed2b35178cf1a3c5bf9a7327cf..7b8e93ddc0c430d09553365cbc5aef11650a87fd 100644 (file)
@@ -12,18 +12,17 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.AugmentTuple;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.FlowStatsResponseConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
@@ -63,11 +62,15 @@ public class FlowStatsResponseConvertor extends Convertor<List<FlowStats>, List<
      * Method wraps openflow 1.0 actions list to Apply Action Instructions
      *
      * @param actionsList list of action
+     * @param ipProtocol ip protocol
      * @return OF10 actions as an instructions
      */
-    private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, final short version) {
+    private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList,
+                                                      final short version,
+                                                      final Short ipProtocol) {
         ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version);
         actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+        actionResponseConvertorData.setIpProtocol(ipProtocol);
 
         InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
         List<Instruction> salInstructionList = new ArrayList<>();
@@ -120,15 +123,21 @@ public class FlowStatsResponseConvertor extends Convertor<List<FlowStats>, List<
             salFlowStatsBuilder.setPriority(flowStats.getPriority());
             salFlowStatsBuilder.setTableId(flowStats.getTableId());
 
+            Short ipProtocol = null;
+
             if (flowStats.getMatchV10() != null) {
                 final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
 
                 if (matchBuilderOptional.isPresent()) {
+                    if (Objects.nonNull(matchBuilderOptional.get().getIpMatch())) {
+                        ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol();
+                    }
+
                     salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
                 }
 
                 if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
-                    salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion()));
+                    salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion(), ipProtocol));
                 }
             }
 
index f1df444145dbff900f85e25cb4de6c222aa86051..e3c32889a9d9c4b657c69d9b199a98b5eced33d6 100644 (file)
@@ -264,6 +264,7 @@ public class ActionConvertorV13Test {
         actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
 \r
+        // Add some unsupported actions and check if they are missing from results
         actionBuilder = new ActionBuilder();\r
         actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());\r
         actions.add(actionBuilder.build());\r
@@ -281,7 +282,7 @@ public class ActionConvertorV13Test {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action\r
                 .Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());\r
 \r
-        Assert.assertEquals("Wrong number of output actions", 18, mdSalActions.size());\r
+        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);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
                 + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());\r
@@ -351,12 +352,6 @@ public class ActionConvertorV13Test {
         action = mdSalActions.get(15);\r
         Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
                 + ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());\r
-        action = mdSalActions.get(16);\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
-                + ".rev131112.action.action.SetNwDstActionCase", action.getImplementedInterface().getName());\r
-        action = mdSalActions.get(17);\r
-        Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"\r
-                + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());\r
     }\r
 \r
     /**\r