Search in sources :

Example 1 with TapiNodeRef

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

the class DcsBasedTapiDataProducer method getNodes.

/**
 * Extract Tapi Nodes from context modelObject and convert them to NodeRefs.
 *
 * @param context
 * @return List of NodeRef
 */
private List<TapiNodeRef> getNodes(DefaultContext context) {
    DefaultAugmentedTapiCommonContext topologyContext = context.augmentation(DefaultAugmentedTapiCommonContext.class);
    Topology topology = topologyContext.topologyContext().topology().get(0);
    if (topology.node() == null) {
        return Collections.emptyList();
    }
    return topology.node().stream().map(node -> {
        TapiNodeRef nodeRef = DcsBasedTapiObjectRefFactory.create(topology, node);
        if (node.name() != null) {
            String deviceId = node.name().stream().filter(kv -> kv.valueName().equals(DEVICE_ID)).findFirst().map(Name::value).get();
            nodeRef.setDeviceId(DeviceId.deviceId(deviceId));
        }
        return nodeRef;
    }).collect(Collectors.toList());
}
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) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) Topology(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology) Name(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.Name)

Example 2 with TapiNodeRef

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

the class DefaultTapiResolver method getNodeRef.

@Override
public TapiNodeRef getNodeRef(ElementId deviceId) throws NoSuchElementException {
    updateCache();
    TapiNodeRef ret = null;
    try {
        ret = tapiNodeRefList.stream().filter(node -> node.getDeviceId() != null && node.getDeviceId().equals(deviceId)).findFirst().get();
    } catch (NoSuchElementException e) {
        log.error("Node not found associated with {}", deviceId);
        throw e;
    }
    return ret;
}
Also used : Logger(org.slf4j.Logger) TapiResolver(org.onosproject.odtn.TapiResolver) Deactivate(org.osgi.service.component.annotations.Deactivate) ElementId(org.onosproject.net.ElementId) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) ConnectPoint(org.onosproject.net.ConnectPoint) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) List(java.util.List) Stream(java.util.stream.Stream) Map(java.util.Map) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Activate(org.osgi.service.component.annotations.Activate) NoSuchElementException(java.util.NoSuchElementException) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with TapiNodeRef

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

the class DcsBasedTapiTopologyManager method addPort.

@Override
public void addPort(Port port) {
    log.debug("Add port: {}", port);
    ConnectPoint cp = new ConnectPoint(port.element().id(), port.number());
    if (tapiResolver.hasNepRef(cp)) {
        return;
    }
    TapiNodeRef nodeRef = tapiResolver.getNodeRef(port.element().id());
    String nodeId = nodeRef.getNodeId();
    // nep
    TapiNepHandler nepBuilder = TapiNepHandler.create().setPort(port).setTopologyUuid(topology.uuid()).setNodeUuid(Uuid.fromString(nodeId));
    // cep
    TapiCepHandler cepBuilder = TapiCepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(Uuid.fromString(nodeId)).setNepUuid(nepBuilder.getId()).setParentNep();
    nepBuilder.addCep(cepBuilder.getModelObject());
    if (TapiSipHandler.isSip(port)) {
        TapiSipHandler sipBuilder = TapiSipHandler.create().setPort(port);
        nepBuilder.addSip(sipBuilder.getId());
        sipBuilder.add();
    }
    nepBuilder.add();
}
Also used : TapiNodeRef(org.onosproject.odtn.utils.tapi.TapiNodeRef) TapiCepHandler(org.onosproject.odtn.utils.tapi.TapiCepHandler) TapiSipHandler(org.onosproject.odtn.utils.tapi.TapiSipHandler) ConnectPoint(org.onosproject.net.ConnectPoint) TapiNepHandler(org.onosproject.odtn.utils.tapi.TapiNepHandler)

Example 4 with TapiNodeRef

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

the class DefaultTapiResolver method getNodeRef.

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

Aggregations

TapiNodeRef (org.onosproject.odtn.utils.tapi.TapiNodeRef)4 ConnectPoint (org.onosproject.net.ConnectPoint)3 List (java.util.List)2 Map (java.util.Map)2 NoSuchElementException (java.util.NoSuchElementException)2 Collectors (java.util.stream.Collectors)2 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)2 Logger (org.slf4j.Logger)2 LoggerFactory.getLogger (org.slf4j.LoggerFactory.getLogger)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Stream (java.util.stream.Stream)1 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 Filter (org.onosproject.config.Filter)1 DeviceId (org.onosproject.net.DeviceId)1 ElementId (org.onosproject.net.ElementId)1