Search in sources :

Example 91 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project bgpcep by opendaylight.

the class SimpleEROSubobjectRegistryTest method testSerializerRegistration.

@Test
public void testSerializerRegistration() {
    assertNotNull(this.simpleEROSubobjectRegistry.registerSubobjectSerializer(LabelCase.class, this.rroSubobjectSerializer));
    final SubobjectContainer container = new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().build()).build();
    final ByteBuf output = Unpooled.buffer();
    this.simpleEROSubobjectRegistry.serializeSubobject(container, output);
    assertEquals(1, output.readableBytes());
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer) LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 92 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netconf by opendaylight.

the class NetconfMessageTransformUtil method createEditConfigAnyxml.

/**
 * Create edit-config structure to invoke {@code operation} with {@code lastChildOverride} data on {@code dataPath}.
 *
 * @param ctx {@link EffectiveModelContext} device's model context
 * @param dataPath {@link YangInstanceIdentifier} path to data in device's data-store
 * @param operation Optional of {@link ModifyAction} action to be invoked
 * @param lastChildOverride Optional of {@code NormalizedNode} data on which action will be invoked
 * @return {@link DOMSourceAnyxmlNode} containing edit-config structure
 */
public static DOMSourceAnyxmlNode createEditConfigAnyxml(final EffectiveModelContext ctx, final YangInstanceIdentifier dataPath, final Optional<ModifyAction> operation, final Optional<NormalizedNode> lastChildOverride) {
    if (dataPath.isEmpty()) {
        Preconditions.checkArgument(lastChildOverride.isPresent(), "Data has to be present when creating structure for top level element");
        Preconditions.checkArgument(lastChildOverride.get() instanceof DataContainerChild, "Data has to be either container or a list node when creating structure for top level element, " + "but was: %s", lastChildOverride.get());
    }
    final var element = XmlUtil.createElement(BLANK_DOCUMENT, NETCONF_CONFIG_QNAME.getLocalName(), Optional.of(NETCONF_CONFIG_QNAME.getNamespace().toString()));
    final var metadata = operation.map(o -> leafMetadata(dataPath, o)).orElse(null);
    try {
        if (lastChildOverride.isPresent()) {
            // FIXME remove ImmutableNodes.fromInstanceId usage
            final var configContent = ImmutableNodes.fromInstanceId(ctx, dataPath, lastChildOverride.get());
            NetconfUtil.writeNormalizedNode(configContent, metadata, new DOMResult(element), SchemaPath.ROOT, ctx);
        } else {
            NetconfUtil.writeNormalizedNode(dataPath, metadata, new DOMResult(element), SchemaPath.ROOT, ctx);
        }
    } catch (final IOException | XMLStreamException e) {
        throw new IllegalStateException("Unable to serialize edit config content element for path " + dataPath, e);
    }
    return Builders.anyXmlBuilder().withNodeIdentifier(NETCONF_CONFIG_NODEID).withValue(new DOMSource(element)).build();
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) LoggerFactory(org.slf4j.LoggerFactory) NetconfUtil(org.opendaylight.netconf.util.NetconfUtil) XMLNamespace(org.opendaylight.yangtools.yang.common.XMLNamespace) ErrorSeverity(org.opendaylight.yangtools.yang.common.ErrorSeverity) XmlElement(org.opendaylight.netconf.api.xml.XmlElement) MessageCounter(org.opendaylight.netconf.sal.connect.util.MessageCounter) Absolute(org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NETCONF_QNAME(org.opendaylight.netconf.util.NetconfUtil.NETCONF_QNAME) NetconfState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState) Locale(java.util.Locale) Document(org.w3c.dom.Document) Map(java.util.Map) XMLStreamException(javax.xml.stream.XMLStreamException) FailedNetconfMessage(org.opendaylight.netconf.api.FailedNetconfMessage) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) URI(java.net.URI) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) XmlUtil(org.opendaylight.netconf.api.xml.XmlUtil) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) Instant(java.time.Instant) XMLStreamNormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.codec.xml.XMLStreamNormalizedNodeStreamWriter) DateTimeParseException(java.time.format.DateTimeParseException) List(java.util.List) Builder(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) CreateSubscriptionInput(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) SchemaOrderedNormalizedNodeWriter(org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter) YangConstants(org.opendaylight.yangtools.yang.common.YangConstants) Entry(java.util.Map.Entry) Optional(java.util.Optional) NormalizedMetadata(org.opendaylight.yangtools.rfc7952.data.api.NormalizedMetadata) NonNull(org.eclipse.jdt.annotation.NonNull) DOMSource(javax.xml.transform.dom.DOMSource) SchemaPath(org.opendaylight.yangtools.yang.model.api.SchemaPath) NETCONF_DATA_QNAME(org.opendaylight.netconf.util.NetconfUtil.NETCONF_DATA_QNAME) NetconfDocumentedException(org.opendaylight.netconf.api.NetconfDocumentedException) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ImmutableNormalizedMetadata(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata) Deque(java.util.Deque) DataSchemaContextNode(org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode) ModifyAction(org.opendaylight.netconf.api.ModifyAction) ErrorType(org.opendaylight.yangtools.yang.common.ErrorType) ImmutableList(com.google.common.collect.ImmutableList) DocumentedException(org.opendaylight.netconf.api.DocumentedException) SimpleEntry(java.util.AbstractMap.SimpleEntry) Builders(org.opendaylight.yangtools.yang.data.impl.schema.Builders) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ErrorTag(org.opendaylight.yangtools.yang.common.ErrorTag) AnyxmlNode(org.opendaylight.yangtools.yang.data.api.schema.AnyxmlNode) IOException(java.io.IOException) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) DataSchemaContextTree(org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) QName(org.opendaylight.yangtools.yang.common.QName) DOMSourceAnyxmlNode(org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode) Element(org.w3c.dom.Element) EditContent(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) NetconfCapabilityChange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange) NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Preconditions(com.google.common.base.Preconditions) ArrayDeque(java.util.ArrayDeque) DOMResult(javax.xml.transform.dom.DOMResult) NetconfMessageUtil(org.opendaylight.netconf.util.messages.NetconfMessageUtil) RpcError(org.opendaylight.yangtools.yang.common.RpcError) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) DOMSource(javax.xml.transform.dom.DOMSource) DOMResult(javax.xml.transform.dom.DOMResult) XMLStreamException(javax.xml.stream.XMLStreamException) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) IOException(java.io.IOException)

Example 93 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netconf by opendaylight.

the class NetconfDeviceTopologyAdapter method createNetworkTopologyIfNotPresent.

private void createNetworkTopologyIfNotPresent(final WriteTransaction writeTx) {
    final NetworkTopology networkTopology = new NetworkTopologyBuilder().build();
    LOG.trace("{}: Transaction {} merging {} container to ensure its presence", id, writeTx.getIdentifier(), NetworkTopology.QNAME);
    writeTx.merge(LogicalDatastoreType.OPERATIONAL, networkTopologyPath, networkTopology);
    final Topology topology = new TopologyBuilder().setTopologyId(new TopologyId(TopologyNetconf.QNAME.getLocalName())).build();
    LOG.trace("{}: Transaction {} merging {} container to ensure its presence", id, writeTx.getIdentifier(), Topology.QNAME);
    writeTx.merge(LogicalDatastoreType.OPERATIONAL, topologyListPath, topology);
}
Also used : TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) NetworkTopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NetworkTopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Example 94 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netconf by opendaylight.

the class RestconfImpl method invokeSalRemoteRpcSubscribeRPC.

private ListenableFuture<DOMRpcResult> invokeSalRemoteRpcSubscribeRPC(final NormalizedNodeContext payload) {
    final ContainerNode value = (ContainerNode) payload.getData();
    final QName rpcQName = payload.getInstanceIdentifierContext().getSchemaNode().getQName();
    final Optional<DataContainerChild> path = value.findChildByArg(new NodeIdentifier(QName.create(rpcQName, "path")));
    final Object pathValue = path.isPresent() ? path.get().body() : null;
    if (!(pathValue instanceof YangInstanceIdentifier)) {
        LOG.debug("Instance identifier {} was not normalized correctly", rpcQName);
        throw new RestconfDocumentedException("Instance identifier was not normalized correctly", ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
    }
    final YangInstanceIdentifier pathIdentifier = (YangInstanceIdentifier) pathValue;
    String streamName = (String) CREATE_DATA_SUBSCR;
    NotificationOutputType outputType = null;
    if (!pathIdentifier.isEmpty()) {
        final String fullRestconfIdentifier = DATA_SUBSCR + controllerContext.toFullRestconfIdentifier(pathIdentifier, null);
        LogicalDatastoreType datastore = parseEnumTypeParameter(value, LogicalDatastoreType.class, DATASTORE_PARAM_NAME);
        datastore = datastore == null ? DEFAULT_DATASTORE : datastore;
        Scope scope = parseEnumTypeParameter(value, Scope.class, SCOPE_PARAM_NAME);
        scope = scope == null ? Scope.BASE : scope;
        outputType = parseEnumTypeParameter(value, NotificationOutputType.class, OUTPUT_TYPE_PARAM_NAME);
        outputType = outputType == null ? NotificationOutputType.XML : outputType;
        streamName = Notificator.createStreamNameFromUri(fullRestconfIdentifier + "/datastore=" + datastore + "/scope=" + scope);
    }
    if (Strings.isNullOrEmpty(streamName)) {
        LOG.debug("Path is empty or contains value node which is not Container or List built-in type at {}", pathIdentifier);
        throw new RestconfDocumentedException("Path is empty or contains value node which is not Container or List " + "built-in type.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
    }
    final QName outputQname = QName.create(rpcQName, "output");
    final QName streamNameQname = QName.create(rpcQName, "stream-name");
    final ContainerNode output = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(outputQname)).withChild(ImmutableNodes.leafNode(streamNameQname, streamName)).build();
    if (!Notificator.existListenerFor(streamName)) {
        Notificator.createListener(pathIdentifier, streamName, outputType, controllerContext);
    }
    return Futures.immediateFuture(new DefaultDOMRpcResult(output));
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) RestconfDocumentedException(org.opendaylight.restconf.common.errors.RestconfDocumentedException) QName(org.opendaylight.yangtools.yang.common.QName) NotificationOutputType(org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Scope(org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType)

Example 95 with Container

use of org.opendaylight.yang.gen.v1.urn.test.opendaylight.mdsal298.rev180129.Container in project netconf by opendaylight.

the class CreateStreamUtil method prepareDataChangeNotifiStreamName.

/**
 * Prepare stream name.
 *
 * @param path          Path of element from which data-change-event notifications are going to be generated.
 * @param schemaContext Schema context.
 * @param data          Container with stream settings (RPC create-stream).
 * @return Parsed stream name.
 */
private static String prepareDataChangeNotifiStreamName(final YangInstanceIdentifier path, final EffectiveModelContext schemaContext, final ContainerNode data) {
    final String datastoreName = extractStringLeaf(data, DATASTORE_NODEID);
    final LogicalDatastoreType datastoreType = datastoreName != null ? LogicalDatastoreType.valueOf(datastoreName) : LogicalDatastoreType.CONFIGURATION;
    final String scopeName = extractStringLeaf(data, SCOPE_NODEID);
    // FIXME: this is not really used
    final Scope scope = scopeName != null ? Scope.forName(scopeName).orElseThrow() : Scope.BASE;
    return RestconfStreamsConstants.DATA_SUBSCRIPTION + "/" + ListenersBroker.createStreamNameFromUri(IdentifierCodec.serialize(path, schemaContext) + "/" + RestconfStreamsConstants.DATASTORE_PARAM_NAME + "=" + datastoreType + "/" + RestconfStreamsConstants.SCOPE_PARAM_NAME + "=" + scope);
}
Also used : Scope(org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.CreateDataChangeEventSubscriptionInput1.Scope) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)45 Test (org.junit.Test)16 HashMap (java.util.HashMap)10 Container (net.minecraft.server.v1_12_R1.Container)9 Container (net.minecraft.server.v1_16_R3.Container)9 Container (org.flyte.api.v1.Container)9 FailedNbt (com.ruinscraft.panilla.api.exception.FailedNbt)8 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)8 Container (net.minecraft.server.v1_11_R1.Container)8 Container (net.minecraft.server.v1_14_R1.Container)8 Container (net.minecraft.server.v1_15_R1.Container)8 Container (net.minecraft.server.v1_16_R1.Container)8 Container (net.minecraft.server.v1_16_R2.Container)8 Container (net.minecraft.server.v1_8_R3.Container)8 ByteBuf (io.netty.buffer.ByteBuf)7 ArrayList (java.util.ArrayList)7 Container (net.minecraft.server.v1_13_R1.Container)7 Container (net.minecraft.server.v1_13_R2.Container)6 Container (net.minecraft.server.v1_10_R1.Container)5 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)5