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.sal.connect.netconf;
10 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas;
11 import org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemasResolver;
12 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
13 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
14 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.$YangModuleInfoImpl;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.common.Revision;
19 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
22 * Default implementation resolving schemas QNames from netconf-state or from modules-state.
24 public final class NetconfStateSchemasResolverImpl implements NetconfDeviceSchemasResolver {
25 private static final QName RFC8525_YANG_LIBRARY_CAPABILITY = $YangModuleInfoImpl.getInstance().getName();
26 private static final QName RFC7895_YANG_LIBRARY_CAPABILITY = RFC8525_YANG_LIBRARY_CAPABILITY
27 .bindTo(QNameModule.create(RFC8525_YANG_LIBRARY_CAPABILITY.getNamespace(), Revision.of("2016-06-21"))).intern();
30 public NetconfDeviceSchemas resolve(final NetconfDeviceRpc deviceRpc,
31 final NetconfSessionPreferences remoteSessionCapabilities,
32 final RemoteDeviceId id, final EffectiveModelContext schemaContext) {
33 // FIXME: I think we should prefer YANG library here
34 if (remoteSessionCapabilities.isMonitoringSupported()) {
35 return NetconfStateSchemas.create(deviceRpc, remoteSessionCapabilities, id, schemaContext);
37 if (remoteSessionCapabilities.containsModuleCapability(RFC8525_YANG_LIBRARY_CAPABILITY)
38 || remoteSessionCapabilities.containsModuleCapability(RFC7895_YANG_LIBRARY_CAPABILITY)) {
39 return LibraryModulesSchemas.create(deviceRpc, id);
42 return NetconfStateSchemas.EMPTY;