use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder in project netconf by opendaylight.
the class MonitoringToMdsalWriterTest method testOnSchemasChanged.
@Test
public void testOnSchemasChanged() throws Exception {
final InstanceIdentifier<Schemas> schemasId = InstanceIdentifier.create(NetconfState.class).child(Schemas.class);
writer.start();
final Schemas schemas = new SchemasBuilder().build();
writer.onSchemasChanged(schemas);
InOrder inOrder = inOrder(writeTransaction);
inOrder.verify(writeTransaction).put(LogicalDatastoreType.OPERATIONAL, schemasId, schemas);
inOrder.verify(writeTransaction).commit();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder in project lighty-netconf-simulator by PANTHEONtech.
the class NetconfDeviceImpl method prepareSchemasForNetconfMonitoring.
/**
* Method creates schemas from device's schema context and
* stores them in the netconf-state/schemas path in operational datastore.
* netconfDeviceServices represents device services from which
* the modules loaded in schema-context will be converted to schemas
* stored in netconf-state/schemas.
* @return transaction commit information in FluentFuture
*/
private FluentFuture<? extends CommitInfo> prepareSchemasForNetconfMonitoring() {
HashMap<SchemaKey, Schema> mapSchemas = new HashMap<>();
EffectiveModelContext modelContext = netconfDeviceServices.getAdapterContext().currentSerializer().getRuntimeContext().getEffectiveModelContext();
Queue<Collection<? extends ModuleLike>> queueModulesCollections = new LinkedList<>();
queueModulesCollections.add(modelContext.getModules());
while (!queueModulesCollections.isEmpty()) {
Collection<? extends ModuleLike> modules = queueModulesCollections.poll();
for (ModuleLike module : modules) {
Schema schema = createSchemaFromModule(module);
if (!mapSchemas.containsKey(schema.key())) {
mapSchemas.put(schema.key(), schema);
if (!module.getSubmodules().isEmpty()) {
queueModulesCollections.add(module.getSubmodules());
}
}
}
}
WriteTransaction writeTx = netconfDeviceServices.getDataBroker().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(NetconfState.class).child(Schemas.class).build(), new SchemasBuilder().setSchema(mapSchemas).build());
return writeTx.commit();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder in project netconf by opendaylight.
the class NetconfCapabilityMonitoringService method transformSchemas.
private static Schemas transformSchemas(final Set<Capability> caps) {
final Map<SchemaKey, Schema> schemas = Maps.newHashMapWithExpectedSize(caps.size());
for (final Capability cap : caps) {
if (isValidModuleCapability(cap)) {
final SchemaKey key = new SchemaKey(Yang.class, cap.getModuleName().get(), cap.getRevision().orElse(""));
schemas.put(key, new SchemaBuilder().withKey(key).setNamespace(new Uri(cap.getModuleNamespace().get())).setLocation(transformLocations(cap.getLocation())).build());
}
}
return new SchemasBuilder().setSchema(schemas).build();
}
Aggregations