summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-12-06 07:56:27 +0100
committerJan Srnicek <jsrnicek@cisco.com>2016-12-07 09:46:42 +0000
commit304258199c928cd73baced4b6c62614b469c272e (patch)
tree58d5a72e42e04960e344ec1a97e6d768dc59667a /v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java
parentfb7dd3797b431d2a14c574c712fdf43bb9acb7a3 (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/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/InterfacesClassifierIetfAclWriterFactory.java81
1 files changed, 81 insertions, 0 deletions
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)));
+ }
+}