import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
import org.opendaylight.netconf.client.mdsal.DatastoreBackedPublicKeyAuth;
import org.opendaylight.netconf.client.mdsal.LibraryModulesSchemas;
+import org.opendaylight.netconf.client.mdsal.LibrarySchemaSourceProvider;
import org.opendaylight.netconf.client.mdsal.NetconfDevice;
import org.opendaylight.netconf.client.mdsal.NetconfDeviceBuilder;
import org.opendaylight.netconf.client.mdsal.SchemalessNetconfDevice;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfKeystoreAdapter;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
import org.opendaylight.netconf.sal.connect.util.SslHandlerFactoryImpl;
import org.opendaylight.netconf.topology.singleton.api.RemoteDeviceConnector;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
libraryModulesSchemas.getAvailableModels().entrySet()) {
registeredYangLibSources
.add(schemaResourcesDTO.getSchemaRegistry().registerSchemaSource(
- new YangLibrarySchemaYangSourceProvider(remoteDeviceId,
+ new LibrarySchemaSourceProvider(remoteDeviceId,
libraryModulesSchemas.getAvailableModels()),
PotentialSchemaSource
.create(sourceIdentifierURLEntry.getKey(), YangTextSchemaSource.class,
import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
import org.opendaylight.netconf.client.mdsal.DatastoreBackedPublicKeyAuth;
import org.opendaylight.netconf.client.mdsal.LibraryModulesSchemas;
+import org.opendaylight.netconf.client.mdsal.LibrarySchemaSourceProvider;
import org.opendaylight.netconf.client.mdsal.NetconfDevice.SchemaResourcesDTO;
import org.opendaylight.netconf.client.mdsal.NetconfDeviceBuilder;
import org.opendaylight.netconf.client.mdsal.SchemalessNetconfDevice;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfKeystoreAdapter;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseNetconfSchemas;
import org.opendaylight.netconf.sal.connect.util.SslHandlerFactoryImpl;
import org.opendaylight.netconf.topology.api.NetconfTopology;
}
for (final Map.Entry<SourceIdentifier, URL> entry : schemas.getAvailableModels().entrySet()) {
- registrations.add(schemaRegistry.registerSchemaSource(new YangLibrarySchemaYangSourceProvider(
+ registrations.add(schemaRegistry.registerSchemaSource(new LibrarySchemaSourceProvider(
remoteDeviceId, schemas.getAvailableModels()),
PotentialSchemaSource.create(entry.getKey(), YangTextSchemaSource.class,
PotentialSchemaSource.Costs.REMOTE_IO.getValue())));
import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc;
-import org.opendaylight.netconf.sal.connect.netconf.schema.YangLibrarySchemaYangSourceProvider;
import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseSchema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
final var sourceProvider = availableSchemas instanceof LibraryModulesSchemas libraryModule
- ? new YangLibrarySchemaYangSourceProvider(id, libraryModule.getAvailableModels())
+ ? new LibrarySchemaSourceProvider(id, libraryModule.getAvailableModels())
: new MonitoringSchemaSourceProvider(id, deviceRpc);
return new DeviceSources(requiredSources, providedSources, sourceProvider);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.sal.connect.netconf.schema;
+package org.opendaylight.netconf.client.mdsal;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
-import org.opendaylight.netconf.client.mdsal.CachedYangTextSchemaSource;
import org.opendaylight.netconf.client.mdsal.api.RemoteDeviceId;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.slf4j.LoggerFactory;
/**
- * Provides YANG schema sources from yang library.
+ * Provides YANG schema sources from YANG library. The set of available sources is pre-determined when this provider
+ * is created, but each source is acquired on demand.
*/
-public final class YangLibrarySchemaYangSourceProvider implements SchemaSourceProvider<YangTextSchemaSource> {
- private static final Logger LOG = LoggerFactory.getLogger(YangLibrarySchemaYangSourceProvider.class);
+public final class LibrarySchemaSourceProvider implements SchemaSourceProvider<YangTextSchemaSource> {
+ private static final Logger LOG = LoggerFactory.getLogger(LibrarySchemaSourceProvider.class);
private final ImmutableMap<SourceIdentifier, URL> availableSources;
private final RemoteDeviceId id;
- public YangLibrarySchemaYangSourceProvider(final RemoteDeviceId id,
- final Map<SourceIdentifier, URL> availableSources) {
+ public LibrarySchemaSourceProvider(final RemoteDeviceId id, final Map<SourceIdentifier, URL> availableSources) {
this.id = requireNonNull(id);
this.availableSources = ImmutableMap.copyOf(availableSources);
}
"Unable to download remote schema for " + sourceIdentifier + " from " + url, e));
}
- final var yangSource = new CachedYangTextSchemaSource(id, sourceIdentifier,
- url.toString(), schemaContent);
+ final var yangSource = new CachedYangTextSchemaSource(id, sourceIdentifier, url.toString(), schemaContent);
LOG.debug("Source {} downloaded from a yang library's url {}", sourceIdentifier, url);
return Futures.immediateFuture(yangSource);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.netconf.sal.connect.netconf.schema;
+package org.opendaylight.netconf.client.mdsal;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-public class YangLibrarySchemaYangSourceProviderTest {
+public class LibrarySchemaYangSourceProviderTest {
private SourceIdentifier workingSid;
- private YangLibrarySchemaYangSourceProvider yangLibrarySchemaYangSourceProvider;
+ private LibrarySchemaSourceProvider yangLibrarySchemaYangSourceProvider;
@Before
public void setUp() throws Exception {
workingSid = new SourceIdentifier("abc");
- yangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(
+ yangLibrarySchemaYangSourceProvider = new LibrarySchemaSourceProvider(
new RemoteDeviceId("id", new InetSocketAddress("localhost", 22)),
Map.of(workingSid, getClass().getResource("/schemas/config-test-rpc.yang")));
}
@Test
public void testGetSourceFailure() throws InterruptedException, MalformedURLException {
final var sourceIdentifierURLMap = Map.of(workingSid, new URL("http://non-existing-entity.yang"));
- final var failingYangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(
+ final var failingYangLibrarySchemaYangSourceProvider = new LibrarySchemaSourceProvider(
new RemoteDeviceId("id", new InetSocketAddress("localhost", 22)), sourceIdentifierURLMap);
final var future = failingYangLibrarySchemaYangSourceProvider.getSource(workingSid);