HC2VPP-91: fix acl ordering 04/5604/5
authorMarek Gradzki <mgradzki@cisco.com>
Fri, 3 Mar 2017 06:36:52 +0000 (07:36 +0100)
committerJan Srnicek <jsrnicek@cisco.com>
Wed, 8 Mar 2017 09:00:34 +0000 (09:00 +0000)
Acl assignment should be added after interface creation
(and removed in reverse order).

Change-Id: Ieb915b8909ce39549e6f8312a92e065d59303e8d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/AclReaderFactory.java
acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/read/factory/InterfaceAclReaderFactory.java
acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/write/factory/InterfaceAclWriterFactory.java
acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/write/factory/VppAclWriterFactory.java

index 90c4afe..34352e8 100644 (file)
@@ -56,15 +56,8 @@ public class AclReaderFactory implements ReaderFactory, AclFactory {
     public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
         registry.addStructuralReader(ACLS_ID, AccessListsBuilder.class);
 
-        // TODO(HONEYCOMB-331): initializer is not registered correctly when subtreeAddBefore is used,
-        // enable after fixing infra issue:
-
-//        registry.subtreeAddBefore(vppAclChildren(InstanceIdentifier.create(Acl.class)),
-//            new GenericInitListReader<>(ACL_ID,
-//                new AclCustomizer(futureAclFacade, standardAclContext, macIpAClContext)),
-//            ImmutableSet.of(ACL_INGRESS_IID, ACL_EGRESS_IID));
-
-        registry.addBefore(new GenericInitListReader<>(ACL_ID,
+        registry.subtreeAddBefore(vppAclChildren(InstanceIdentifier.create(Acl.class)),
+            new GenericInitListReader<>(ACL_ID,
                 new AclCustomizer(futureAclFacade, standardAclContext, macIpAClContext)),
             ImmutableSet.of(ACL_INGRESS_IID, ACL_EGRESS_IID));
     }
index 5b2c450..1732236 100644 (file)
@@ -65,7 +65,7 @@ public class InterfaceAclReaderFactory implements ReaderFactory {
         IFC_ID = InstanceIdentifier.create(InterfacesState.class).child(Interface.class);
     private static final InstanceIdentifier<VppAclInterfaceStateAugmentation> VPP_ACL_AUG_IID =
         IFC_ID.augmentation(VppAclInterfaceStateAugmentation.class);
-    private static final InstanceIdentifier<Acl> ACL_IID = VPP_ACL_AUG_IID.child(Acl.class);
+    static final InstanceIdentifier<Acl> ACL_IID = VPP_ACL_AUG_IID.child(Acl.class);
     static final InstanceIdentifier<Ingress> ACL_INGRESS_IID = ACL_IID.child(Ingress.class);
     static final InstanceIdentifier<Egress> ACL_EGRESS_IID = ACL_IID.child(Egress.class);
 
index 6598aae..12be40a 100644 (file)
@@ -36,21 +36,24 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class InterfaceAclWriterFactory extends AbstractAclWriterFactory implements WriterFactory {
 
-    private static final InstanceIdentifier<Acl> ACL_IID =
+    static final InstanceIdentifier<Acl> ACL_IID =
         InstanceIdentifier.create(Interfaces.class).child(Interface.class)
             .augmentation(VppAclInterfaceAugmentation.class).child(Acl.class);
+    private static final InstanceIdentifier<Interface> IFC_ID =
+        InstanceIdentifier.create(Interfaces.class).child(Interface.class);
+
 
     @Override
     public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
-        registry.subtreeAdd(aclHandledChildren(InstanceIdentifier.create(Acl.class)),
+        registry.subtreeAddAfter(aclHandledChildren(InstanceIdentifier.create(Acl.class)),
             new GenericWriter<>(ACL_IID,
-                new InterfaceAclCustomizer(futureAclFacade, interfaceContext, standardAclContext)));
+                new InterfaceAclCustomizer(futureAclFacade, interfaceContext, standardAclContext)), IFC_ID);
 
-        registry.add(new GenericWriter<>(ACL_IID.child(Ingress.class).child(VppMacipAcl.class),
-            new InterfaceAclMacIpCustomizer(futureAclFacade, macIpAClContext, interfaceContext)));
+        registry.addAfter(new GenericWriter<>(ACL_IID.child(Ingress.class).child(VppMacipAcl.class),
+            new InterfaceAclMacIpCustomizer(futureAclFacade, macIpAClContext, interfaceContext)), IFC_ID);
     }
 
-    private Set<InstanceIdentifier<?>> aclHandledChildren(final InstanceIdentifier<Acl> parentId) {
+    static Set<InstanceIdentifier<?>> aclHandledChildren(final InstanceIdentifier<Acl> parentId) {
         return ImmutableSet.of(parentId.child(Ingress.class),
             parentId.child(Ingress.class).child(VppAcls.class),
             parentId.child(Egress.class),
index bf855ef..2b95f0b 100644 (file)
@@ -16,6 +16,9 @@
 
 package io.fd.hc2vpp.acl.write.factory;
 
+import static io.fd.hc2vpp.acl.write.factory.InterfaceAclWriterFactory.ACL_IID;
+import static io.fd.hc2vpp.acl.write.factory.InterfaceAclWriterFactory.aclHandledChildren;
+
 import io.fd.hc2vpp.acl.util.factory.AclFactory;
 import io.fd.hc2vpp.acl.write.VppAclCustomizer;
 import io.fd.honeycomb.translate.impl.write.GenericListWriter;
@@ -32,8 +35,9 @@ public class VppAclWriterFactory extends AbstractAclWriterFactory implements Wri
     public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
         final InstanceIdentifier<AccessLists> rootNode = InstanceIdentifier.create(AccessLists.class);
 
-        registry.subtreeAdd(vppAclChildren(InstanceIdentifier.create(Acl.class)),
+        registry.subtreeAddBefore(vppAclChildren(InstanceIdentifier.create(Acl.class)),
             new GenericListWriter<>(rootNode.child(Acl.class),
-                new VppAclCustomizer(futureAclFacade, standardAclContext, macIpAClContext)));
+                new VppAclCustomizer(futureAclFacade, standardAclContext, macIpAClContext)),
+            aclHandledChildren(ACL_IID));
     }
 }