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