use of org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry in project netconf by opendaylight.
the class NetconfDeviceTest method getSchemaRegistry.
private static SchemaSourceRegistry getSchemaRegistry() {
final SchemaSourceRegistry mock = mock(SchemaSourceRegistry.class);
final SchemaSourceRegistration<?> mockReg = mock(SchemaSourceRegistration.class);
doNothing().when(mockReg).close();
doReturn(mockReg).when(mock).registerSchemaSource(any(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider.class), any(PotentialSchemaSource.class));
return mock;
}
use of org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry in project netconf by opendaylight.
the class AbstractNetconfTopology method registerDeviceSchemaSources.
private List<SchemaSourceRegistration<?>> registerDeviceSchemaSources(final RemoteDeviceId remoteDeviceId, final NetconfNode node, final SchemaResourcesDTO resources) {
final YangLibrary yangLibrary = node.getYangLibrary();
if (yangLibrary != null) {
final Uri uri = yangLibrary.getYangLibraryUrl();
if (uri != null) {
final List<SchemaSourceRegistration<?>> registrations = new ArrayList<>();
final String yangLibURL = uri.getValue();
final SchemaSourceRegistry schemaRegistry = resources.getSchemaRegistry();
// pre register yang library sources as fallback schemas to schema registry
final LibraryModulesSchemas schemas;
final String yangLibUsername = yangLibrary.getUsername();
final String yangLigPassword = yangLibrary.getPassword();
if (yangLibUsername != null && yangLigPassword != null) {
schemas = LibraryModulesSchemas.create(yangLibURL, yangLibUsername, yangLigPassword);
} else {
schemas = LibraryModulesSchemas.create(yangLibURL);
}
for (final Map.Entry<SourceIdentifier, URL> entry : schemas.getAvailableModels().entrySet()) {
registrations.add(schemaRegistry.registerSchemaSource(new YangLibrarySchemaYangSourceProvider(remoteDeviceId, schemas.getAvailableModels()), PotentialSchemaSource.create(entry.getKey(), YangTextSchemaSource.class, PotentialSchemaSource.Costs.REMOTE_IO.getValue())));
}
return List.copyOf(registrations);
}
}
return List.of();
}
Aggregations