Search in sources :

Example 1 with DefaultConnectivityService

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService 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 DefaultConnectivityService

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService 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)2 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)2 DefaultConnectivityService (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService)2 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 TapiCepHandler (org.onosproject.odtn.utils.tapi.TapiCepHandler)1 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)1 TapiNepHandler (org.onosproject.odtn.utils.tapi.TapiNepHandler)1 TapiNodeHandler (org.onosproject.odtn.utils.tapi.TapiNodeHandler)1 TapiSepHandler (org.onosproject.odtn.utils.tapi.TapiSepHandler)1 TapiSipHandler (org.onosproject.odtn.utils.tapi.TapiSipHandler)1 TapiTopologyHandler (org.onosproject.odtn.utils.tapi.TapiTopologyHandler)1 DefaultContext (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)1 DefaultServiceInterfacePoint (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.tapicontext.DefaultServiceInterfacePoint)1 DefaultConnection (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnection)1 DefaultEndPoint (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivityservice.DefaultEndPoint)1 DefaultConnectivityContext (org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.augmentedtapicommoncontext.DefaultConnectivityContext)1 DefaultTopologyContext (org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.augmentedtapicommoncontext.DefaultTopologyContext)1 DefaultOwnedNodeEdgePoint (org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.node.DefaultOwnedNodeEdgePoint)1 DefaultNode (org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topology.DefaultNode)1