Search in sources :

Example 1 with RpcOutput

use of org.onosproject.yang.model.RpcOutput in project onos by opennetworkinglab.

the class DcsBasedTapiConnectivityRpc method getConnectivityServiceDetails.

/**
 * Service interface of getConnectivityServiceDetails.
 *
 * @param inputVar input of service interface getConnectivityServiceDetails
 * @return output of service interface getConnectivityServiceDetails
 */
@Override
public RpcOutput getConnectivityServiceDetails(RpcInput inputVar) {
    try {
        TapiGetConnectivityDetailsInputHandler input = new TapiGetConnectivityDetailsInputHandler();
        input.setRpcInput(inputVar);
        log.info("input serviceId: {}", input.getId());
        TapiConnectivityServiceHandler handler = TapiConnectivityServiceHandler.create();
        handler.setId(input.getId());
        handler.read();
        TapiGetConnectivityDetailsOutputHandler output = TapiGetConnectivityDetailsOutputHandler.create().addService(handler.getModelObject());
        return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, output.getDataNode());
    } catch (Throwable e) {
        return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
    }
}
Also used : TapiGetConnectivityDetailsOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) TapiGetConnectivityDetailsInputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler)

Example 2 with RpcOutput

use of org.onosproject.yang.model.RpcOutput in project onos by opennetworkinglab.

the class DcsBasedTapiConnectivityRpc method getConnectivityServiceList.

/**
 * Service interface of getConnectivityServiceList.
 *
 * @param inputVar input of service interface getConnectivityServiceList
 * @return output of service interface getConnectivityServiceList
 */
@Override
public RpcOutput getConnectivityServiceList(RpcInput inputVar) {
    try {
        TapiGetConnectivityListOutputHandler output = TapiGetConnectivityListOutputHandler.create();
        log.info("get list called");
        TapiContextHandler handler = TapiContextHandler.create();
        handler.read();
        log.info("model : {}", handler.getModelObject());
        log.info("conserv : {}", handler.getConnectivityServices());
        handler.getConnectivityServices().stream().map(TapiObjectHandler::getModelObject).forEach(output::addService);
        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 : TapiGetConnectivityListOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler) TapiContextHandler(org.onosproject.odtn.utils.tapi.TapiContextHandler) RpcOutput(org.onosproject.yang.model.RpcOutput)

Example 3 with RpcOutput

use of org.onosproject.yang.model.RpcOutput 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 4 with RpcOutput

use of org.onosproject.yang.model.RpcOutput in project onos by opennetworkinglab.

the class DcsBasedTapiConnectivityRpc method deleteConnectivityService.

/**
 * Service interface of deleteConnectivityService.
 *
 * @param inputVar input of service interface deleteConnectivityService
 * @return output of service interface deleteConnectivityService
 */
@Override
public RpcOutput deleteConnectivityService(RpcInput inputVar) {
    try {
        TapiDeleteConnectivityInputHandler input = new TapiDeleteConnectivityInputHandler();
        input.setRpcInput(inputVar);
        log.info("deleteConnectivityService - serviceId: {}", input.getId());
        // Retrieve the Connectivity Service from the DCS, based on Id
        TapiConnectivityServiceHandler serviceHandler = TapiConnectivityServiceHandler.create();
        serviceHandler.setId(input.getId());
        DefaultConnectivityService service = serviceHandler.read();
        // For each top-most connection of the service handler, delete that connection
        // using a manager
        service.connection().stream().forEach(connection -> {
            TapiConnectionHandler connectionHandler = TapiConnectionHandler.create();
            connectionHandler.setId(Uuid.fromString(connection.connectionUuid().toString()));
            DcsBasedTapiConnectionManager manager = DcsBasedTapiConnectionManager.create();
            log.info("deleteConnectivityService - connectionId: {}", connectionHandler.getId());
            manager.deleteConnection(connectionHandler);
            manager.apply();
        });
        serviceHandler.remove();
        return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, null);
    } catch (Throwable e) {
        log.error("Error:", e);
        return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
    }
}
Also used : DefaultConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) TapiDeleteConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)

Example 5 with RpcOutput

use of org.onosproject.yang.model.RpcOutput 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)

Aggregations

RpcOutput (org.onosproject.yang.model.RpcOutput)7 RpcInput (org.onosproject.yang.model.RpcInput)4 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)3 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)2 DynamicConfigService (org.onosproject.config.DynamicConfigService)2 TapiResolver (org.onosproject.odtn.TapiResolver)2 TapiConnectionHandler (org.onosproject.odtn.utils.tapi.TapiConnectionHandler)2 TapiContextHandler (org.onosproject.odtn.utils.tapi.TapiContextHandler)2 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)2 TapiGetConnectivityDetailsInputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler)2 TapiGetConnectivityDetailsOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler)2 TapiGetConnectivityListOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler)2 Uuid (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid)2 DefaultConnectivityService (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService)2 ModelConverter (org.onosproject.yang.model.ModelConverter)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Collections.disjoint (java.util.Collections.disjoint)1