Pbb Support
[honeycomb.git] / v3po / v3po2vpp / src / main / java / io / fd / honeycomb / translate / v3po / InterfacesWriterFactory.java
index 29a6ac5..d138dac 100644 (file)
@@ -41,6 +41,7 @@ import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv4AddressCustomizer;
 import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv4Customizer;
 import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv4NeighbourCustomizer;
 import io.fd.honeycomb.translate.v3po.interfaces.ip.Ipv6Customizer;
+import io.fd.honeycomb.translate.v3po.interfaces.pbb.PbbRewriteCustomizer;
 import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
 import io.fd.honeycomb.translate.vpp.util.NamingContext;
 import io.fd.honeycomb.translate.write.WriterFactory;
@@ -71,24 +72,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.Vxlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.VxlanGpe;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.acl.Ingress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.pbb.rev160410.PbbRewriteInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.pbb.rev160410.interfaces._interface.PbbRewrite;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public final class InterfacesWriterFactory implements WriterFactory {
 
     public static final InstanceIdentifier<Interface> IFC_ID =
-        InstanceIdentifier.create(Interfaces.class).child(Interface.class);
+            InstanceIdentifier.create(Interfaces.class).child(Interface.class);
     public static final InstanceIdentifier<VppInterfaceAugmentation> VPP_IFC_AUG_ID =
-        IFC_ID.augmentation(VppInterfaceAugmentation.class);
+            IFC_ID.augmentation(VppInterfaceAugmentation.class);
     public static final InstanceIdentifier<Acl> ACL_ID = VPP_IFC_AUG_ID.child(Acl.class);
     public static final InstanceIdentifier<Ingress> INGRESS_ACL_ID = ACL_ID.child(Ingress.class);
     public static final InstanceIdentifier<L2> L2_ID = VPP_IFC_AUG_ID.child(L2.class);
     public static final InstanceIdentifier<IetfAcl> IETF_ACL_ID = VPP_IFC_AUG_ID.child(IetfAcl.class);
     public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Ingress>
-        INGRESS_IETF_ACL_ID = IETF_ACL_ID.child(
-        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Ingress.class);
+            INGRESS_IETF_ACL_ID = IETF_ACL_ID.child(
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Ingress.class);
     public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Egress>
-        EGRESS_IETF_ACL_ID = IETF_ACL_ID.child(
-        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Egress.class);
+            EGRESS_IETF_ACL_ID = IETF_ACL_ID.child(
+            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Egress.class);
 
     private final FutureJVppCore jvpp;
     private final IetfAClWriter aclWriter;
@@ -123,7 +126,9 @@ public final class InterfacesWriterFactory implements WriterFactory {
         addInterface1AugmentationWriters(IFC_ID, registry);
         //   SubinterfaceAugmentation
         new SubinterfaceAugmentationWriterFactory(jvpp, aclWriter, ifcNamingContext, bdNamingContext,
-            classifyTableContext).init(registry);
+                classifyTableContext).init(registry);
+
+        addPbbAugmentationWriters(IFC_ID, registry);
     }
 
     private void addInterface1AugmentationWriters(final InstanceIdentifier<Interface> ifcId,
@@ -131,19 +136,19 @@ public final class InterfacesWriterFactory implements WriterFactory {
         final InstanceIdentifier<Interface1> ifc1AugId = ifcId.augmentation(Interface1.class);
         // Ipv6(after interface) =
         registry.addAfter(new GenericWriter<>(ifc1AugId.child(Ipv6.class), new Ipv6Customizer(jvpp)),
-            ifcId);
+                ifcId);
         // Ipv4(after interface)
         final InstanceIdentifier<Ipv4> ipv4Id = ifc1AugId.child(Ipv4.class);
         registry.addAfter(new GenericWriter<>(ipv4Id, new Ipv4Customizer(jvpp)),
-            ifcId);
+                ifcId);
         //  Address(after Ipv4) =
         final InstanceIdentifier<Address> ipv4AddressId = ipv4Id.child(Address.class);
         registry.addAfter(new GenericListWriter<>(ipv4AddressId, new Ipv4AddressCustomizer(jvpp, ifcNamingContext)),
-            ipv4Id);
+                ipv4Id);
         //  Neighbor(after ipv4Address)
         registry.addAfter(new GenericListWriter<>(ipv4Id.child(Neighbor.class), new Ipv4NeighbourCustomizer(jvpp,
-                ifcNamingContext)),
-            ipv4AddressId);
+                        ifcNamingContext)),
+                ipv4AddressId);
     }
 
     private void addVppInterfaceAgmentationWriters(final InstanceIdentifier<Interface> ifcId,
@@ -151,24 +156,24 @@ public final class InterfacesWriterFactory implements WriterFactory {
         // VhostUser(Needs to be executed before Interface customizer) =
         final InstanceIdentifier<VhostUser> vhostId = VPP_IFC_AUG_ID.child(VhostUser.class);
         registry.addBefore(new GenericWriter<>(vhostId, new VhostUserCustomizer(jvpp, ifcNamingContext)),
-            ifcId);
+                ifcId);
         // Vxlan(Needs to be executed before Interface customizer) =
         final InstanceIdentifier<Vxlan> vxlanId = VPP_IFC_AUG_ID.child(Vxlan.class);
         registry.addBefore(new GenericWriter<>(vxlanId, new VxlanCustomizer(jvpp, ifcNamingContext, ifcDisableContext)),
-            ifcId);
+                ifcId);
         // VxlanGpe(Needs to be executed before Interface customizer) =
         final InstanceIdentifier<VxlanGpe> vxlanGpeId = VPP_IFC_AUG_ID.child(VxlanGpe.class);
         registry.addBefore(new GenericWriter<>(vxlanGpeId,
-            new VxlanGpeCustomizer(jvpp, ifcNamingContext, ifcDisableContext)), ifcId);
+                new VxlanGpeCustomizer(jvpp, ifcNamingContext, ifcDisableContext)), ifcId);
         // Tap(Needs to be executed before Interface customizer) =
         final InstanceIdentifier<Tap> tapId = VPP_IFC_AUG_ID.child(Tap.class);
         registry.addBefore(new GenericWriter<>(tapId, new TapCustomizer(jvpp, ifcNamingContext)),
-            ifcId);
+                ifcId);
 
         // Gre(Needs to be executed before Interface customizer) =
         final InstanceIdentifier<Gre> greId = VPP_IFC_AUG_ID.child(Gre.class);
         registry.addBefore(new GenericWriter<>(greId, new GreCustomizer(jvpp, ifcNamingContext)),
-            ifcId);
+                ifcId);
 
 
         final Set<InstanceIdentifier<?>> specificIfcTypes = Sets.newHashSet(vhostId, vxlanGpeId, vxlanGpeId, tapId);
@@ -177,48 +182,54 @@ public final class InterfacesWriterFactory implements WriterFactory {
         registry.add(new GenericWriter<>(VPP_IFC_AUG_ID.child(Ethernet.class), new EthernetCustomizer(jvpp)));
         // Routing(Execute only after specific interface customizers) =
         registry.addAfter(
-            new GenericWriter<>(VPP_IFC_AUG_ID.child(Routing.class), new RoutingCustomizer(jvpp, ifcNamingContext)),
-            specificIfcTypes);
+                new GenericWriter<>(VPP_IFC_AUG_ID.child(Routing.class), new RoutingCustomizer(jvpp, ifcNamingContext)),
+                specificIfcTypes);
         // L2(Execute only after subinterface (and all other ifc types) =
         registry.addAfter(new GenericWriter<>(L2_ID, new L2Customizer(jvpp, ifcNamingContext, bdNamingContext)),
-            SubinterfaceAugmentationWriterFactory.SUB_IFC_ID);
+                SubinterfaceAugmentationWriterFactory.SUB_IFC_ID);
         // Proxy Arp (execute after specific interface customizers)
         registry.addAfter(
-            new GenericWriter<>(VPP_IFC_AUG_ID.child(ProxyArp.class), new ProxyArpCustomizer(jvpp)),
-            specificIfcTypes);
+                new GenericWriter<>(VPP_IFC_AUG_ID.child(ProxyArp.class), new ProxyArpCustomizer(jvpp)),
+                specificIfcTypes);
         // Ingress (execute after classify table and session writers)
         // also handles L2Acl, Ip4Acl and Ip6Acl:
         final InstanceIdentifier<Ingress> ingressId = InstanceIdentifier.create(Ingress.class);
         registry
-            .subtreeAddAfter(
-                Sets.newHashSet(ingressId.child(L2Acl.class), ingressId.child(Ip4Acl.class),
-                    ingressId.child(Ip6Acl.class)),
-                new GenericWriter<>(INGRESS_ACL_ID,
-                    new AclCustomizer(jvpp, ifcNamingContext, classifyTableContext)),
-                Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));
+                .subtreeAddAfter(
+                        Sets.newHashSet(ingressId.child(L2Acl.class), ingressId.child(Ip4Acl.class),
+                                ingressId.child(Ip6Acl.class)),
+                        new GenericWriter<>(INGRESS_ACL_ID,
+                                new AclCustomizer(jvpp, ifcNamingContext, classifyTableContext)),
+                        Sets.newHashSet(CLASSIFY_TABLE_ID, CLASSIFY_SESSION_ID));
 
         // Ingress IETF-ACL, also handles AccessLists and Acl:
         final InstanceIdentifier<AccessLists> accessListsIdIngress = InstanceIdentifier.create(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Ingress.class)
-            .child(AccessLists.class);
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Ingress.class)
+                .child(AccessLists.class);
         final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.access.lists.Acl.class);
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.access.lists.Acl.class);
         registry.subtreeAdd(
-            Sets.newHashSet(accessListsIdIngress, aclIdIngress),
-            new GenericWriter<>(INGRESS_IETF_ACL_ID, new IetfAclCustomizer(aclWriter, ifcNamingContext)));
+                Sets.newHashSet(accessListsIdIngress, aclIdIngress),
+                new GenericWriter<>(INGRESS_IETF_ACL_ID, new IetfAclCustomizer(aclWriter, ifcNamingContext)));
 
         // Ingress IETF-ACL, also handles AccessLists and Acl:
         final InstanceIdentifier<AccessLists> accessListsIdEgress = InstanceIdentifier.create(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Egress.class)
-            .child(AccessLists.class);
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ietf.acl.Egress.class)
+                .child(AccessLists.class);
         final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(
-            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.access.lists.Acl.class);
+                org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.ietf.acl.base.attributes.access.lists.Acl.class);
         registry.subtreeAdd(
-            Sets.newHashSet(accessListsIdEgress, aclIdEgress),
-            new GenericWriter<>(EGRESS_IETF_ACL_ID,
-                new io.fd.honeycomb.translate.v3po.interfaces.acl.egress.IetfAclCustomizer(aclWriter,
-                    ifcNamingContext)));
+                Sets.newHashSet(accessListsIdEgress, aclIdEgress),
+                new GenericWriter<>(EGRESS_IETF_ACL_ID,
+                        new io.fd.honeycomb.translate.v3po.interfaces.acl.egress.IetfAclCustomizer(aclWriter,
+                                ifcNamingContext)));
     }
 
+    private void addPbbAugmentationWriters(final InstanceIdentifier<Interface> ifcId,
+                                           final ModifiableWriterRegistryBuilder registry) {
+        final InstanceIdentifier<PbbRewrite> pbbRewriteId =
+                ifcId.augmentation(PbbRewriteInterfaceAugmentation.class).child(PbbRewrite.class);
 
+        registry.add(new GenericWriter<>(pbbRewriteId, new PbbRewriteCustomizer(jvpp, ifcNamingContext)));
+    }
 }