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.honeycomb.translate.v3po;
19 import com.google.common.collect.Sets;
20 import io.fd.honeycomb.translate.impl.read.GenericListReader;
21 import io.fd.honeycomb.translate.impl.read.GenericReader;
22 import io.fd.honeycomb.translate.read.ReaderFactory;
23 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
24 import io.fd.honeycomb.translate.v3po.interfacesstate.RewriteCustomizer;
25 import io.fd.honeycomb.translate.v3po.interfacesstate.SubInterfaceCustomizer;
26 import io.fd.honeycomb.translate.v3po.interfacesstate.acl.ingress.SubInterfaceAclCustomizer;
27 import io.fd.honeycomb.translate.v3po.interfacesstate.SubInterfaceL2Customizer;
28 import io.fd.honeycomb.translate.v3po.interfacesstate.ip.SubInterfaceIpv4AddressCustomizer;
29 import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
30 import io.fd.honeycomb.translate.vpp.util.NamingContext;
31 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
32 import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.Ip4Acl;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.Ip6Acl;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.acl.base.attributes.L2Acl;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceStateAugmentation;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.SubinterfaceStateAugmentationBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.SubInterfaces;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.SubInterfacesBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.interfaces.state._interface.sub.interfaces.SubInterface;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.match.attributes.match.type.vlan.tagged.VlanTagged;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Acl;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.AclBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Match;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.acl.Ingress;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.l2.Rewrite;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.Tag;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.Ipv4;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.Ipv4Builder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.ipv4.Address;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.tag.rewrite.PushTags;
54 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
56 final class SubinterfaceStateAugmentationReaderFactory implements ReaderFactory {
58 private final FutureJVppCore jvpp;
59 private final NamingContext ifcCtx;
60 private final NamingContext bdCtx;
61 private final VppClassifierContextManager classifyCtx;
63 SubinterfaceStateAugmentationReaderFactory(final FutureJVppCore jvpp, final NamingContext ifcCtx,
64 final NamingContext bdCtx,
65 final VppClassifierContextManager classifyCtx) {
69 this.classifyCtx = classifyCtx;
73 public void init(final ModifiableReaderRegistryBuilder registry) {
74 // SubinterfaceStateAugmentation(Structural)
75 final InstanceIdentifier<SubinterfaceStateAugmentation> subIfcAugId =
76 InterfacesStateReaderFactory.IFC_ID.augmentation(SubinterfaceStateAugmentation.class);
77 registry.addStructuralReader(subIfcAugId, SubinterfaceStateAugmentationBuilder.class);
78 // SubInterfaces(Structural)
79 final InstanceIdentifier<SubInterfaces> subIfcsId = subIfcAugId.child(SubInterfaces.class);
80 registry.addStructuralReader(subIfcsId, SubInterfacesBuilder.class);
81 // SubInterface(Subtree)
82 final InstanceIdentifier<SubInterface> subIfcId = subIfcsId.child(SubInterface.class);
83 registry.subtreeAdd(Sets.newHashSet(
84 InstanceIdentifier.create(SubInterface.class).child(Tags.class),
85 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class),
86 InstanceIdentifier.create(SubInterface.class).child(Tags.class).child(Tag.class).child(Dot1qTag.class),
87 InstanceIdentifier.create(SubInterface.class).child(Match.class),
88 InstanceIdentifier.create(SubInterface.class).child(Match.class).child(VlanTagged.class)),
89 new GenericListReader<>(subIfcId, new SubInterfaceCustomizer(jvpp, ifcCtx)));
91 final InstanceIdentifier<L2> l2Id = subIfcId.child(L2.class);
92 registry.add(new GenericReader<>(l2Id, new SubInterfaceL2Customizer(jvpp, ifcCtx, bdCtx)));
94 registry.subtreeAdd(Sets.newHashSet(
95 InstanceIdentifier.create(Rewrite.class).child(PushTags.class),
96 InstanceIdentifier.create(Rewrite.class).child(PushTags.class)
98 org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.Dot1qTag.class)),
99 new GenericReader<>(l2Id.child(Rewrite.class), new RewriteCustomizer(jvpp, ifcCtx)));
101 final InstanceIdentifier<Ipv4> ipv4Id = subIfcId.child(Ipv4.class);
102 registry.addStructuralReader(ipv4Id, Ipv4Builder.class);
105 new GenericListReader<>(ipv4Id.child(Address.class), new SubInterfaceIpv4AddressCustomizer(jvpp, ifcCtx)));
107 final InstanceIdentifier<Acl> aclIid = subIfcId.child(Acl.class);
108 registry.addStructuralReader(aclIid, AclBuilder.class);
110 final InstanceIdentifier<Ingress> ingressIdRelative = InstanceIdentifier.create(Ingress.class);
112 Sets.newHashSet(ingressIdRelative.child(L2Acl.class), ingressIdRelative.child(Ip4Acl.class),
113 ingressIdRelative.child(Ip6Acl.class)),
114 new GenericReader<>(aclIid.child(Ingress.class),
115 new SubInterfaceAclCustomizer(jvpp, ifcCtx, classifyCtx)));