Search in sources :

Example 6 with TapiNepRef

use of org.onosproject.odtn.utils.tapi.TapiNepRef 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)

Example 7 with TapiNepRef

use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.

the class DcsBasedTapiDataProducer method getNeps.

/**
 * Extract Tapi Neps from context modelObject and convert them to NepRefs.
 *
 * @param context
 * @return List of TapiNepRef
 */
private List<TapiNepRef> getNeps(DefaultContext context) {
    DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
    Topology topology = topologyContext.topologyContext().topology().get(0);
    if (topology.node() == null) {
        return Collections.emptyList();
    }
    List<TapiNepRef> ret = topology.node().stream().flatMap(node -> {
        if (node.ownedNodeEdgePoint() == null) {
            return null;
        }
        return node.ownedNodeEdgePoint().stream().map(nep -> {
            TapiNepRef nepRef = DcsBasedTapiObjectRefFactory.create(topology, node, nep);
            if (nep.name() != null) {
                Map<String, String> kvs = new HashMap<>();
                nep.name().forEach(kv -> kvs.put(kv.valueName(), kv.value()));
                String onosConnectPoint = kvs.getOrDefault(ONOS_CP, null);
                String portType = kvs.getOrDefault(ODTN_PORT_TYPE, null);
                String connectionId = kvs.getOrDefault(CONNECTION_ID, null);
                nepRef.setConnectPoint(ConnectPoint.fromString(onosConnectPoint)).setPortType(portType).setConnectionId(connectionId);
            }
            if (nep.mappedServiceInterfacePoint() != null) {
                nep.mappedServiceInterfacePoint().stream().forEach(sip -> {
                    nepRef.setSipId(sip.serviceInterfacePointUuid().toString());
                });
            }
            DefaultAugmentedTapiTopologyOwnedNodeEdgePoint augmentNep = nep.augmentation(DefaultAugmentedTapiTopologyOwnedNodeEdgePoint.class);
            try {
                if (augmentNep.cepList().connectionEndPoint() != null) {
                    List<String> cepIds = augmentNep.cepList().connectionEndPoint().stream().map(cep -> cep.uuid().toString()).collect(Collectors.toList());
                    nepRef.setCepIds(cepIds);
                }
            } catch (NullPointerException e) {
                log.warn("Augmented ownedNodeEdgePoint is not found.");
            }
            return nepRef;
        });
    }).collect(Collectors.toList());
    return ret;
}
Also used : DcsBasedTapiObjectRefFactory(org.onosproject.odtn.utils.tapi.DcsBasedTapiObjectRefFactory) HashMap(java.util.HashMap) DefaultModelObjectData(org.onosproject.yang.model.DefaultModelObjectData) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) ResourceData(org.onosproject.yang.model.ResourceData) ConnectPoint(org.onosproject.net.ConnectPoint) DataNode(org.onosproject.yang.model.DataNode) Map(java.util.Map) DynamicConfigService(org.onosproject.config.DynamicConfigService) Name(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) Logger(org.slf4j.Logger) DefaultResourceData(org.onosproject.yang.model.DefaultResourceData) ModelConverter(org.onosproject.yang.model.ModelConverter) ModelObjectId(org.onosproject.yang.model.ModelObjectId) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) ResourceId(org.onosproject.yang.model.ResourceId) DefaultAugmentedTapiTopologyOwnedNodeEdgePoint(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.topologycontext.topology.node.ownednodeedgepoint.DefaultAugmentedTapiTopologyOwnedNodeEdgePoint) List(java.util.List) CONNECTION_ID(org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID) ModelObjectData(org.onosproject.yang.model.ModelObjectData) Topology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology) ODTN_PORT_TYPE(org.onosproject.odtn.utils.tapi.TapiObjectHandler.ODTN_PORT_TYPE) DEVICE_ID(org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Filter(org.onosproject.config.Filter) DeviceId(org.onosproject.net.DeviceId) Collections(java.util.Collections) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) ONOS_CP(org.onosproject.odtn.utils.tapi.TapiObjectHandler.ONOS_CP) DefaultAugmentedTapiTopologyOwnedNodeEdgePoint(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.topologycontext.topology.node.ownednodeedgepoint.DefaultAugmentedTapiTopologyOwnedNodeEdgePoint) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) List(java.util.List) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) Topology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with TapiNepRef

use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.

the class DcsBasedTapiTopologyManager method addLink.

@Override
public void addLink(Link link) {
    log.debug("Add link: {}", link);
    // TODO: existence check
    // link
    TapiNepRef srcNepRef = tapiResolver.getNepRef(link.src());
    TapiNepRef dstNepRef = tapiResolver.getNepRef(link.dst());
    TapiLinkHandler.create().setTopologyUuid(topology.uuid()).addNep(srcNepRef).addNep(dstNepRef).add();
}
Also used : TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef)

Example 9 with TapiNepRef

use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.

the class DefaultTapiPathComputer method mockPathCompute.

/**
 * Mock to create path computation result.
 *
 * neps.left           connection                 neps.right
 * ■----------------------------------------------------■
 *  \                                                  /
 *   \                                                /
 *    \ leftLowerConnection                          / rightLowerConnection
 *     \                                            /
 *      \                                          /
 *       ■                                        ■
 *   leftLineNep                             rightLineNep
 */
private TapiConnection mockPathCompute(TapiNepPair neps) {
    TapiNepRef leftLineNep = mockGetTransponderLinePort(neps.left());
    TapiNepRef rightLineNep = mockGetTransponderLinePort(neps.right());
    TapiConnection leftLowerConnection = TapiConnection.create(TapiCepRef.create(neps.left(), neps.left().getCepIds().get(0)), TapiCepRef.create(leftLineNep, leftLineNep.getCepIds().get(0)));
    TapiConnection rightLowerConnection = TapiConnection.create(TapiCepRef.create(neps.right(), neps.right().getCepIds().get(0)), TapiCepRef.create(rightLineNep, rightLineNep.getCepIds().get(0)));
    TapiConnection connection = TapiConnection.create(TapiCepRef.create(neps.left(), neps.left().getCepIds().get(0)), TapiCepRef.create(neps.right(), neps.right().getCepIds().get(0)));
    connection.addLowerConnection(leftLowerConnection).addLowerConnection(rightLowerConnection);
    return connection;
}
Also used : TapiConnection(org.onosproject.odtn.utils.tapi.TapiConnection) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef)

Example 10 with TapiNepRef

use of org.onosproject.odtn.utils.tapi.TapiNepRef in project onos by opennetworkinglab.

the class DefaultTapiResolver method getNepRef.

@Override
public TapiNepRef getNepRef(TapiNepRef nepRef) throws NoSuchElementException {
    updateCache();
    TapiNepRef ret = null;
    try {
        ret = tapiNepRefList.stream().filter(nepRef::equals).findFirst().get();
    } catch (NoSuchElementException e) {
        log.error("Nep not found of {}", nepRef);
        throw e;
    }
    return ret;
}
Also used : TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)10 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 Logger (org.slf4j.Logger)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 NoSuchElementException (java.util.NoSuchElementException)3 TapiResolver (org.onosproject.odtn.TapiResolver)3 TapiNodeRef (org.onosproject.odtn.utils.tapi.TapiNodeRef)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Stream (java.util.stream.Stream)2 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)2 DynamicConfigService (org.onosproject.config.DynamicConfigService)2 ElementId (org.onosproject.net.ElementId)2 TapiConnection (org.onosproject.odtn.utils.tapi.TapiConnection)2 ModelConverter (org.onosproject.yang.model.ModelConverter)2 Activate (org.osgi.service.component.annotations.Activate)2 Component (org.osgi.service.component.annotations.Component)2 Deactivate (org.osgi.service.component.annotations.Deactivate)2