2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.client.mdsal;
10 import com.google.common.util.concurrent.Futures;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.netconf.client.mdsal.api.NetconfDeviceSchemas;
13 import org.opendaylight.netconf.client.mdsal.api.NetconfDeviceSchemasResolver;
14 import org.opendaylight.netconf.client.mdsal.api.NetconfRpcService;
15 import org.opendaylight.netconf.client.mdsal.api.NetconfSessionPreferences;
16 import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
17 import org.opendaylight.yang.svc.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangModuleInfoImpl;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.common.QNameModule;
20 import org.opendaylight.yangtools.yang.common.Revision;
21 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
24 * Default implementation resolving schemas QNames from netconf-state or from modules-state.
26 public final class NetconfStateSchemasResolverImpl implements NetconfDeviceSchemasResolver {
27 private static final QName RFC8525_YANG_LIBRARY_CAPABILITY = YangModuleInfoImpl.getInstance().getName();
28 private static final QName RFC7895_YANG_LIBRARY_CAPABILITY = RFC8525_YANG_LIBRARY_CAPABILITY
29 .bindTo(QNameModule.create(RFC8525_YANG_LIBRARY_CAPABILITY.getNamespace(), Revision.of("2016-06-21"))).intern();
32 public ListenableFuture<? extends NetconfDeviceSchemas> resolve(final NetconfRpcService deviceRpc,
33 final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id,
34 final EffectiveModelContext schemaContext) {
35 // FIXME: I think we should prefer YANG library here
36 if (remoteSessionCapabilities.isMonitoringSupported()) {
37 return NetconfStateSchemas.forDevice(deviceRpc, remoteSessionCapabilities, id, schemaContext);
39 if (remoteSessionCapabilities.containsModuleCapability(RFC8525_YANG_LIBRARY_CAPABILITY)
40 || remoteSessionCapabilities.containsModuleCapability(RFC7895_YANG_LIBRARY_CAPABILITY)) {
41 return LibraryModulesSchemas.forDevice(deviceRpc, id);
44 return Futures.immediateFuture(NetconfStateSchemas.EMPTY);