use of org.opendaylight.netconf.sal.connect.api.NetconfDeviceSchemas in project netconf by opendaylight.
the class DeviceSourcesResolver method call.
@Override
public DeviceSources call() {
final NetconfDeviceSchemas availableSchemas = stateSchemasResolver.resolve(deviceRpc, remoteSessionCapabilities, id, baseSchema.getEffectiveModelContext());
LOG.debug("{}: Schemas exposed by ietf-netconf-monitoring: {}", id, availableSchemas.getAvailableYangSchemasQNames());
final Set<QName> requiredSources = Sets.newHashSet(remoteSessionCapabilities.getModuleBasedCaps());
final Set<QName> providedSources = availableSchemas.getAvailableYangSchemasQNames();
final Set<QName> requiredSourcesNotProvided = Sets.difference(requiredSources, providedSources);
if (!requiredSourcesNotProvided.isEmpty()) {
LOG.warn("{}: Netconf device does not provide all yang models reported in hello message capabilities," + " required but not provided: {}", id, requiredSourcesNotProvided);
LOG.warn("{}: Attempting to build schema context from required sources", id);
}
// Here all the sources reported in netconf monitoring are merged with those reported in hello.
// It is necessary to perform this since submodules are not mentioned in hello but still required.
// This clashes with the option of a user to specify supported yang models manually in configuration
// for netconf-connector and as a result one is not able to fully override yang models of a device.
// It is only possible to add additional models.
final Set<QName> providedSourcesNotRequired = Sets.difference(providedSources, requiredSources);
if (!providedSourcesNotRequired.isEmpty()) {
LOG.warn("{}: Netconf device provides additional yang models not reported in " + "hello message capabilities: {}", id, providedSourcesNotRequired);
LOG.warn("{}: Adding provided but not required sources as required to prevent failures", id);
LOG.debug("{}: Netconf device reported in hello: {}", id, requiredSources);
requiredSources.addAll(providedSourcesNotRequired);
}
final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
if (availableSchemas instanceof LibraryModulesSchemas) {
sourceProvider = new YangLibrarySchemaYangSourceProvider(id, ((LibraryModulesSchemas) availableSchemas).getAvailableModels());
} else {
sourceProvider = new NetconfRemoteSchemaYangSourceProvider(id, deviceRpc);
}
return new DeviceSources(requiredSources, providedSources, sourceProvider);
}
Aggregations