Search in sources :

Example 1 with TapiDeleteConnectivityInputHandler

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

Aggregations

TapiConnectionHandler (org.onosproject.odtn.utils.tapi.TapiConnectionHandler)1 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)1 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)1 DefaultConnectivityService (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService)1 RpcOutput (org.onosproject.yang.model.RpcOutput)1