2 * Copyright (c) 2017 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.hc2vpp.vpp.classifier.factory.write;
19 import com.google.common.collect.Sets;
20 import com.google.inject.Inject;
21 import com.google.inject.name.Named;
22 import io.fd.hc2vpp.common.translate.util.NamingContext;
23 import io.fd.hc2vpp.v3po.factory.InterfacesWriterFactory;
24 import io.fd.hc2vpp.vpp.classifier.write.acl.egress.EgressIetfAclWriter;
25 import io.fd.hc2vpp.vpp.classifier.write.acl.ingress.IngressIetfAclWriter;
26 import io.fd.hc2vpp.vpp.classifier.write.acl.ingress.SubInterfaceIetfAclCustomizer;
27 import io.fd.honeycomb.translate.impl.write.GenericWriter;
28 import io.fd.honeycomb.translate.write.WriterFactory;
29 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev161214.ietf.acl.base.attributes.AccessLists;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev161214.ietf.acl.base.attributes.access.lists.Acl;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev161214.vpp.acl.attributes.IetfAcl;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev161214.vpp.acl.attributes.ietf.acl.Egress;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.acl.rev161214.vpp.acl.attributes.ietf.acl.Ingress;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.subinterface.acl.rev161214.VppSubinterfaceAclAugmentation;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceAugmentation;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.SubInterfaces;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces._interface.sub.interfaces.SubInterface;
39 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
41 public final class SubInterfacesClassifierIetfAclWriterFactory implements WriterFactory {
43 public static final InstanceIdentifier<SubinterfaceAugmentation> SUB_IFC_AUG_ID =
44 InterfacesWriterFactory.IFC_ID.augmentation(SubinterfaceAugmentation.class);
45 public static final InstanceIdentifier<SubInterface> SUB_IFC_ID =
46 SUB_IFC_AUG_ID.child(SubInterfaces.class).child(SubInterface.class);
48 public static final InstanceIdentifier<VppSubinterfaceAclAugmentation> SUB_IFC_ACL_AUG_ID =
49 SUB_IFC_ID.augmentation(VppSubinterfaceAclAugmentation.class);
51 public static final InstanceIdentifier<IetfAcl> SUBIF_IETF_ACL_ID = SUB_IFC_ACL_AUG_ID.child(IetfAcl.class);
52 public static final InstanceIdentifier<Ingress> SUBIF_INGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(Ingress.class);
53 public static final InstanceIdentifier<Egress> SUBIF_EGRESS_IETF_ACL_ID = SUBIF_IETF_ACL_ID.child(Egress.class);
55 private final IngressIetfAclWriter ingressAclWriter;
56 private final EgressIetfAclWriter egressAclWriter;
57 private final NamingContext ifcContext;
60 public SubInterfacesClassifierIetfAclWriterFactory(final IngressIetfAclWriter ingressAclWriter,
61 final EgressIetfAclWriter egressAclWriter,
62 @Named("interface-context") final NamingContext ifcContext) {
63 this.ingressAclWriter = ingressAclWriter;
64 this.egressAclWriter = egressAclWriter;
65 this.ifcContext = ifcContext;
69 public void init(final ModifiableWriterRegistryBuilder registry) {
70 // Ingress IETF-ACL, also handles AccessLists and Acl:
71 final InstanceIdentifier<AccessLists> accessListsIdIngress =
72 InstanceIdentifier.create(Ingress.class).child(AccessLists.class);
73 final InstanceIdentifier<?> aclIdIngress = accessListsIdIngress.child(Acl.class);
75 Sets.newHashSet(accessListsIdIngress, aclIdIngress),
76 new GenericWriter<>(SUBIF_INGRESS_IETF_ACL_ID,
77 new SubInterfaceIetfAclCustomizer(ingressAclWriter, ifcContext)));
79 // Egress IETF-ACL, also handles AccessLists and Acl:
80 final InstanceIdentifier<AccessLists> accessListsIdEgress =
81 InstanceIdentifier.create(Egress.class).child(AccessLists.class);
82 final InstanceIdentifier<?> aclIdEgress = accessListsIdEgress.child(Acl.class);
84 Sets.newHashSet(accessListsIdEgress, aclIdEgress),
85 new GenericWriter<>(SUBIF_EGRESS_IETF_ACL_ID,
86 new io.fd.hc2vpp.vpp.classifier.write.acl.egress.SubInterfaceIetfAclCustomizer(
87 egressAclWriter, ifcContext)));