Search in sources :

Example 1 with TapiNepPair

use of org.onosproject.odtn.utils.tapi.TapiNepPair 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

ArrayList (java.util.ArrayList)1 Collections.disjoint (java.util.Collections.disjoint)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 TapiResolver (org.onosproject.odtn.TapiResolver)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 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)1 TapiGetConnectivityDetailsInputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler)1 TapiGetConnectivityDetailsOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler)1 TapiGetConnectivityListOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler)1 TapiNepPair (org.onosproject.odtn.utils.tapi.TapiNepPair)1 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)1 TapiObjectHandler (org.onosproject.odtn.utils.tapi.TapiObjectHandler)1 TapiSepHandler (org.onosproject.odtn.utils.tapi.TapiSepHandler)1