Search in sources :

Example 1 with TapiConnectionHandler

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);
}
Also used : DefaultTopology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.DefaultTopology) DeviceId(org.onosproject.net.DeviceId) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) DefaultTopologyContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.augmentedtapicommoncontext.DefaultTopologyContext) TapiNepHandler(org.onosproject.odtn.utils.tapi.TapiNepHandler) TapiTopologyHandler(org.onosproject.odtn.utils.tapi.TapiTopologyHandler) DefaultOwnedNodeEdgePoint(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.node.DefaultOwnedNodeEdgePoint) TapiNodeHandler(org.onosproject.odtn.utils.tapi.TapiNodeHandler) DefaultNode(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topology.DefaultNode) DefaultEndPoint(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivityservice.DefaultEndPoint) DefaultConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) DefaultServiceInterfacePoint(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.tapicontext.DefaultServiceInterfacePoint) TapiSipHandler(org.onosproject.odtn.utils.tapi.TapiSipHandler) ConnectPoint(org.onosproject.net.ConnectPoint) Augmentable(org.onosproject.yang.model.Augmentable) DefaultConnection(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnection) TapiCepHandler(org.onosproject.odtn.utils.tapi.TapiCepHandler) TapiSepHandler(org.onosproject.odtn.utils.tapi.TapiSepHandler) DefaultConnectivityContext(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.augmentedtapicommoncontext.DefaultConnectivityContext) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)

Example 2 with TapiConnectionHandler

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

Example 3 with TapiConnectionHandler

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

TapiConnectionHandler (org.onosproject.odtn.utils.tapi.TapiConnectionHandler)3 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)3 DefaultConnectivityService (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService)3 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)2 TapiSepHandler (org.onosproject.odtn.utils.tapi.TapiSepHandler)2 RpcOutput (org.onosproject.yang.model.RpcOutput)2 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 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 TapiResolver (org.onosproject.odtn.TapiResolver)1 TapiCepHandler (org.onosproject.odtn.utils.tapi.TapiCepHandler)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 TapiGetConnectivityDetailsInputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler)1