From e7903be79d4451f5b6e6f633b7ea20f8330ac0c1 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 27 Feb 2017 07:39:22 +0100 Subject: HC2VPP-39: yang model for policer configuration in VPP Change-Id: I6c84c5fb85e2a4073a7a885db390b08a6582639d Signed-off-by: Marek Gradzki --- .../io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java | 9 ++++++--- .../io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java | 6 ++++-- .../hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java | 8 ++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'vpp-classifier/impl') diff --git a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java index 4b985538e..e30a56615 100644 --- a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java +++ b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/read/ClassifySessionReader.java @@ -44,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.OpaqueIndex; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.StandardBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey; @@ -105,15 +106,17 @@ public class ClassifySessionReader extends FutureJVppCustomizer final ClassifySessionDetails detail = classifySession.get(); final Optional node = readVppNode(detail.tableId, detail.hitNextIndex, classifyTableContext, ctx.getMappingContext(), LOG); + final StandardBuilder nextNode = new StandardBuilder(); if (node.isPresent()) { - builder.setHitNext(node.get()); + nextNode.setHitNext(node.get()); } else { - builder.setHitNext(new VppNode(new VppNodeName("unknown"))); // TODO(HC2VPP-9): remove this workaround + nextNode.setHitNext(new VppNode(new VppNodeName("unknown"))); } if (detail.opaqueIndex != ~0) { // value is specified: - builder.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext())); + nextNode.setOpaqueIndex(readOpaqueIndex(detail.tableId, detail.opaqueIndex, ctx.getMappingContext())); } + builder.setNextNode(nextNode.build()); builder.setAdvance(detail.advance); builder.setMatch(key.getMatch()); diff --git a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java index 00e858955..8b1db57b7 100644 --- a/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java +++ b/vpp-classifier/impl/src/main/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriter.java @@ -36,6 +36,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.xml.bind.DatatypeConverter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.OpaqueIndex; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.Standard; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.vpp.classifier.ClassifyTable; @@ -108,10 +109,11 @@ public class ClassifySessionWriter extends VppNodeWriter final ClassifyTable classifyTable = getClassifyTable(writeContext, id.firstIdentifierOf(ClassifyTable.class), isAdd); - final int hitNextIndex = getNodeIndex(classifySession.getHitNext(), classifyTable, classifyTableContext, + final int hitNextIndex = getNodeIndex(((Standard)classifySession.getNextNode()).getHitNext(), + classifyTable, classifyTableContext, writeContext.getMappingContext(), id); final int opaqueIndex = - getOpaqueIndex(classifySession.getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id); + getOpaqueIndex(((Standard)classifySession.getNextNode()).getOpaqueIndex(), classifyTable, writeContext.getMappingContext(), id); final CompletionStage createClassifyTableReplyCompletionStage = getFutureJVpp() .classifyAddDelSession( diff --git a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java index 49e172fac..abc3901b6 100644 --- a/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java +++ b/vpp-classifier/impl/src/test/java/io/fd/hc2vpp/vpp/classifier/write/ClassifySessionWriterTest.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.clas import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppClassifier; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNode; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.session.attributes.next_node.StandardBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySession; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.classify.table.base.attributes.ClassifySessionKey; @@ -57,8 +58,11 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { private static ClassifySession generateClassifySession(final long opaqueIndex, final String match) { final ClassifySessionBuilder builder = new ClassifySessionBuilder(); - builder.setOpaqueIndex(new OpaqueIndex(opaqueIndex)); - builder.setHitNext(new VppNode(PacketHandlingAction.Deny)); + builder.setNextNode( + new StandardBuilder() + .setOpaqueIndex(new OpaqueIndex(opaqueIndex)) + .setHitNext(new VppNode(PacketHandlingAction.Deny)) + .build()); builder.setAdvance(123); builder.setMatch(new HexString(match)); return builder.build(); -- cgit 1.2.3-korg