RoutedDOMRpcRoutingTableEntry( final RpcDefinition def, final YangInstanceIdentifier keyId, final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls) { super(def.getPath(), impls); this.keyId = Preconditions.checkNotNull(keyId); this.globalRpcId = DOMRpcIdentifier.create(def.getPath()); }
public static Command create( final RpcDefinition rpcDefinition, final NetconfDeviceConnectionManager connectManager, final Integer connectionTimeout) { return new Connect( rpcDefinition.getQName(), getInputDefinition(rpcDefinition), getOutputDefinition(rpcDefinition), connectManager, rpcDefinition.getDescription(), connectionTimeout); }
@Override public synchronized DOMRpcResult toRpcResult(final NetconfMessage message, final SchemaPath rpc) { final NormalizedNode<?, ?> normalizedNode; final QName rpcQName = rpc.getLastComponent(); if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpcQName)) { final Element xmlData = NetconfMessageTransformUtil.getDataSubtree(message.getDocument()); final ContainerSchemaNode schemaForDataRead = NetconfMessageTransformUtil.createSchemaForDataRead(schemaContext); final ContainerNode dataNode; try { dataNode = parserFactory .getContainerNodeParser() .parse(Collections.singleton(xmlData), schemaForDataRead); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( String.format("Failed to parse data response %s", xmlData), e); } normalizedNode = Builders.containerBuilder() .withNodeIdentifier( new YangInstanceIdentifier.NodeIdentifier( NetconfMessageTransformUtil.NETCONF_RPC_REPLY_QNAME)) .withChild(dataNode) .build(); } else { Map<QName, RpcDefinition> currentMappedRpcs = mappedRpcs; // Determine whether a base netconf operation is being invoked and also check if the device // exposed model for base netconf // If no, use pre built base netconf operations model final boolean needToUseBaseCtx = mappedRpcs.get(rpcQName) == null && isBaseRpc(rpcQName); if (needToUseBaseCtx) { currentMappedRpcs = MAPPED_BASE_RPCS; } final RpcDefinition rpcDefinition = currentMappedRpcs.get(rpcQName); Preconditions.checkArgument( rpcDefinition != null, "Unable to parse response of %s, the rpc is unknown", rpcQName); // In case no input for rpc is defined, we can simply construct the payload here if (rpcDefinition.getOutput() == null) { Preconditions.checkArgument( XmlElement.fromDomDocument(message.getDocument()) .getOnlyChildElementWithSameNamespaceOptionally("ok") .isPresent(), "Unexpected content in response of rpc: %s, %s", rpcDefinition.getQName(), message); normalizedNode = null; } else { final Element element = message.getDocument().getDocumentElement(); try { normalizedNode = parserFactory .getContainerNodeParser() .parse(Collections.singleton(element), rpcDefinition.getOutput()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( String.format("Failed to parse RPC response %s", element), e); } } } return new DefaultDOMRpcResult(normalizedNode); }