use of org.onosproject.yang.model.RpcInput in project onos by opennetworkinglab.
the class DcsBasedTapiCommonRpc method getServiceInterfacePointList.
/**
* Service interface of getServiceInterfacePointList.
*
* @param rpcInput input of service interface getServiceInterfacePointList
* @return rpcOutput output of service interface getServiceInterfacePointList
*/
@Override
public RpcOutput getServiceInterfacePointList(RpcInput rpcInput) {
try {
TapiGetSipListOutputHandler output = TapiGetSipListOutputHandler.create();
resolver.getNepRefs().stream().filter(nepRef -> nepRef.getSipId() != null).forEach(nepRef -> {
output.addSip(Uuid.fromString(nepRef.getSipId()));
});
return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, output.getDataNode());
} catch (Throwable e) {
log.error("Error:", e);
return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
}
}
use of org.onosproject.yang.model.RpcInput in project onos by opennetworkinglab.
the class DcsBasedTapiConnectivityRpc method createConnectivityService.
/**
* Service interface of createConnectivityService.
*
* @param inputVar input of service interface createConnectivityService
* @return output of service interface createConnectivityService
*/
@Override
public RpcOutput createConnectivityService(RpcInput inputVar) {
try {
TapiCreateConnectivityInputHandler input = new TapiCreateConnectivityInputHandler();
input.setRpcInput(inputVar);
log.info("input SIPs: {}", input.getSips());
// check SIP validation
if (!disjoint(getUsedSips(), input.getSips())) {
log.error("SIPS {} are already used, please use a different pair", input.getSips());
return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
}
log.debug("check SIP validation : OK");
List<TapiNepRef> nepRefs = input.getSips().stream().map(sipId -> resolver.getNepRef(sipId)).collect(Collectors.toList());
// setup connections
TapiNepPair neps = TapiNepPair.create(nepRefs.get(0), nepRefs.get(1));
// Allocate a connectivity Service
TapiConnectivityServiceHandler connectivityServiceHandler = TapiConnectivityServiceHandler.create();
// This connectivity service will be supported over a single end-to-end connection
// Allocate a manager for that connection
DcsBasedTapiConnectionManager connectionManager = DcsBasedTapiConnectionManager.create();
TapiConnectionHandler connectionHandler = connectionManager.createConnection(neps);
// Add the supporting connection uuid to the service
connectivityServiceHandler.addConnection(connectionHandler.getModelObject().uuid());
neps.stream().map(nepRef -> TapiSepHandler.create().setSip(nepRef.getSipId())).forEach(sepBuilder -> {
connectivityServiceHandler.addSep(sepBuilder.getModelObject());
});
// build
connectionManager.apply();
connectivityServiceHandler.add();
// output
TapiCreateConnectivityOutputHandler output = TapiCreateConnectivityOutputHandler.create().addService(connectivityServiceHandler.getModelObject());
return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, output.getDataNode());
} catch (Throwable e) {
log.error("Error:", e);
return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
}
}
use of org.onosproject.yang.model.RpcInput 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;
}
use of org.onosproject.yang.model.RpcInput in project onos by opennetworkinglab.
the class DynamicDeviceConfigServiceViewTest method testInvokeRpc.
@Test
public void testInvokeRpc() {
RpcInput input = new RpcInput(relIntf, null);
view.invokeRpc(input);
assertTrue(ResourceIds.isPrefix(rid, realId));
}
Aggregations