diff options
author | 2016-12-06 07:56:27 +0100 | |
---|---|---|
committer | 2016-12-07 09:46:42 +0000 | |
commit | 304258199c928cd73baced4b6c62614b469c272e (patch) | |
tree | 58d5a72e42e04960e344ec1a97e6d768dc59667a /v3po/v3po2vpp/src/main/java/io/fd | |
parent | fb7dd3797b431d2a14c574c712fdf43bb9acb7a3 (diff) |
HONEYCOMB-304: provide separate guice module for ietf-acl implementation
Current IETF-ACL implementation is using vpp-classfier.
In the future, acl implementation based on acl plugin is going to be
supported. Current implementation is going to be deprecated, then removed.
In order to switch between acl implementations, ietf-acl configuration
needs separate guice module.
After fixing nested augmentation support (HONEYCOMB-302), current
implementation can be moved to separate hc2vpp module (HONEYCOMB-308).
Change-Id: I1668c274c03f9a750654cb0f96ec328af09f89f5
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd')
15 files changed, 260 insertions, 106 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/ClassifierIetfAclModule.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/ClassifierIetfAclModule.java new file mode 100644 index 000000000..dc21a2911 --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/ClassifierIetfAclModule.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.v3po; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; +import io.fd.hc2vpp.v3po.factory.AclWriterFactory; +import io.fd.hc2vpp.v3po.factory.EgressIetfAClWriterProvider; +import io.fd.hc2vpp.v3po.factory.IngressIetfAClWriterProvider; +import io.fd.hc2vpp.v3po.factory.InterfacesClassifierIetfAclWriterFactory; +import io.fd.hc2vpp.v3po.factory.SubInterfacesClassifierIetfAclWriterFactory; +import io.fd.hc2vpp.v3po.interfaces.acl.egress.EgressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; +import io.fd.honeycomb.translate.write.WriterFactory; +import net.jmob.guice.conf.core.ConfigurationModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ClassifierIetfAclModule extends AbstractModule { + + private static final Logger LOG = LoggerFactory.getLogger(ClassifierIetfAclModule.class); + + @Override + protected void configure() { + LOG.debug("Installing VppClassifierAcl module"); + install(ConfigurationModule.create()); + + // Utils + bind(IngressIetfAclWriter.class).toProvider(IngressIetfAClWriterProvider.class); + bind(EgressIetfAclWriter.class).toProvider(EgressIetfAClWriterProvider.class); + + // Writers + final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class); + writerFactoryBinder.addBinding().to(AclWriterFactory.class); + writerFactoryBinder.addBinding().to(InterfacesClassifierIetfAclWriterFactory.class); + writerFactoryBinder.addBinding().to(SubInterfacesClassifierIetfAclWriterFactory.class); + + LOG.info("Module VppClassifierAcl module successfully configured"); + } +} diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/V3poModule.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/V3poModule.java index ad9d04888..6abe33e83 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/V3poModule.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/V3poModule.java @@ -19,15 +19,23 @@ package io.fd.hc2vpp.v3po; import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.cfgattrs.V3poConfiguration; +import io.fd.hc2vpp.v3po.factory.EgressIetfAClWriterProvider; +import io.fd.hc2vpp.v3po.factory.IngressIetfAClWriterProvider; +import io.fd.hc2vpp.v3po.factory.InterfacesStateReaderFactory; +import io.fd.hc2vpp.v3po.factory.InterfacesWriterFactory; +import io.fd.hc2vpp.v3po.factory.VppClassifierHoneycombWriterFactory; +import io.fd.hc2vpp.v3po.factory.VppClassifierReaderFactory; +import io.fd.hc2vpp.v3po.factory.VppHoneycombWriterFactory; +import io.fd.hc2vpp.v3po.factory.VppStateHoneycombReaderFactory; import io.fd.hc2vpp.v3po.interfaces.acl.egress.EgressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; import io.fd.hc2vpp.v3po.notification.InterfaceChangeNotificationProducer; import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManagerImpl; import io.fd.honeycomb.notification.ManagedNotificationProducer; import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.hc2vpp.v3po.cfgattrs.V3poConfiguration; -import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriterFactory; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -81,7 +89,6 @@ public class V3poModule extends AbstractModule { writerFactoryBinder.addBinding().to(InterfacesWriterFactory.class); writerFactoryBinder.addBinding().to(VppHoneycombWriterFactory.class); writerFactoryBinder.addBinding().to(VppClassifierHoneycombWriterFactory.class); - writerFactoryBinder.addBinding().to(AclWriterFactory.class); // Notifications final Multibinder<ManagedNotificationProducer> notifiersBinder = diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/AclWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java index dbac5f342..2b72cd058 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/AclWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; -import static io.fd.hc2vpp.v3po.InterfacesWriterFactory.IETF_ACL_ID; -import static io.fd.hc2vpp.v3po.SubinterfaceAugmentationWriterFactory.SUBIF_IETF_ACL_ID; +import static io.fd.hc2vpp.v3po.factory.InterfacesClassifierIetfAclWriterFactory.IETF_ACL_ID; +import static io.fd.hc2vpp.v3po.factory.SubInterfacesClassifierIetfAclWriterFactory.SUBIF_IETF_ACL_ID; import com.google.common.collect.Sets; import io.fd.honeycomb.translate.impl.write.GenericListWriter; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/EgressIetfAClWriterProvider.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/EgressIetfAClWriterProvider.java index 0e4aaa80d..9ccc1d8e5 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/EgressIetfAClWriterProvider.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/EgressIetfAClWriterProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.inject.Inject; import com.google.inject.Provider; @@ -23,7 +23,7 @@ import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManagerImpl; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.context.rev161214.mapping.entry.context.attributes.acl.mapping.entry.context.MappingTable; -class EgressIetfAClWriterProvider implements Provider<EgressIetfAclWriter> { +public class EgressIetfAClWriterProvider implements Provider<EgressIetfAclWriter> { private final FutureJVppCore jvpp; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/IngressIetfAClWriterProvider.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/IngressIetfAClWriterProvider.java index 12349a356..be6a2a3fb 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/IngressIetfAClWriterProvider.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/IngressIetfAClWriterProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.inject.Inject; import com.google.inject.Provider; @@ -23,7 +23,7 @@ import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; import io.fd.vpp.jvpp.core.future.FutureJVppCore; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.context.rev161214.mapping.entry.context.attributes.acl.mapping.entry.context.MappingTable; -class IngressIetfAClWriterProvider implements Provider<IngressIetfAclWriter> { +public class IngressIetfAClWriterProvider implements Provider<IngressIetfAclWriter> { private final FutureJVppCore jvpp; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java new file mode 100644 index 000000000..b463e47c6 --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.v3po.factory; + +import com.google.common.collect.Sets; +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfaces.acl.egress.EgressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; +import io.fd.honeycomb.translate.impl.write.GenericWriter; +import io.fd.honeycomb.translate.write.WriterFactory; +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.IetfAcl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ietf.acl.Egress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ietf.acl.Ingress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.AccessLists; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public final class InterfacesClassifierIetfAclWriterFactory implements WriterFactory { + + public static final InstanceIdentifier<Interface> IFC_ID = + InstanceIdentifier.create(Interfaces.class).child(Interface.class); + public static final InstanceIdentifier<VppInterfaceAugmentation> VPP_IFC_AUG_ID = + IFC_ID.augmentation(VppInterfaceAugmentation.class); + public static final InstanceIdentifier<IetfAcl> IETF_ACL_ID = VPP_IFC_AUG_ID.child(IetfAcl.class); + public static final InstanceIdentifier<Ingress> INGRESS_IETF_ACL_ID = IETF_ACL_ID.child(Ingress.class); + public static final InstanceIdentifier<Egress> EGRESS_IETF_ACL_ID = IETF_ACL_ID.child(Egress.class); + + private final IngressIetfAclWriter ingressAclWriter; + private final EgressIetfAclWriter egressAclWriter; + private final NamingContext ifcNamingContext; + + @Inject + public InterfacesClassifierIetfAclWriterFactory(final IngressIetfAclWriter ingressAclWriter, + final EgressIetfAclWriter egressAclWriter, + @Named("interface-context") final NamingContext interfaceContextDependency) { + this.ingressAclWriter = ingressAclWriter; + this.egressAclWriter = egressAclWriter; + this.ifcNamingContext = interfaceContextDependency; + } + + @Override + public void init(final ModifiableWriterRegistryBuilder registry) { + // Ingress IETF-ACL, also handles AccessLists and Acl: + final InstanceIdentifier<AccessLists> accessListsIdIngress = + InstanceIdentifier.create(Ingress.class).child(AccessLists.class); + final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(Acl.class); + registry.subtreeAdd( + Sets.newHashSet(accessListsIdIngress, aclIdIngress), + new GenericWriter<>(INGRESS_IETF_ACL_ID, + new io.fd.hc2vpp.v3po.interfaces.acl.ingress.IetfAclCustomizer(ingressAclWriter, ifcNamingContext))); + + // Ingress IETF-ACL, also handles AccessLists and Acl: + final InstanceIdentifier<AccessLists> accessListsIdEgress = + InstanceIdentifier.create(Egress.class).child(AccessLists.class); + final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(Acl.class); + registry.subtreeAdd( + Sets.newHashSet(accessListsIdEgress, aclIdEgress), + new GenericWriter<>(EGRESS_IETF_ACL_ID, + new io.fd.hc2vpp.v3po.interfaces.acl.egress.IetfAclCustomizer(egressAclWriter, ifcNamingContext))); + } +} diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/InterfacesStateReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesStateReaderFactory.java index 5b9ee6f9f..66777d93f 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/InterfacesStateReaderFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesStateReaderFactory.java @@ -14,12 +14,13 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; import io.fd.hc2vpp.v3po.interfacesstate.EthernetCustomizer; import io.fd.hc2vpp.v3po.interfacesstate.GreCustomizer; import io.fd.hc2vpp.v3po.interfacesstate.InterfaceCustomizer; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/InterfacesWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java index c0848631d..fbf741fba 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/InterfacesWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesWriterFactory.java @@ -14,15 +14,16 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; -import static io.fd.hc2vpp.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID; -import static io.fd.hc2vpp.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID; +import static io.fd.hc2vpp.v3po.factory.VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID; +import static io.fd.hc2vpp.v3po.factory.VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID; import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.name.Named; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; import io.fd.hc2vpp.v3po.interfaces.EthernetCustomizer; import io.fd.hc2vpp.v3po.interfaces.GreCustomizer; import io.fd.hc2vpp.v3po.interfaces.InterfaceCustomizer; @@ -61,7 +62,6 @@ 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.rev161214.interfaces._interface.Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Ethernet; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Gre; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.IetfAcl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.L2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Loopback; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ProxyArp; @@ -76,7 +76,6 @@ 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.vpp.classfier.acl.rev161214.acl.base.attributes.Ip4Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.Ip6Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.L2Acl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.AccessLists; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.pbb.rev161214.PbbRewriteInterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.pbb.rev161214.interfaces._interface.PbbRewrite; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -90,13 +89,6 @@ public final class InterfacesWriterFactory implements WriterFactory { 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.rev161214.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.rev161214.interfaces._interface.ietf.acl.Ingress.class); - public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.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.rev161214.interfaces._interface.ietf.acl.Egress.class); private final FutureJVppCore jvpp; private final IngressIetfAclWriter ingressAclWriter; @@ -130,11 +122,11 @@ public final class InterfacesWriterFactory implements WriterFactory { registry.add(new GenericListWriter<>(IFC_ID, new InterfaceCustomizer(jvpp, ifcNamingContext))); // VppInterfaceAugmentation addVppInterfaceAgmentationWriters(IFC_ID, registry); - // Interface1 (ietf-ip augmentation) + // Interface1 (ietf-ip augmentation) addInterface1AugmentationWriters(IFC_ID, registry); // SubinterfaceAugmentation - new SubinterfaceAugmentationWriterFactory(jvpp, ingressAclWriter, egressAclWriter, ifcNamingContext, bdNamingContext, - classifyTableContext).init(registry); + new SubinterfaceAugmentationWriterFactory(jvpp, ifcNamingContext, bdNamingContext, + classifyTableContext).init(registry); addPbbAugmentationWriters(IFC_ID, registry); } @@ -214,27 +206,6 @@ public final class InterfacesWriterFactory implements WriterFactory { 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.rev161214.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.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class); - registry.subtreeAdd( - Sets.newHashSet(accessListsIdIngress, aclIdIngress), - new GenericWriter<>(INGRESS_IETF_ACL_ID, new io.fd.hc2vpp.v3po.interfaces.acl.ingress.IetfAclCustomizer(ingressAclWriter, 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.rev161214.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.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class); - registry.subtreeAdd( - Sets.newHashSet(accessListsIdEgress, aclIdEgress), - new GenericWriter<>(EGRESS_IETF_ACL_ID, - new io.fd.hc2vpp.v3po.interfaces.acl.egress.IetfAclCustomizer(egressAclWriter, - ifcNamingContext))); // Span writers // Mirrored interfaces final InstanceIdentifier<MirroredInterfaces> mirroredIfcsId = VPP_IFC_AUG_ID diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubInterfacesClassifierIetfAclWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubInterfacesClassifierIetfAclWriterFactory.java new file mode 100644 index 000000000..5748f081b --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubInterfacesClassifierIetfAclWriterFactory.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.hc2vpp.v3po.factory; + +import com.google.common.collect.Sets; +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfaces.acl.egress.EgressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.SubInterfaceIetfAclCustomizer; +import io.fd.honeycomb.translate.impl.write.GenericWriter; +import io.fd.honeycomb.translate.write.WriterFactory; +import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.AccessLists; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceAugmentation; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.SubInterfaces; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.sub.interfaces.SubInterface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.IetfAcl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public final class SubInterfacesClassifierIetfAclWriterFactory implements WriterFactory { + + public static final InstanceIdentifier<SubinterfaceAugmentation> SUB_IFC_AUG_ID = + InterfacesWriterFactory.IFC_ID.augmentation(SubinterfaceAugmentation.class); + public static final InstanceIdentifier<SubInterface> SUB_IFC_ID = + SUB_IFC_AUG_ID.child(SubInterfaces.class).child(SubInterface.class); + public static final InstanceIdentifier<IetfAcl> SUBIF_IETF_ACL_ID = SUB_IFC_ID.child(IetfAcl.class); + public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(Ingress.class); + public static final InstanceIdentifier<Egress> SUBIF_EGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(Egress.class); + + private final IngressIetfAclWriter ingressAclWriter; + private final EgressIetfAclWriter egressAclWriter; + private final NamingContext ifcContext; + + @Inject + public SubInterfacesClassifierIetfAclWriterFactory(final IngressIetfAclWriter ingressAclWriter, + final EgressIetfAclWriter egressAclWriter, + @Named("interface-context") final NamingContext ifcContext) { + this.ingressAclWriter = ingressAclWriter; + this.egressAclWriter = egressAclWriter; + this.ifcContext = ifcContext; + } + + @Override + public void init(final ModifiableWriterRegistryBuilder registry) { + // Ingress IETF-ACL, also handles AccessLists and Acl: + final InstanceIdentifier<AccessLists> accessListsIdIngress = + InstanceIdentifier.create(Ingress.class).child(AccessLists.class); + final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(Acl.class); + registry.subtreeAdd( + Sets.newHashSet(accessListsIdIngress, aclIdIngress), + new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID, + new SubInterfaceIetfAclCustomizer(ingressAclWriter, ifcContext))); + + // Egress IETF-ACL, also handles AccessLists and Acl: + final InstanceIdentifier<AccessLists> accessListsIdEgress = + InstanceIdentifier.create(Egress.class).child(AccessLists.class); + final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(Acl.class); + registry.subtreeAdd( + Sets.newHashSet(accessListsIdEgress, aclIdEgress), + new GenericWriter<>(SUBIF_EGRESS_IETF_ACL_ID, + new io.fd.hc2vpp.v3po.interfaces.acl.egress.SubInterfaceIetfAclCustomizer( + egressAclWriter, ifcContext))); + } +} diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/SubinterfaceAugmentationWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubinterfaceAugmentationWriterFactory.java index 8f36eff3a..0b9b848ff 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/SubinterfaceAugmentationWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubinterfaceAugmentationWriterFactory.java @@ -14,24 +14,18 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; - -import static io.fd.hc2vpp.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID; -import static io.fd.hc2vpp.v3po.VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID; +package io.fd.hc2vpp.v3po.factory; import com.google.common.collect.Sets; -import io.fd.hc2vpp.v3po.interfaces.acl.egress.EgressIetfAclWriter; -import io.fd.hc2vpp.v3po.interfaces.acl.ingress.SubInterfaceAclCustomizer; -import io.fd.hc2vpp.v3po.interfaces.acl.ingress.SubInterfaceIetfAclCustomizer; -import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; -import io.fd.honeycomb.translate.impl.write.GenericListWriter; -import io.fd.honeycomb.translate.impl.write.GenericWriter; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfaces.RewriteCustomizer; import io.fd.hc2vpp.v3po.interfaces.SubInterfaceCustomizer; import io.fd.hc2vpp.v3po.interfaces.SubInterfaceL2Customizer; -import io.fd.hc2vpp.v3po.interfaces.acl.ingress.IngressIetfAclWriter; +import io.fd.hc2vpp.v3po.interfaces.acl.ingress.SubInterfaceAclCustomizer; import io.fd.hc2vpp.v3po.interfaces.ip.SubInterfaceIpv4AddressCustomizer; -import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; +import io.fd.honeycomb.translate.impl.write.GenericListWriter; +import io.fd.honeycomb.translate.impl.write.GenericWriter; import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder; import io.fd.vpp.jvpp.core.future.FutureJVppCore; @@ -39,13 +33,11 @@ import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.Ip4Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.Ip6Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.L2Acl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.AccessLists; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.SubInterfaces; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.sub.interfaces.SubInterface; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.match.attributes.match.type.vlan.tagged.VlanTagged; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Acl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.IetfAcl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Match; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags; @@ -60,8 +52,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class SubinterfaceAugmentationWriterFactory implements WriterFactory { private final FutureJVppCore jvpp; - private final IngressIetfAclWriter ingressAclWriter; - private final EgressIetfAclWriter egressAclWriter; private final NamingContext ifcContext; private final NamingContext bdContext; private final VppClassifierContextManager classifyTableContext; @@ -74,19 +64,9 @@ public final class SubinterfaceAugmentationWriterFactory implements WriterFactor L2.class); public static final InstanceIdentifier<Acl> SUBIF_ACL_ID = SUB_IFC_ID.child(Acl.class); public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_ACL_ID = SUBIF_ACL_ID.child(Ingress.class); - public static final InstanceIdentifier<IetfAcl> SUBIF_IETF_ACL_ID = SUB_IFC_ID.child(IetfAcl.class); - public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress> SUBIF_INGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.class); - public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress> SUBIF_EGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress.class); - public SubinterfaceAugmentationWriterFactory(final FutureJVppCore jvpp, - final IngressIetfAclWriter ingressAclWriter, - final EgressIetfAclWriter egressAclWriter, - final NamingContext ifcContext, final NamingContext bdContext, final VppClassifierContextManager classifyTableContext) { + public SubinterfaceAugmentationWriterFactory(final FutureJVppCore jvpp, final NamingContext ifcContext, final NamingContext bdContext, final VppClassifierContextManager classifyTableContext) { this.jvpp = jvpp; - this.ingressAclWriter = ingressAclWriter; - this.egressAclWriter = egressAclWriter; this.ifcContext = ifcContext; this.bdContext = bdContext; this.classifyTableContext = classifyTableContext; @@ -132,27 +112,6 @@ public final class SubinterfaceAugmentationWriterFactory implements WriterFactor .subtreeAddAfter( Sets.newHashSet(aclId.child(L2Acl.class), aclId.child(Ip4Acl.class), aclId.child(Ip6Acl.class)), new GenericWriter<>(SUBIF_INGRESS_ACL_ID, new SubInterfaceAclCustomizer(jvpp, ifcContext, 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.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Ingress.class) - .child(AccessLists.class); - final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class); - registry.subtreeAdd( - Sets.newHashSet(accessListsIdIngress, aclIdIngress), - new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID, new SubInterfaceIetfAclCustomizer(ingressAclWriter, ifcContext))); - - // Egress IETF-ACL, also handles AccessLists and Acl: - final InstanceIdentifier<AccessLists> accessListsIdEgress = InstanceIdentifier.create( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.ietf.acl.Egress.class) - .child(AccessLists.class); - final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child( - org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl.class); - registry.subtreeAdd( - Sets.newHashSet(accessListsIdEgress, aclIdEgress), - new GenericWriter<>(SUBIF_EGRESS_IETF_ACL_ID, new io.fd.hc2vpp.v3po.interfaces.acl.egress.SubInterfaceIetfAclCustomizer( - egressAclWriter, ifcContext))); + Sets.newHashSet(VppClassifierHoneycombWriterFactory.CLASSIFY_TABLE_ID, VppClassifierHoneycombWriterFactory.CLASSIFY_SESSION_ID)); } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/SubinterfaceStateAugmentationReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubinterfaceStateAugmentationReaderFactory.java index e449f9aa8..1946a28c7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/SubinterfaceStateAugmentationReaderFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/SubinterfaceStateAugmentationReaderFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.common.collect.Sets; import io.fd.hc2vpp.v3po.interfacesstate.RewriteCustomizer; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppClassifierHoneycombWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppClassifierHoneycombWriterFactory.java index 1443c5576..5a7b64694 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppClassifierHoneycombWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppClassifierHoneycombWriterFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.inject.Inject; import com.google.inject.name.Named; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppClassifierReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppClassifierReaderFactory.java index d612314e1..56983e9f3 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppClassifierReaderFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppClassifierReaderFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.inject.Inject; import com.google.inject.name.Named; diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppHoneycombWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppHoneycombWriterFactory.java index 3629fbcdb..0fb95938a 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppHoneycombWriterFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppHoneycombWriterFactory.java @@ -14,9 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; - -import static io.fd.hc2vpp.v3po.InterfacesWriterFactory.L2_ID; +package io.fd.hc2vpp.v3po.factory; import com.google.common.collect.Sets; import com.google.inject.Inject; @@ -62,7 +60,7 @@ public final class VppHoneycombWriterFactory implements WriterFactory { InstanceIdentifier.create(Vpp.class).child(BridgeDomains.class).child(BridgeDomain.class); registry.addBefore(new GenericListWriter<>(bdId, new BridgeDomainCustomizer(jvpp, bdContext)), Sets.newHashSet( - L2_ID, + InterfacesWriterFactory.L2_ID, SubinterfaceAugmentationWriterFactory.L2_ID)); // L2FibTable has no handlers // L2FibEntry(handled after BridgeDomain and L2 of ifc and subifc) = @@ -71,7 +69,7 @@ public final class VppHoneycombWriterFactory implements WriterFactory { new GenericListWriter<>(l2FibEntryId, new L2FibEntryCustomizer(jvpp, bdContext, ifcContext)), Sets.newHashSet( bdId, - L2_ID, + InterfacesWriterFactory.L2_ID, SubinterfaceAugmentationWriterFactory.L2_ID)); // ArpTerminationTable has no handlers // ArpTerminationTableEntry(handled after BridgeDomain) = diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppStateHoneycombReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppStateHoneycombReaderFactory.java index 8fcad8f49..6d019ea2a 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/VppStateHoneycombReaderFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/VppStateHoneycombReaderFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.hc2vpp.v3po; +package io.fd.hc2vpp.v3po.factory; import com.google.inject.Inject; import com.google.inject.name.Named; |