@Override public void onSuccess(final DOMRpcResult result) { if (result != null && result.getResult() != null) { LOG.debug("{}: Keepalive RPC successful with response: {}", id, result.getResult()); scheduleKeepalive(); } else { LOG.warn("{} Keepalive RPC returned null with response: {}. Reconnecting netconf session", id, result); reconnect(); } }
@Override public NormalizedNode<?, ?> getResult() { return delegate().getResult(); } }
@Override public NormalizedNode<?, ?> getResult() { return delegate().getResult(); } }
@Override protected DOMRpcResult transform(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult fromResult) { return new DefaultDOMRpcResult(fromResult.getResult(), fromResult.getErrors()); } }
private DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> findDataNode(final DOMRpcResult result) { return ((ContainerNode) result.getResult()).getChild(NetconfMessageTransformUtil.toId(NetconfMessageTransformUtil.NETCONF_DATA_QNAME)).get(); }
@Override public YangTextSchemaSource apply(final DOMRpcResult input) { if (input.getErrors().isEmpty()) { final Optional<String> schemaString = getSchemaFromRpc(id, input.getResult()); Preconditions.checkState(schemaString.isPresent(), "%s: Unexpected response to get-schema, schema not present in message for: %s", id, sourceIdentifier); logger.debug("{}: YANG Schema successfully retrieved for {}:{}", id, moduleName, revision); return new NetconfYangTextSchemaSource(id, sourceIdentifier, schemaString); } logger.warn("{}: YANG schema was not successfully retrieved for {}. Errors: {}", id, sourceIdentifier, input.getErrors()); throw new IllegalStateException(String.format( "%s: YANG schema was not successfully retrieved for %s. Errors: %s", id, sourceIdentifier, input.getErrors())); }
@Override public RpcResult<?> apply(final DOMRpcResult input) { final NormalizedNode<?, ?> domData = input.getResult(); final DataObject bindingResult; if (domData != null) { final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output")); bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData); } else { bindingResult = null; } return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build()); } });
final Optional<? extends NormalizedNode<?, ?>> schemasNode = findSchemasNode(schemasNodeResult.getResult());
@Override public void onSuccess(final DOMRpcResult result) { if (result.getErrors() != null && (!result.getErrors().isEmpty())) { final String message = String.format("Execution of RPC %s failed", msg.getRpc()); Collection<RpcError> errors = result.getErrors(); if (errors == null || errors.size() == 0) { errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message)); } sender.tell(new akka.actor.Status.Failure(new RpcErrorsException(message, errors)), self); } else { final Node serializedResultNode; if (result.getResult() == null) { serializedResultNode = null; } else { serializedResultNode = NormalizedNodeSerializer.serialize(result.getResult()); } LOG.debug("Sending response for execute rpc : {}", msg.getRpc()); sender.tell(new RpcResponse(serializedResultNode), self); } }
try { final DOMRpcResult result = rpcFuture.checkedGet(); if (result.getResult() == null) { return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)); return (Element) transformNormalizedNode(document, result.getResult(), rpcDefinition.getOutput().getPath()); } catch (DOMRpcException e) { throw DocumentedException.wrap(e);
try { final DOMRpcResult result = rpcFuture.checkedGet(); if (result.getResult() == null) { return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0)); return (Element) transformNormalizedNode(document, result.getResult(), rpcDefinition.getOutput().getPath()); } catch (DOMRpcException e) { throw NetconfDocumentedException.wrap(e);
result.getResult(), QueryParametersParser.parseWriterParameters(uriInfo));
@Override public NormalizedNodeContext invokeRpc(final String identifier, final NormalizedNodeContext payload, final UriInfo uriInfo) { Preconditions.checkArgument(payload.getInstanceIdentifierContext().getSchemaNode() != null); Preconditions.checkArgument(payload.getInstanceIdentifierContext().getSchemaNode() instanceof RpcDefinition); final SchemaPath type = payload.getInstanceIdentifierContext().getSchemaNode().getPath(); final URI namespace = payload.getInstanceIdentifierContext().getSchemaNode().getQName().getNamespace(); final CheckedFuture<DOMRpcResult, DOMRpcException> response; final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint(); final SchemaContext schemaContext; if (mountPoint != null) { final Optional<DOMRpcService> mountRpcServices = mountPoint.getService(DOMRpcService.class); if ( ! mountRpcServices.isPresent()) { LOG.debug("Error: Rpc service is missing."); throw new RestconfDocumentedException("Rpc service is missing."); } schemaContext = mountPoint.getSchemaContext(); response = mountRpcServices.get().invokeRpc(type, payload.getData()); } else { if (namespace.toString().equals(SAL_REMOTE_NAMESPACE)) { response = invokeSalRemoteRpcSubscribeRPC(payload); } else { response = broker.invokeRpc(type, payload.getData()); } schemaContext = controllerContext.getGlobalSchema(); } final DOMRpcResult result = checkRpcResponse(response); final RpcDefinition rpcSchemaNode = (RpcDefinition) payload.getInstanceIdentifierContext().getSchemaNode(); return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpcSchemaNode, mountPoint, schemaContext), result.getResult(), QueryParametersParser.parseWriterParameters(uriInfo)); }