Fix opendaylight-flow-types.yang cases 72/73472/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Jun 2018 11:18:43 +0000 (13:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Jun 2018 11:23:49 +0000 (13:23 +0200)
The model is invalid, as it is introducing duplicate names into
a choice. Fix this up by adding an intermediate container.

JIRA: OPNFLWPLUG-1020
Change-Id: I76b4822b63df05051bdd3f4787186a5e76480970
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/model-flow-base/src/main/yang/opendaylight-flow-types.yang
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/MultipartRequestInputFactory.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsService.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowAggregateStatsSerializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/multipart/MultipartRequestFlowStatsSerializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/singlelayer/SingleLayerAggregateFlowMultipartServiceTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/services/direct/singlelayer/FlowDirectStatisticsServiceTest.java

index ce4baf673802d2024116ea96c630f393a34704bf..a1b0701a89e53447cf4c6d45341dd92a30d644e1 100644 (file)
@@ -295,10 +295,14 @@ module opendaylight-flow-types {
 
     augment "/multipart:multipart-request/multipart:multipart-request-body" {
         case multipart-request-flow-stats {
-            uses flow;
+            container flow-stats {
+                uses flow;
+            }
         }
         case multipart-request-flow-aggregate-stats {
-            uses flow;
+            container flow-aggregate-stats {
+                uses flow;
+            }
         }
     }
 }
index 910a3ad07c66d90b921edd4394c395d0ad5c6f4d..5a3d6813d2d9ee25d42d5f29087dc49a62bbe723 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.request.multipart.request.body.MultipartRequestPortDescBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.stats.FlowStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupDescBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.request.multipart.request.body.MultipartRequestGroupStatsBuilder;
@@ -107,10 +108,9 @@ public final class MultipartRequestInputFactory {
         .MultipartRequestBody makeDefaultSingleLayerBody(final MultipartType type) {
         switch (type) {
             case OFPMPDESC: return new MultipartRequestDescBuilder().build();
-            case OFPMPFLOW: return new MultipartRequestFlowStatsBuilder()
+            case OFPMPFLOW: return new MultipartRequestFlowStatsBuilder().setFlowStats(new FlowStatsBuilder()
                 .setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
-                    .MatchBuilder().build())
-                .build();
+                    .MatchBuilder().build()).build()).build();
             case OFPMPAGGREGATE: return new MultipartRequestFlowAggregateStatsBuilder().build();
             case OFPMPTABLE: return new MultipartRequestFlowTableStatsBuilder().build();
             case OFPMPPORTSTATS: return new org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics
index 284026b55433cd1812d937348e366237532a8768..6ca6294333fae7c7e70aee87020b0cc98e154dcf 100644 (file)
@@ -5,7 +5,6 @@
  * 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.impl.protocol.serialization.multipart;
 
 import com.google.common.base.MoreObjects;
@@ -19,6 +18,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.aggregate.stats.FlowAggregateStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
 public class MultipartRequestFlowAggregateStatsSerializer implements OFSerializer<MultipartRequestFlowAggregateStats>,
@@ -31,22 +31,20 @@ public class MultipartRequestFlowAggregateStatsSerializer implements OFSerialize
     @Override
     public void serialize(final MultipartRequestFlowAggregateStats multipartRequestFlowAggregateStats,
             final ByteBuf byteBuf) {
-        byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getTableId(),
-                OFConstants.OFPTT_ALL).byteValue());
+        final FlowAggregateStats stats = multipartRequestFlowAggregateStats.getFlowAggregateStats();
+        byteBuf.writeByte(MoreObjects.firstNonNull(stats.getTableId(), OFConstants.OFPTT_ALL).byteValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);
-        byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getOutPort(),
-                OFConstants.OFPP_ANY).intValue());
-        byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getOutGroup(),
-                OFConstants.OFPG_ANY).intValue());
+        byteBuf.writeInt(MoreObjects.firstNonNull(stats.getOutPort(), OFConstants.OFPP_ANY).intValue());
+        byteBuf.writeInt(MoreObjects.firstNonNull(stats.getOutGroup(), OFConstants.OFPG_ANY).intValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02);
-        byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getCookie(),
+        byteBuf.writeLong(MoreObjects.firstNonNull(stats.getCookie(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE)).getValue().longValue());
-        byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowAggregateStats.getCookieMask(),
+        byteBuf.writeLong(MoreObjects.firstNonNull(stats.getCookieMask(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue());
 
         Preconditions.checkNotNull(registry).<Match, OFSerializer<Match>>getSerializer(
                 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class))
-                .serialize(multipartRequestFlowAggregateStats.getMatch(), byteBuf);
+                .serialize(stats.getMatch(), byteBuf);
     }
 
     @Override
index 50dd3ba14920f6a4ad4e76af67299e6a6db24352..37a856feac5ec39218332951fe3a86be7b4ce42b 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.stats.FlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 
 public class MultipartRequestFlowStatsSerializer implements OFSerializer<MultipartRequestFlowStats>,
@@ -30,22 +31,20 @@ public class MultipartRequestFlowStatsSerializer implements OFSerializer<Multipa
 
     @Override
     public void serialize(final MultipartRequestFlowStats multipartRequestFlowStats, final ByteBuf byteBuf) {
-        byteBuf.writeByte(MoreObjects.firstNonNull(multipartRequestFlowStats.getTableId(),
-                OFConstants.OFPTT_ALL).byteValue());
+        final FlowStats stats = multipartRequestFlowStats.getFlowStats();
+        byteBuf.writeByte(MoreObjects.firstNonNull(stats.getTableId(), OFConstants.OFPTT_ALL).byteValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_01);
-        byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowStats.getOutPort(),
-                OFConstants.OFPP_ANY).intValue());
-        byteBuf.writeInt(MoreObjects.firstNonNull(multipartRequestFlowStats.getOutGroup(),
-                OFConstants.OFPG_ANY).intValue());
+        byteBuf.writeInt(MoreObjects.firstNonNull(stats.getOutPort(), OFConstants.OFPP_ANY).intValue());
+        byteBuf.writeInt(MoreObjects.firstNonNull(stats.getOutGroup(), OFConstants.OFPG_ANY).intValue());
         byteBuf.writeZero(PADDING_IN_MULTIPART_REQUEST_FLOW_BODY_02);
-        byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowStats.getCookie(),
+        byteBuf.writeLong(MoreObjects.firstNonNull(stats.getCookie(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE)).getValue().longValue());
-        byteBuf.writeLong(MoreObjects.firstNonNull(multipartRequestFlowStats.getCookieMask(),
+        byteBuf.writeLong(MoreObjects.firstNonNull(stats.getCookieMask(),
                 new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK)).getValue().longValue());
 
         Preconditions.checkNotNull(registry).<Match, OFSerializer<Match>>getSerializer(
             new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class))
-            .serialize(multipartRequestFlowStats.getMatch(), byteBuf);
+            .serialize(stats.getMatch(), byteBuf);
     }
 
     @Override
index 14bf93ae58ec50c5a7a51111bd9e7301314a70f8..e118a7f1078f976e72cd712ce90057a0ceaafc05 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.G
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.aggregate.stats.FlowAggregateStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -46,8 +47,8 @@ public class SingleLayerAggregateFlowMultipartService
                 .setXid(xid.getValue())
                 .setVersion(getVersion())
                 .setRequestMore(false)
-                .setMultipartRequestBody(new MultipartRequestFlowAggregateStatsBuilder(input)
-                        .build())
+                .setMultipartRequestBody(new MultipartRequestFlowAggregateStatsBuilder()
+                    .setFlowAggregateStats(new FlowAggregateStatsBuilder(input).build()).build())
                 .build();
     }
 
index e761e829d4e32e04f118a8bec478cece569cdc74..15a1d43856e820fd0b17b2330344243f0cc0ab43 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.f
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.stats.FlowStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
@@ -39,7 +40,7 @@ public class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsSer
     }
 
     @Override
-    protected GetFlowStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
+    protected GetFlowStatisticsOutput buildReply(final List<MultipartReply> input, final boolean success) {
         return new GetFlowStatisticsOutputBuilder()
             .setFlowAndStatisticsMapList(input
                 .stream()
@@ -64,7 +65,8 @@ public class FlowDirectStatisticsService extends AbstractFlowDirectStatisticsSer
             .setXid(xid.getValue())
             .setVersion(getVersion())
             .setRequestMore(false)
-            .setMultipartRequestBody(new MultipartRequestFlowStatsBuilder(input)
+            .setMultipartRequestBody(new MultipartRequestFlowStatsBuilder()
+                .setFlowStats(new FlowStatsBuilder(input).build())
                 .build())
             .build();
     }
index 268ec24b3f08804b89192cb995ee2b9e1006da78..14efdedcdb1a0484659f7896a586f8acbd0ec0e8 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.aggregate.stats.FlowAggregateStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
 
 public class MultipartRequestFlowAggregateStatsSerializerTest extends AbstractSerializerTest {
@@ -40,13 +41,14 @@ public class MultipartRequestFlowAggregateStatsSerializerTest extends AbstractSe
                     .build())
             .build();
     private static final MultipartRequestFlowAggregateStats BODY = new MultipartRequestFlowAggregateStatsBuilder()
-            .setTableId(TABLE_ID)
-            .setOutPort(OUT_PORT)
-            .setOutGroup(OUT_GROUP)
-            .setCookie(COOKIE)
-            .setCookieMask(COOKIE_MASK)
-            .setMatch(MATCH)
-            .build();
+            .setFlowAggregateStats(new FlowAggregateStatsBuilder()
+                .setTableId(TABLE_ID)
+                .setOutPort(OUT_PORT)
+                .setOutGroup(OUT_GROUP)
+                .setCookie(COOKIE)
+                .setCookieMask(COOKIE_MASK)
+                .setMatch(MATCH)
+                .build()).build();
 
     private MultipartRequestFlowAggregateStatsSerializer serializer;
 
index 7118d09eb61ca121046f572e7de001f9dee6d4fe..2cef6dbc9ca6c175e125b32c3de5d333b34b5e0d 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.multipart.request.flow.stats.FlowStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
 
 public class MultipartRequestFlowStatsSerializerTest extends AbstractSerializerTest {
@@ -40,13 +41,14 @@ public class MultipartRequestFlowStatsSerializerTest extends AbstractSerializerT
                     .build())
             .build();
     private static final MultipartRequestFlowStats BODY = new MultipartRequestFlowStatsBuilder()
-            .setTableId(TABLE_ID)
-            .setOutPort(OUT_PORT)
-            .setOutGroup(OUT_GROUP)
-            .setCookie(COOKIE)
-            .setCookieMask(COOKIE_MASK)
-            .setMatch(MATCH)
-            .build();
+            .setFlowStats(new FlowStatsBuilder()
+                .setTableId(TABLE_ID)
+                .setOutPort(OUT_PORT)
+                .setOutGroup(OUT_GROUP)
+                .setCookie(COOKIE)
+                .setCookieMask(COOKIE_MASK)
+                .setMatch(MATCH)
+                .build()).build();
 
     private MultipartRequestFlowStatsSerializer serializer;
 
index 64f7dec7ea539448b782bb8a8448780d77d68173..8728062a6d248b9f4cf6aeb8dc9fa45f17a496fb 100644 (file)
@@ -50,7 +50,7 @@ public class SingleLayerAggregateFlowMultipartServiceTest extends ServiceMocking
                 MultipartRequest.class.cast(ofHeader)
                         .getMultipartRequestBody());
 
-        assertEquals(TABLE_ID, result.getTableId().shortValue());
+        assertEquals(TABLE_ID, result.getFlowAggregateStats().getTableId().shortValue());
     }
 
     @Test
index aa50913f15486db44036b5cae013381d5a851511..3276a81b4c6dff5d61f3e4e8051bacbd22e38b9c 100644 (file)
@@ -68,7 +68,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
             .buildRequest(new Xid(42L), input))
             .getMultipartRequestBody();
 
-        assertEquals(TABLE_NO, body.getTableId());
+        assertEquals(TABLE_NO, body.getFlowStats().getTableId());
     }
 
     @Override