use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class RestconfManager method executeRpc.
private RestconfRpcOutput executeRpc(URI uri, ObjectNode input, String clientIpAddress) {
ResourceData rpcInputNode = convertJsonToDataNode(uri, input);
ResourceId resourceId = rpcInputNode.resourceId();
List<DataNode> inputDataNodeList = rpcInputNode.dataNodes();
DataNode inputDataNode = inputDataNodeList.get(0);
RpcInput rpcInput = new RpcInput(resourceId, inputDataNode);
RestconfRpcOutput restconfOutput = null;
try {
CompletableFuture<RpcOutput> rpcFuture = dynamicConfigService.invokeRpc(rpcInput);
RpcOutput rpcOutput = rpcFuture.get();
restconfOutput = RestconfUtils.convertRpcOutput(resourceId, rpcOutput);
} catch (InterruptedException e) {
log.error("ERROR: computeResultQ.take() has been interrupted.");
log.debug("executeRpc Exception:", e);
RestconfError error = RestconfError.builder(RestconfError.ErrorType.RPC, RestconfError.ErrorTag.OPERATION_FAILED).errorMessage("RPC execution has been interrupted").errorPath(uri.getPath()).build();
restconfOutput = new RestconfRpcOutput(INTERNAL_SERVER_ERROR, RestconfError.wrapErrorAsJson(Arrays.asList(error)));
restconfOutput.reason("RPC execution has been interrupted");
} catch (Exception e) {
log.error("ERROR: executeRpc: {}", e.getMessage());
log.debug("executeRpc Exception:", e);
RestconfError error = RestconfError.builder(RestconfError.ErrorType.RPC, RestconfError.ErrorTag.OPERATION_FAILED).errorMessage(e.getMessage()).errorPath(uri.getPath()).build();
restconfOutput = new RestconfRpcOutput(INTERNAL_SERVER_ERROR, RestconfError.wrapErrorAsJson(Arrays.asList(error)));
restconfOutput.reason(e.getMessage());
}
return restconfOutput;
}
Aggregations