Fix initializer for vpp classifier 61/2061/3
authorMarek Gradzki <mgradzki@cisco.com>
Fri, 22 Jul 2016 12:43:19 +0000 (14:43 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Mon, 25 Jul 2016 09:06:24 +0000 (09:06 +0000)
Change-Id: I5a94bafb426b4f0b2e077153593f714a69ad2abb
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
v3po/api/src/main/yang/vpp-classifier.yang
v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/initializers/VppClasifierInitializer.java

index 1351f9e..46bff20 100644 (file)
@@ -92,12 +92,6 @@ module vpp-classifier {
         "Used by classifier hashing algorithm. It is not possible to resize the bucket array,
         therefore suggested value is approximate number of expected entries.";
     }
-    leaf memory_size {
-      mandatory true;
-      type uint32;
-      description
-        "Memory size for classify table and its entries.";
-    }
     leaf skip_n_vectors {
       type uint32;
       default 0;
@@ -143,6 +137,21 @@ module vpp-classifier {
     }
   }
 
+  grouping classify-table-config-attributes {
+    description
+      "Defines classify table config only attributes (present in classify_add_del_table message
+       but not in classify_table_info_reply).";
+
+    // FIXME move to classify-table-base-attributes
+    // after https://jira.fd.io/browse/VPP-208 is fixed
+    leaf memory_size {
+      type uint32;
+      mandatory true;
+      description
+        "Memory size for classify table and its entries.";
+    }
+  }
+
   grouping classify-table-operational-attributes {
     description
       "Defines classify table operational attributes (present in classify_table_info_reply message
@@ -167,6 +176,7 @@ module vpp-classifier {
       }
 
       uses classify-table-base-attributes;
+      uses classify-table-config-attributes;
     }
   }
 
index 0881f1a..155f894 100644 (file)
 package io.fd.honeycomb.v3po.translate.v3po.initializers;
 
 import io.fd.honeycomb.v3po.vpp.data.init.AbstractDataTreeConverter;
+import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -39,10 +41,9 @@ public class VppClasifierInitializer extends AbstractDataTreeConverter<VppClassi
     @Override
     protected VppClassifier convert(final VppClassifierState operationalData) {
         final VppClassifierBuilder builder = new VppClassifierBuilder();
-        // TODO finish translation classify table key + mandatory fields at least must be set
-//        builder.setClassifyTable(operationalData.getClassifyTable().stream()
-//            .map(oper -> new ClassifyTableBuilder(oper).build())
-//            .collect(Collectors.toList()));
+        builder.setClassifyTable(operationalData.getClassifyTable().stream()
+            .map(oper -> new ClassifyTableBuilder(oper).setName(oper.getName()).build())
+            .collect(Collectors.toList()));
         return builder.build();
     }
 }