2 * Copyright (c) 2016 Intel 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.vppnsh.impl.oper;
19 import com.google.inject.Inject;
20 import com.google.inject.name.Named;
21 import io.fd.honeycomb.translate.impl.read.GenericListReader;
22 import io.fd.honeycomb.translate.vpp.util.NamingContext;
23 import io.fd.honeycomb.translate.read.ReaderFactory;
24 import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
25 import javax.annotation.Nonnull;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshState;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshStateBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshEntries;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshEntriesBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.entries.NshEntry;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMaps;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMapsBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMap;
35 import org.openvpp.jvpp.nsh.future.FutureJVppNsh;
36 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
38 public class VppNshReaderFactory implements ReaderFactory {
40 private final FutureJVppNsh jvppNsh;
41 private final NamingContext nshEntryContext;
42 private final NamingContext nshMapContext;
43 private final NamingContext interfaceContext;
46 public VppNshReaderFactory(final FutureJVppNsh jvppNsh,
47 @Named("nsh-entry-context") final NamingContext nshEntryContext,
48 @Named("nsh-map-context") final NamingContext nshMapContext,
49 @Named("interface-context") @Nonnull final NamingContext interfaceContext) {
50 this.jvppNsh = jvppNsh;
51 this.nshEntryContext = nshEntryContext;
52 this.nshMapContext = nshMapContext;
53 this.interfaceContext = interfaceContext;
56 public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
57 // ReaderFactory is intended for registering Readers into HC framework
58 // Readers provide ONLY operational (config "false") data straight from underlying device/layer
59 // they are triggered when RESTCONF GET on operational is invoked or when NETCONF get operation is executed
61 // VppNshState(Structural)
62 final InstanceIdentifier<VppNshState> vppNshStateId = InstanceIdentifier.create(VppNshState.class);
63 registry.addStructuralReader(vppNshStateId, VppNshStateBuilder.class);
65 // NshENtries(Structural)
66 final InstanceIdentifier<NshEntries> nshEntriesId = vppNshStateId.child(NshEntries.class);
67 registry.addStructuralReader(nshEntriesId, NshEntriesBuilder.class);
69 final InstanceIdentifier<NshEntry> nshEntryId = nshEntriesId.child(NshEntry.class);
70 registry.add(new GenericListReader<>(nshEntryId, new NshEntryReaderCustomizer(jvppNsh, nshEntryContext)));
72 // NshMaps(Structural)
73 final InstanceIdentifier<NshMaps> nshMapsId = vppNshStateId.child(NshMaps.class);
74 registry.addStructuralReader(nshMapsId, NshMapsBuilder.class);
76 final InstanceIdentifier<NshMap> nshMapId = nshMapsId.child(NshMap.class);
77 registry.add(new GenericListReader<>(nshMapId, new NshMapReaderCustomizer(jvppNsh, nshMapContext, interfaceContext)));