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);
}
}
Aggregations