BUG-4123: Li:flow statistics are not passed into DS/operational 90/25190/1
authorMichal Rehak <mirehak@cisco.com>
Tue, 11 Aug 2015 15:47:35 +0000 (17:47 +0200)
committerMichal Rehak <mirehak@cisco.com>
Wed, 12 Aug 2015 08:22:14 +0000 (10:22 +0200)
 - added corresponding augmentation when transforming flow for DS

Change-Id: I49f96faa9d2587baf2e0cad28f061a2bdd0d2619
Signed-off-by: Michal Rehak <mirehak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtils.java

index f4734789cd9d2c49ee6ecb5cdad39a1f92affcb4..b3952c61af59fc96822ab27a9ff20b19e1bc3bdb 100644 (file)
@@ -40,8 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsDataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
 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.statistics.FlowStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
@@ -204,6 +207,8 @@ public final class StatisticsGatheringUtils {
         for (final FlowsStatisticsUpdate flowsStatistics : data) {
             for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
                 final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
+                flowBuilder.addAugmentation(FlowStatisticsData.class, refineFlowStatisticsAugmentation(flowStat).build());
+
                 final short tableId = flowStat.getTableId();
                 final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build());
                 final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
@@ -217,6 +222,18 @@ public final class StatisticsGatheringUtils {
         }
     }
 
+    /**
+     * Method extracts flow statistics out of flowAndStatistics model
+     *
+     * @param flowAndStats
+     */
+    private static FlowStatisticsDataBuilder refineFlowStatisticsAugmentation(final FlowAndStatisticsMapList flowAndStats) {
+        final FlowStatisticsBuilder flowStatisticsBuilder = new FlowStatisticsBuilder(flowAndStats);
+        final FlowStatisticsDataBuilder flowStatisticsDataBld = new FlowStatisticsDataBuilder();
+        flowStatisticsDataBld.setFlowStatistics(flowStatisticsBuilder.build());
+        return flowStatisticsDataBld;
+    }
+
     public static void deleteAllKnownFlows(final DeviceContext deviceContext) {
         if (deviceContext.getDeviceState().deviceSynchronized()) {
             InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceContext);