2 * Copyright (c) 2016 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.v3po.factory;
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.interfacesstate.RewriteCustomizer;
24 import io.fd.hc2vpp.v3po.interfacesstate.SubInterfaceCustomizer;
25 import io.fd.hc2vpp.v3po.interfacesstate.SubInterfaceL2Customizer;
26 import io.fd.hc2vpp.v3po.interfacesstate.acl.ingress.SubInterfaceAclCustomizer;
27 import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
28 import io.fd.honeycomb.translate.impl.read.GenericInitListReader;
29 import io.fd.honeycomb.translate.impl.read.GenericInitReader;
30 import io.fd.honeycomb.translate.impl.read.GenericReader;
31 import io.fd.honeycomb.translate.read.ReaderFactory;
32 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
33 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
34 import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.Ip4Acl;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.Ip6Acl;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.acl.base.attributes.L2Acl;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceStateAugmentation;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceStateAugmentationBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.SubInterfaces;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.SubInterfacesBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.sub.interfaces.SubInterface;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.match.attributes.match.type.vlan.tagged.VlanTagged;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Acl;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.AclBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Match;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.acl.Ingress;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.l2.Rewrite;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.Tag;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.tag.rewrite.PushTags;
53 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
55 public final class SubinterfaceStateAugmentationReaderFactory implements ReaderFactory {
57 private final FutureJVppCore jvpp;
58 private final NamingContext ifcCtx;
59 private final NamingContext bdCtx;
60 private final VppClassifierContextManager classifyCtx;
63 public SubinterfaceStateAugmentationReaderFactory(final FutureJVppCore jvpp,
64 @Named("interface-context") final NamingContext ifcCtx,
65 @Named("bridge-domain-context") final NamingContext bdCtx,
66 @Named("classify-table-context") final VppClassifierContextManager classifyCtx) {
70 this.classifyCtx = classifyCtx;
74 public void init(final ModifiableReaderRegistryBuilder registry) {
75 // SubinterfaceStateAugmentation(Structural)
76 final InstanceIdentifier<SubinterfaceStateAugmentation> subIfcAugId =
77 InterfacesStateReaderFactory.IFC_ID.augmentation(SubinterfaceStateAugmentation.class);
78 registry.addStructuralReader(subIfcAugId, SubinterfaceStateAugmentationBuilder.class);
79 // SubInterfaces(Structural)
80 final InstanceIdentifier<SubInterfaces> subIfcsId = subIfcAugId.child(SubInterfaces.class);
81 registry.addStructuralReader(subIfcsId, SubInterfacesBuilder.class);
82 // SubInterface(Subtree)
83 final InstanceIdentifier<SubInterface> subIfcId = subIfcsId.child(SubInterface.class);
84 registry.subtreeAdd(Sets.newHashSet(
85 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
86 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
87 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(Dot1qTag.class),
88 InstanceIdentifier.create(SubInterface.class).child(Match.class),
89 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
90 new GenericInitListReader<>(subIfcId, new SubInterfaceCustomizer(jvpp, ifcCtx)));
92 final InstanceIdentifier<L2> l2Id = subIfcId.child(L2.class);
93 registry.add(new GenericInitReader<>(l2Id, new SubInterfaceL2Customizer(jvpp, ifcCtx, bdCtx)));
95 registry.subtreeAdd(Sets.newHashSet(
96 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
97 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
99 org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
100 new GenericReader<>(l2Id.child(Rewrite.class), new RewriteCustomizer(jvpp, ifcCtx)));
103 final InstanceIdentifier<Acl> aclIid = subIfcId.child(Acl.class);
104 registry.addStructuralReader(aclIid, AclBuilder.class);
106 final InstanceIdentifier<Ingress> ingressIdRelative = InstanceIdentifier.create(Ingress.class);
108 Sets.newHashSet(ingressIdRelative.child(L2Acl.class), ingressIdRelative.child(Ip4Acl.class),
109 ingressIdRelative.child(Ip6Acl.class)),
110 new GenericInitReader<>(aclIid.child(Ingress.class),
111 new SubInterfaceAclCustomizer(jvpp, ifcCtx, classifyCtx)));