Search in sources :

Example 1 with RpcInput

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);
    }
}
Also used : DynamicConfigService(org.onosproject.config.DynamicConfigService) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) RpcInput(org.onosproject.yang.model.RpcInput) Logger(org.slf4j.Logger) TapiResolver(org.onosproject.odtn.TapiResolver) ModelConverter(org.onosproject.yang.model.ModelConverter) LoggerFactory(org.slf4j.LoggerFactory) TapiCommonService(org.onosproject.yang.gen.v1.tapicommon.rev20181210.TapiCommonService) TapiGetSipListOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetSipListOutputHandler) RpcOutput(org.onosproject.yang.model.RpcOutput) Uuid(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiGetSipListOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetSipListOutputHandler)

Example 2 with RpcInput

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);
    }
}
Also used : TapiConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.TapiConnectivityService) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) LoggerFactory(org.slf4j.LoggerFactory) Collections.disjoint(java.util.Collections.disjoint) TapiCreateConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler) ArrayList(java.util.ArrayList) TapiDeleteConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler) TapiSepHandler(org.onosproject.odtn.utils.tapi.TapiSepHandler) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) DynamicConfigService(org.onosproject.config.DynamicConfigService) TapiNepPair(org.onosproject.odtn.utils.tapi.TapiNepPair) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) RpcInput(org.onosproject.yang.model.RpcInput) Logger(org.slf4j.Logger) TapiCreateConnectivityOutputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler) TapiResolver(org.onosproject.odtn.TapiResolver) ModelConverter(org.onosproject.yang.model.ModelConverter) TapiObjectHandler(org.onosproject.odtn.utils.tapi.TapiObjectHandler) DefaultConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiGetConnectivityListOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler) Uuid(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid) TapiGetConnectivityDetailsOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler) TapiGetConnectivityDetailsInputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler) List(java.util.List) TapiContextHandler(org.onosproject.odtn.utils.tapi.TapiContextHandler) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) TapiNepPair(org.onosproject.odtn.utils.tapi.TapiNepPair) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiCreateConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) TapiCreateConnectivityOutputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler)

Example 3 with RpcInput

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;
}
Also used : ResourceData(org.onosproject.yang.model.ResourceData) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) RestconfRpcOutput(org.onosproject.restconf.api.RestconfRpcOutput) ResourceId(org.onosproject.yang.model.ResourceId) DataNode(org.onosproject.yang.model.DataNode) RestconfUtils.convertJsonToDataNode(org.onosproject.restconf.utils.RestconfUtils.convertJsonToDataNode) RpcInput(org.onosproject.yang.model.RpcInput) RestconfRpcOutput(org.onosproject.restconf.api.RestconfRpcOutput) RpcOutput(org.onosproject.yang.model.RpcOutput) RestconfError(org.onosproject.restconf.api.RestconfError) FailedException(org.onosproject.config.FailedException) RestconfException(org.onosproject.restconf.api.RestconfException)

Example 4 with RpcInput

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));
}
Also used : RpcInput(org.onosproject.yang.model.RpcInput) Test(org.junit.Test)

Aggregations

RpcInput (org.onosproject.yang.model.RpcInput)4 RpcOutput (org.onosproject.yang.model.RpcOutput)3 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)2 DynamicConfigService (org.onosproject.config.DynamicConfigService)2 TapiResolver (org.onosproject.odtn.TapiResolver)2 Uuid (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid)2 ModelConverter (org.onosproject.yang.model.ModelConverter)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ArrayList (java.util.ArrayList)1 Collections.disjoint (java.util.Collections.disjoint)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 FailedException (org.onosproject.config.FailedException)1 TapiConnectionHandler (org.onosproject.odtn.utils.tapi.TapiConnectionHandler)1 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)1 TapiContextHandler (org.onosproject.odtn.utils.tapi.TapiContextHandler)1 TapiCreateConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler)1 TapiCreateConnectivityOutputHandler (org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler)1