use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project netconf by opendaylight.
the class BaseYangSwaggerGenerator method getApiDeclaration.
public CommonApiObject getApiDeclaration(final String module, final String revision, final UriInfo uriInfo, final URIType uriType, final OAversion oaversion) {
final EffectiveModelContext schemaContext = schemaService.getGlobalContext();
Preconditions.checkState(schemaContext != null);
final SwaggerObject doc = getApiDeclaration(module, revision, uriInfo, schemaContext, "", uriType, oaversion);
return getAppropriateDoc(doc, oaversion);
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project controller by opendaylight.
the class ShardManagerTest method testOnCreateShard.
@Test
public void testOnCreateShard() {
LOG.info("testOnCreateShard starting");
final TestKit kit = new TestKit(getSystem());
datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true);
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
EffectiveModelContext schemaContext = TEST_SCHEMA_CONTEXT;
shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
DatastoreContext datastoreContext = DatastoreContext.newBuilder().shardElectionTimeoutFactor(100).persistent(false).build();
Shard.Builder shardBuilder = Shard.builder();
ModuleShardConfiguration config = new ModuleShardConfiguration(XMLNamespace.of("foo-ns"), "foo-module", "foo", null, members("member-1", "member-5", "member-6"));
shardManager.tell(new CreateShard(config, shardBuilder, datastoreContext), kit.getRef());
kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
shardManager.tell(new FindLocalShard("foo", true), kit.getRef());
kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
assertFalse("isRecoveryApplicable", shardBuilder.getDatastoreContext().isPersistent());
assertTrue("Epxected ShardPeerAddressResolver", shardBuilder.getDatastoreContext().getShardRaftConfig().getPeerAddressResolver() instanceof ShardPeerAddressResolver);
assertEquals("peerMembers", Sets.newHashSet(ShardIdentifier.create("foo", MemberName.forName("member-5"), shardMrgIDSuffix).toString(), ShardIdentifier.create("foo", MemberName.forName("member-6"), shardMrgIDSuffix).toString()), shardBuilder.getPeerAddresses().keySet());
assertEquals("ShardIdentifier", ShardIdentifier.create("foo", MEMBER_1, shardMrgIDSuffix), shardBuilder.getId());
assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
// Send CreateShard with same name - should return Success with
// a message.
shardManager.tell(new CreateShard(config, shardBuilder, null), kit.getRef());
Success success = kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
assertNotNull("Success status is null", success.status());
LOG.info("testOnCreateShard ending");
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext in project controller by opendaylight.
the class ShardManagerTest method testOnCreateShardWithNoInitialSchemaContext.
@Test
public void testOnCreateShardWithNoInitialSchemaContext() {
LOG.info("testOnCreateShardWithNoInitialSchemaContext starting");
final TestKit kit = new TestKit(getSystem());
ActorRef shardManager = actorFactory.createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())).withDispatcher(Dispatchers.DefaultDispatcherId()));
Shard.Builder shardBuilder = Shard.builder();
ModuleShardConfiguration config = new ModuleShardConfiguration(XMLNamespace.of("foo-ns"), "foo-module", "foo", null, members("member-1"));
shardManager.tell(new CreateShard(config, shardBuilder, null), kit.getRef());
kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
EffectiveModelContext schemaContext = TEST_SCHEMA_CONTEXT;
shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
shardManager.tell(new FindLocalShard("foo", true), kit.getRef());
kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
assertNotNull("schemaContext is null", shardBuilder.getDatastoreContext());
LOG.info("testOnCreateShardWithNoInitialSchemaContext ending");
}
use of org.opendaylight.yangtools.yang.model.api.EffectiveModelContext 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.yangtools.yang.model.api.EffectiveModelContext in project lighty-netconf-simulator by PANTHEONtech.
the class EditConfigRequestProcessor method ensureParentsByMerge.
private void ensureParentsByMerge(final YangInstanceIdentifier path, final DOMDataTreeWriteTransaction writeTx) {
final EffectiveModelContext effectiveModelContext = getNetconfDeviceServices().getAdapterContext().currentSerializer().getRuntimeContext().getEffectiveModelContext();
final List<PathArgument> normalizedPathWithoutChildArgs = new ArrayList<>();
YangInstanceIdentifier rootNormalizedPath = null;
final Iterator<PathArgument> it = path.getPathArguments().iterator();
while (it.hasNext()) {
final PathArgument pathArgument = it.next();
if (rootNormalizedPath == null) {
rootNormalizedPath = YangInstanceIdentifier.create(pathArgument);
}
if (it.hasNext()) {
normalizedPathWithoutChildArgs.add(pathArgument);
}
}
if (normalizedPathWithoutChildArgs.isEmpty()) {
return;
}
Preconditions.checkArgument(rootNormalizedPath != null, "Empty path received");
final NormalizedNode parentStructure = ImmutableNodes.fromInstanceId(effectiveModelContext, YangInstanceIdentifier.create(normalizedPathWithoutChildArgs));
writeTx.merge(LogicalDatastoreType.CONFIGURATION, rootNormalizedPath, parentStructure);
}
Aggregations