1) Fixed minor issue caused by change in port statistics models 98/3898/1
authorAnilkumar Vishnoi <avishnoi@in.ibm.com>
Sat, 21 Dec 2013 20:07:56 +0000 (01:37 +0530)
committerAnilkumar Vishnoi <avishnoi@in.ibm.com>
Sun, 22 Dec 2013 21:29:05 +0000 (02:59 +0530)
2) Added converter to convert OF actions to MD-SAL actions
3) Added check to avoid sending group/meter feature request to openflow 1.0 switch

Change-Id: Ib1995f53c7cdb1e092fffa8418ac5520291c97fb
Signed-off-by: Anilkumar Vishnoi <avishnoi@in.ibm.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/ConnectionConductorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/MDController.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowStatsResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/GroupStatsResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/MeterStatsResponseConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFToMDSalFlowConvertor.java [new file with mode: 0644]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTranslator.java

index 5c5271f56959e5c25dd25408f23083e000ffbea3..98e9037eb18f29ee5161f7be18816f2e9c7098d3 100644 (file)
@@ -15,6 +15,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
+import org.opendaylight.openflowplugin.openflow.md.OFConstants;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.PortFeaturesUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
@@ -380,8 +381,10 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
         OFSessionUtil.registerSession(this, featureOutput, negotiatedVersion);
         requestDesc();
         requestPorts();
-        requestGroupFeatures();
-        requestMeterFeatures();
+        if(version == OFConstants.OFP_VERSION_1_3){
+            requestGroupFeatures();
+            requestMeterFeatures();
+        }
     }
 
     /*
index c89b27c748f2e8cd0df09b94c6c2923bb9bd4468..811dc5725d3847350b7b3e8ce489d3234ae3f80b 100644 (file)
@@ -56,7 +56,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.PortStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdated;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -137,7 +137,7 @@ public class MDController implements IMDController {
         addMessagePopListener(MeterFeaturesUpdated.class, notificationPopListener);
 
         //Notification registration for port-statistics
-        addMessagePopListener(PortStatisticsUpdate.class, notificationPopListener);
+        addMessagePopListener(NodeConnectorStatisticsUpdate.class, notificationPopListener);
         
         //Notification registration for flow-table statistics
         addMessagePopListener(FlowTableStatisticsUpdate.class, notificationPopListener);
index fbed99b857766983e98ef179159ae0f67d465802..dcf3dc8d1b9f2c545ad8baf973b0f8a1b4fbfc99 100644 (file)
@@ -46,22 +46,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllNodeConnectorStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowTableStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetNodeConnectorStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
@@ -161,12 +151,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.GetP
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllPortsStatisticsOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetPortStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
@@ -891,7 +881,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
     }
     
     @Override
-    public Future<RpcResult<GetAllPortsStatisticsOutput>> getAllPortsStatistics(GetAllPortsStatisticsInput arg0) {
+    public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(GetAllNodeConnectorsStatisticsInput arg0) {
 
         //Generate xid to associate it with the request
         Long xid = this.getSessionContext().getNextXid();
@@ -920,16 +910,16 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         this.messageService.multipartRequest(mprInput.build(), null);
 
         // Prepare rpc return output. Set xid and send it back.
-        GetAllPortsStatisticsOutputBuilder output = new GetAllPortsStatisticsOutputBuilder();
+        GetAllNodeConnectorsStatisticsOutputBuilder output = new GetAllNodeConnectorsStatisticsOutputBuilder();
         output.setTransactionId(generateTransactionId(xid));
 
         Collection<RpcError> errors = Collections.emptyList();
-        RpcResult<GetAllPortsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+        RpcResult<GetAllNodeConnectorsStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
         return Futures.immediateFuture(rpcResult);
     }
 
     @Override
-    public Future<RpcResult<GetPortStatisticsOutput>> getPortStatistics(GetPortStatisticsInput arg0) {
+    public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(GetNodeConnectorStatisticsInput arg0) {
         //Generate xid to associate it with the request
         Long xid = this.getSessionContext().getNextXid();
 
@@ -958,11 +948,11 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         this.messageService.multipartRequest(mprInput.build(), null);
 
         // Prepare rpc return output. Set xid and send it back.
-        GetPortStatisticsOutputBuilder output = new GetPortStatisticsOutputBuilder();
+        GetNodeConnectorStatisticsOutputBuilder output = new GetNodeConnectorStatisticsOutputBuilder();
         output.setTransactionId(generateTransactionId(xid));
 
         Collection<RpcError> errors = Collections.emptyList();
-        RpcResult<GetPortStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
+        RpcResult<GetNodeConnectorStatisticsOutput> rpcResult = Rpcs.getRpcResult(true, output.build(), errors);
         return Futures.immediateFuture(rpcResult);
     }
 
@@ -1316,7 +1306,7 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         //Generate xid to associate it with the request
         Long xid = this.getSessionContext().getNextXid();
 
-        LOG.debug("Prepare agregate statistics request to get aggregate stats for flows matching {} and installed in flow tables {} - Transaction id - {}"
+        LOG.debug("Prepare aggregate statistics request to get aggregate stats for flows matching {} and installed in flow tables {} - Transaction id - {}"
                 ,arg0.getMatch().toString(),arg0.getTableId(),xid);
 
         // Create multipart request header
@@ -1527,38 +1517,4 @@ public class ModelDrivenSwitchImpl extends AbstractModelDrivenSwitch {
         return Futures.immediateFuture(rpcResult);
     }
 
-    @Override
-    public Future<RpcResult<GetAllFlowStatisticsOutput>> getAllFlowStatistics(GetAllFlowStatisticsInput arg0) {
-        //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
-        // Once sal-compatibility layer is fixed this rpc call can be removed from yang file 
-        return null;
-    }
-
-    @Override
-    public Future<RpcResult<GetAllNodeConnectorStatisticsOutput>> getAllNodeConnectorStatistics(
-            GetAllNodeConnectorStatisticsInput arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public Future<RpcResult<GetFlowStatisticsOutput>> getFlowStatistics(GetFlowStatisticsInput arg0) {
-        //TODO: Depricated, need to clean it up. Sal-Compatibility layes is dependent on it.
-        // Once sal-compatibility layer is fixed this rpc call can be removed from yang file 
-        return null;
-    }
-
-    @Override
-    public Future<RpcResult<GetFlowTableStatisticsOutput>> getFlowTableStatistics(GetFlowTableStatisticsInput arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
-            GetNodeConnectorStatisticsInput arg0) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
 }
index f9505a3e4d4a868afe980a6529748816cca3ffbc..8094b8b3dd69c3b050b287bd3c089e10df6f2b25 100644 (file)
@@ -3,7 +3,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.controller.sal.action.SetNwTos;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@ -761,7 +760,7 @@ public final class ActionConvertor {
      * @param actionList
      * @return List of converted SAL Actions.
      */
-    public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toSALBucketActions(
+    public static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> toMDSalActions(
             List<ActionsList> actionList) {
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> bucketActions = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>();
index a8231a7debd749e5503ea6edbd8c06f9e7da99ee..c89f265d34539855dfe52d99996242b86fe406b8 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright IBM Corporation, 2013.  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;
 
 import java.util.ArrayList;
@@ -9,15 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
 
@@ -81,53 +79,10 @@ public class FlowStatsResponseConvertor {
             salFlowStatsBuilder.setMatch(MatchConvertorImpl.fromOFMatchToSALMatch(flowStats.getMatch()));
         }
         if(flowStats.getInstructions()!= null){
-            salFlowStatsBuilder.setInstructions(toSALInstruction(flowStats.getInstructions()));
+            salFlowStatsBuilder.setInstructions(OFToMDSalFlowConvertor.toSALInstruction(flowStats.getInstructions()));
         }
         
         return salFlowStatsBuilder.build();
         
     }
-    
-    /**
-     * Method convert Openflow 1.3+ specific instructions to MD-SAL format
-     * flow instruction
-     * Note: MD-SAL won't augment this data directly to the data store, 
-     * so key setting is not required. If user wants to augment this data
-     * directly to the data store, key setting is required for each instructions. 
-     * @param instructions
-     * @return
-     */
-    public Instructions toSALInstruction(
-            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions> instructions) {
-        
-        InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
-        
-        List<Instruction> salInstructionList = new ArrayList<Instruction>();
-        
-        for(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions switchInst : instructions){
-            if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions){
-                InstructionBuilder instBuilder = new InstructionBuilder();
-                instBuilder.setInstruction(new ApplyActionsCaseBuilder().build());
-                salInstructionList.add(instBuilder.build());
-            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions){
-                InstructionBuilder instBuilder = new InstructionBuilder();
-                instBuilder.setInstruction(new ClearActionsCaseBuilder().build());
-                salInstructionList.add(instBuilder.build());
-            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable){
-                InstructionBuilder instBuilder = new InstructionBuilder();
-                instBuilder.setInstruction(new GoToTableCaseBuilder().build());
-                salInstructionList.add(instBuilder.build());
-            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions){
-                InstructionBuilder instBuilder = new InstructionBuilder();
-                instBuilder.setInstruction(new WriteActionsCaseBuilder().build());
-                salInstructionList.add(instBuilder.build());
-            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata){
-                InstructionBuilder instBuilder = new InstructionBuilder();
-                instBuilder.setInstruction(new WriteMetadataCaseBuilder().build());
-                salInstructionList.add(instBuilder.build());
-            }
-        }
-        instructionsBuilder.setInstruction(salInstructionList);
-        return instructionsBuilder.build();
-    }
 }
index 636a38fdab6ec2abdd97a2be09c8342a75a753b6..332e5ac100ae020a6e24d771f4888411a6f3c390 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright IBM Corporation, 2013.  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;
 
 import java.util.ArrayList;
@@ -135,7 +143,7 @@ public class GroupStatsResponseConvertor {
         for(BucketsList bucketDetails : bucketDescStats){
             BucketBuilder bucketDesc = new BucketBuilder();
             List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedSalActions = 
-                    ActionConvertor.toSALBucketActions (bucketDetails.getActionsList());
+                    ActionConvertor.toMDSalActions (bucketDetails.getActionsList());
             
             List<Action> actions = new ArrayList<>(); 
             int actionKey = 0;
index 4681ddd09078be18a389de063395349194db9673..1e28567c0d77f3a9fd8aafe92ea38226edf7cd12 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright IBM Corporation, 2013.  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;
 
 import java.util.ArrayList;
diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFToMDSalFlowConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/OFToMDSalFlowConvertor.java
new file mode 100644 (file)
index 0000000..2b2d5e4
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright IBM Corporation, 2013.  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;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+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.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.clear.actions._case.ClearActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;
+
+public class OFToMDSalFlowConvertor {
+    
+    /**
+     * Method convert Openflow 1.3+ specific instructions to MD-SAL format
+     * flow instruction
+     * Note: MD-SAL won't augment this data directly to the data store, 
+     * so key setting is not required. If user wants to augment this data
+     * directly to the data store, key setting is required for each instructions. 
+     * @param instructions
+     * @return
+     */
+    public static Instructions toSALInstruction(
+            List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions> instructions) {
+        
+        InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
+        
+        List<Instruction> salInstructionList = new ArrayList<Instruction>();
+        
+        for(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.Instructions switchInst : instructions){
+            if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions){
+                
+                ActionsInstruction actionsInstruction = (ActionsInstruction)switchInst.getAugmentation(ActionsInstruction.class);
+                ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+                ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+                
+                
+                applyActionsBuilder.setAction(
+                            wrapActionList(
+                                    ActionConvertor.toMDSalActions(actionsInstruction.getActionsList()
+                                            )
+                                            ));
+                
+                applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+                
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                instBuilder.setInstruction(new ApplyActionsCaseBuilder().build());
+                salInstructionList.add(instBuilder.build());
+            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions){
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                
+                ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
+                ClearActionsBuilder clearActionsBuilder = new ClearActionsBuilder();
+                clearActionsCaseBuilder.setClearActions(clearActionsBuilder.build());
+                
+                instBuilder.setInstruction(clearActionsCaseBuilder.build());
+                salInstructionList.add(instBuilder.build());
+            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable){
+                
+                TableIdInstruction tableIdInstruction = (TableIdInstruction)switchInst.getAugmentation(TableIdInstruction.class);
+                
+                GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
+                GoToTableBuilder goToTableBuilder = new GoToTableBuilder();
+                goToTableBuilder.setTableId(tableIdInstruction.getTableId());
+                goToTableCaseBuilder.setGoToTable(goToTableBuilder.build());
+                
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                instBuilder.setInstruction(goToTableCaseBuilder.build());
+                salInstructionList.add(instBuilder.build());
+            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter){
+                
+                MeterIdInstruction meterIdInstruction = (MeterIdInstruction) switchInst.getAugmentation(MeterIdInstruction.class);
+                
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                
+                MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+                MeterBuilder meterBuilder = new MeterBuilder();
+                meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeterId()));
+                meterCaseBuilder.setMeter(meterBuilder.build());
+                
+                instBuilder.setInstruction(meterCaseBuilder.build());
+                salInstructionList.add(instBuilder.build());
+            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions){
+                
+                ActionsInstruction actionsInstruction = (ActionsInstruction)switchInst.getAugmentation(ActionsInstruction.class);
+                
+                WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+                WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
+                writeActionsBuilder.setAction(wrapActionList(ActionConvertor.toMDSalActions(actionsInstruction.getActionsList())));
+                writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+                
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                instBuilder.setInstruction(writeActionsCaseBuilder.build());
+                salInstructionList.add(instBuilder.build());
+            
+            }else if(switchInst instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata){
+
+                MetadataInstruction metadataInstruction = (MetadataInstruction)switchInst.getAugmentation(MetadataInstruction.class);
+                
+                WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
+                WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
+                writeMetadataBuilder.setMetadata(new BigInteger(metadataInstruction.getMetadata()));
+                writeMetadataBuilder.setMetadataMask(new BigInteger(metadataInstruction.getMetadataMask()));
+                writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
+                
+                InstructionBuilder instBuilder = new InstructionBuilder();
+                instBuilder.setInstruction(writeMetadataCaseBuilder.build());
+                salInstructionList.add(instBuilder.build());
+            }
+        }
+        instructionsBuilder.setInstruction(salInstructionList);
+        return instructionsBuilder.build();
+    }
+    
+    /*
+     * Method wrapping all the actions org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
+     * in org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action, to set appropriate keys
+     * for actions. 
+     */
+    private static List<Action> wrapActionList(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> actionList){
+        List<Action> actions = new ArrayList<>(); 
+        
+        int actionKey = 0;
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : actionList){
+            ActionBuilder wrappedAction = new ActionBuilder();
+            wrappedAction.setAction(action);
+            wrappedAction.setKey(new ActionKey(actionKey));
+            wrappedAction.setOrder(actionKey);
+            actions.add(wrappedAction.build());
+            actionKey++;
+        }
+        
+        return actions;
+    }
+
+
+}
index 21ccecc4cf2b999752c7f4af8d5e2c77e3652156..35815c1458109ed249fdfc1e13ee7672c31636ce 100644 (file)
@@ -83,7 +83,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.PortStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
@@ -121,7 +121,7 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
             NodeId node = this.nodeIdFromDatapathId(sc.getFeatures().getDatapathId());
             switch (mpReply.getType()){
             case OFPMPFLOW: {
-                logger.debug("Received flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+");
+                logger.info("Received flow statistics reponse from openflow {} switch",msg.getVersion()==1?"1.0":"1.3+");
                 FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder();
                 message.setId(node);
                 message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
@@ -153,9 +153,9 @@ public class MultipartReplyTranslator implements IMDMessageTranslator<OfHeader,
             }
             case OFPMPPORTSTATS: {
 
-                logger.debug("Received port statistics multipart response");
+                logger.info("Received port statistics multipart response");
                 
-                PortStatisticsUpdateBuilder message = new PortStatisticsUpdateBuilder();
+                NodeConnectorStatisticsUpdateBuilder message = new NodeConnectorStatisticsUpdateBuilder();
                 message.setId(node);
                 message.setMoreReplies(mpReply.getFlags().isOFPMPFREQMORE());
                 message.setTransactionId(generateTransactionId(mpReply.getXid()));