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.vppstate;
19 import io.fd.honeycomb.translate.impl.read.GenericListReader;
20 import io.fd.honeycomb.translate.impl.read.GenericReader;
21 import io.fd.honeycomb.translate.read.registry.ReaderRegistry;
22 import io.fd.honeycomb.translate.util.read.registry.CompositeReaderRegistryBuilder;
23 import io.fd.honeycomb.translate.v3po.util.NamingContext;
24 import javax.annotation.Nonnull;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomains;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.BridgeDomainsBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.Version;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainKey;
33 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
34 import org.openvpp.jvpp.core.future.FutureJVppCore;
36 final class VppStateTestUtils {
38 private static InstanceIdentifier<BridgeDomains> bridgeDomainsId;
40 public VppStateTestUtils() {
44 * Create root VppState reader with all its children wired.
46 static ReaderRegistry getVppStateReader(@Nonnull final FutureJVppCore jVpp,
47 @Nonnull final NamingContext bdContext) {
48 final CompositeReaderRegistryBuilder registry = new CompositeReaderRegistryBuilder();
50 // VppState(Structural)
51 final InstanceIdentifier<VppState> vppStateId = InstanceIdentifier.create(VppState.class);
52 registry.addStructuralReader(vppStateId, VppStateBuilder.class);
54 // Wrap with keepalive reader to detect connection issues
55 // TODO keepalive reader wrapper relies on VersionReaderCustomizer (to perform timeout on reads)
56 // Once readers+customizers are asynchronous, pull the timeout to keepalive executor so that keepalive wrapper
58 registry.add(new GenericReader<>(vppStateId.child(Version.class), new VersionCustomizer(jVpp)));
59 // BridgeDomains(Structural)
60 bridgeDomainsId = vppStateId.child(BridgeDomains.class);
61 registry.addStructuralReader(bridgeDomainsId, BridgeDomainsBuilder.class);
63 registry.add(getBridgeDomainReader(jVpp, bdContext));
64 return registry.build();
67 static GenericListReader<BridgeDomain, BridgeDomainKey, BridgeDomainBuilder> getBridgeDomainReader(
68 final @Nonnull FutureJVppCore jVpp, final @Nonnull NamingContext bdContext) {
69 final InstanceIdentifier<BridgeDomain> bridgeDomainId = bridgeDomainsId.child(BridgeDomain.class);
70 return new GenericListReader<>(bridgeDomainId, new BridgeDomainCustomizer(jVpp, bdContext));