use of org.onosproject.odtn.utils.tapi.TapiConnectionHandler in project onos by opennetworkinglab.
the class OdtnTapiHandlersTestCommand method setupTapiContext.
private void setupTapiContext() {
DeviceId did1 = DeviceId.deviceId("netconf:127.0.0.1:11001");
DeviceId did2 = DeviceId.deviceId("netconf:127.0.0.1:11002");
ConnectPoint cp11 = new ConnectPoint(did1, PortNumber.portNumber(1, "TRANSCEIVER"));
ConnectPoint cp12 = new ConnectPoint(did1, PortNumber.portNumber(2, "TRANSCEIVER"));
ConnectPoint cp21 = new ConnectPoint(did2, PortNumber.portNumber(1, "TRANSCEIVER"));
ConnectPoint cp22 = new ConnectPoint(did2, PortNumber.portNumber(2, "TRANSCEIVER"));
// context
contextHandler = TapiContextHandler.create();
DefaultContext context = contextHandler.getModelObject();
// context augmentation
Augmentable augmentableContext = context;
// context augmentation with topologyContext
org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext augmentedTopologyContext = new org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext();
augmentableContext.addAugmentation(augmentedTopologyContext);
// context augmentation with connectivityServiceContext
org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext augmentedConnectivityContext = new org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext();
augmentableContext.addAugmentation(augmentedConnectivityContext);
// topology context
DefaultTopologyContext topologyContext = TapiTopologyContextHandler.create().getModelObject();
augmentedTopologyContext.topologyContext(topologyContext);
// topology
TapiTopologyHandler topologyHandler = TapiTopologyHandler.create();
topologyHandler.setId(Uuid.of("00000000-0000-0000-0000-000000000001"));
DefaultTopology topology = topologyHandler.getModelObject();
topologyContext.addToTopology(topology);
// nodes
TapiNodeHandler nodeHandler1 = TapiNodeHandler.create();
nodeHandler1.setId(Uuid.of("00000000-0000-0000-0001-000000000001"));
DefaultNode node1 = nodeHandler1.setTopologyUuid(topology.uuid()).setDeviceId(did1).getModelObject();
topology.addToNode(node1);
TapiNodeHandler nodeHandler2 = TapiNodeHandler.create();
nodeHandler2.setId(Uuid.of("00000000-0000-0000-0001-000000000002"));
DefaultNode node2 = nodeHandler2.setTopologyUuid(topology.uuid()).setDeviceId(did2).getModelObject();
topology.addToNode(node2);
// sips
TapiSipHandler sipHandler1 = TapiSipHandler.create();
sipHandler1.setId(Uuid.of("00000000-0000-0000-0002-000000000001"));
DefaultServiceInterfacePoint sip1 = sipHandler1.setConnectPoint(cp11).getModelObject();
context.addToServiceInterfacePoint(sip1);
TapiSipHandler sipHandler2 = TapiSipHandler.create();
sipHandler2.setId(Uuid.of("00000000-0000-0000-0002-000000000002"));
DefaultServiceInterfacePoint sip2 = sipHandler2.setConnectPoint(cp21).getModelObject();
context.addToServiceInterfacePoint(sip2);
// neps
TapiNepHandler nepHandler11 = TapiNepHandler.create();
nepHandler11.setId(Uuid.of("00000000-0000-0000-0003-000000000011"));
DefaultOwnedNodeEdgePoint nep11 = nepHandler11.setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp11).addSip(sip1.uuid()).getModelObject();
nodeHandler1.addNep(nep11);
TapiNepHandler nepHandler12 = TapiNepHandler.create();
nepHandler12.setId(Uuid.of("00000000-0000-0000-0003-000000000012"));
DefaultOwnedNodeEdgePoint nep12 = nepHandler12.setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp12).getModelObject();
nodeHandler1.addNep(nep12);
TapiNepHandler nepHandler21 = TapiNepHandler.create();
nepHandler21.setId(Uuid.of("00000000-0000-0000-0003-000000000021"));
DefaultOwnedNodeEdgePoint nep21 = nepHandler21.setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp21).addSip(sip2.uuid()).getModelObject();
nodeHandler2.addNep(nep21);
TapiNepHandler nepHandler22 = TapiNepHandler.create();
nepHandler22.setId(Uuid.of("00000000-0000-0000-0003-000000000022"));
DefaultOwnedNodeEdgePoint nep22 = nepHandler22.setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp22).getModelObject();
nodeHandler2.addNep(nep22);
// connectivity context
DefaultConnectivityContext connectivityContext = TapiConnectivityContextHandler.create().getModelObject();
augmentedConnectivityContext.connectivityContext(connectivityContext);
// connectivityService
TapiConnectivityServiceHandler connectivityServiceHandler = TapiConnectivityServiceHandler.create();
connectivityServiceHandler.setId(Uuid.of("00000000-0000-0000-0004-000000000001"));
DefaultConnectivityService connectivityService = connectivityServiceHandler.getModelObject();
connectivityContext.addToConnectivityService(connectivityService);
// connection
TapiConnectionHandler connectionHandler = TapiConnectionHandler.create();
connectionHandler.setId(Uuid.of("00000000-0000-0000-0005-000000000001"));
DefaultConnection connection1 = connectionHandler.getModelObject();
connectivityServiceHandler.addConnection(connection1.uuid());
connectivityContext.addToConnection(connection1);
// seps
TapiSepHandler sepHandler1 = TapiSepHandler.create();
sepHandler1.setId(Uuid.of("00000000-0000-0000-0006-000000000001"));
DefaultEndPoint sep1 = sepHandler1.getModelObject();
connectivityServiceHandler.addSep(sep1);
TapiSepHandler sepHandler2 = TapiSepHandler.create();
sepHandler2.setId(Uuid.of("00000000-0000-0000-0006-000000000002"));
DefaultEndPoint sep2 = sepHandler2.getModelObject();
connectivityServiceHandler.addSep(sep2);
// ceps
TapiCepHandler cepHandler11 = TapiCepHandler.create();
cepHandler11.setId(Uuid.of("00000000-0000-0000-0007-000000000011"));
org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.ceplist.DefaultConnectionEndPoint cep11 = cepHandler11.setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setNepUuid(nep11.uuid()).setParentNep().getModelObject();
nepHandler11.addCep(cep11);
org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connection.DefaultConnectionEndPoint cepRef11 = TapiCepRefHandler.create().setCep(cep11).getModelObject();
connectionHandler.addCep(cepRef11);
TapiCepHandler cepHandler21 = TapiCepHandler.create();
cepHandler21.setId(Uuid.of("00000000-0000-0000-0007-000000000021"));
org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.ceplist.DefaultConnectionEndPoint cep21 = cepHandler21.setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setNepUuid(nep21.uuid()).setParentNep().getModelObject();
nepHandler21.addCep(cep21);
org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connection.DefaultConnectionEndPoint cepRef21 = TapiCepRefHandler.create().setCep(cep21).getModelObject();
connectionHandler.addCep(cepRef21);
}
use of org.onosproject.odtn.utils.tapi.TapiConnectionHandler 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.odtn.utils.tapi.TapiConnectionHandler 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