Search in sources :

Example 6 with Topology

use of org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology 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)

Aggregations

HashMap (java.util.HashMap)4 ConnectPoint (org.onosproject.net.ConnectPoint)4 DefaultContext (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)4 DeviceId (org.onosproject.net.DeviceId)3 DefaultAugmentedTapiCommonContext (org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)2 DynamicConfigService (org.onosproject.config.DynamicConfigService)2 Filter (org.onosproject.config.Filter)2 CONNECTION_ID (org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID)2 DcsBasedTapiObjectRefFactory (org.onosproject.odtn.utils.tapi.DcsBasedTapiObjectRefFactory)2 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)2 TapiNodeRef (org.onosproject.odtn.utils.tapi.TapiNodeRef)2 DEVICE_ID (org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID)2 ODTN_PORT_TYPE (org.onosproject.odtn.utils.tapi.TapiObjectHandler.ODTN_PORT_TYPE)2 ONOS_CP (org.onosproject.odtn.utils.tapi.TapiObjectHandler.ONOS_CP)2