use of org.opendaylight.yangtools.yang.model.api.ModuleLike 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();
}
Aggregations