Search in sources :

Example 1 with DefaultAugmentedTapiCommonContext

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

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.

the class TapiConnectivityContextHandler method getParentModelObjectId.

@Override
public ModelObjectId getParentModelObjectId() {
    DefaultAugmentedTapiCommonContext context = new DefaultAugmentedTapiCommonContext();
    context.connectivityContext(obj);
    return ModelObjectId.builder().addChild(DefaultContext.class).build();
}
Also used : DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)

Example 3 with DefaultAugmentedTapiCommonContext

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.

the class DcsBasedTapiDataProducerTest method makeTestData.

private void makeTestData() {
    did1 = DeviceId.deviceId("netconf:127.0.0.1:11001");
    did2 = DeviceId.deviceId("netconf:127.0.0.1:11002");
    cp11 = new ConnectPoint(did1, PortNumber.portNumber(1, "TRANSCEIVER"));
    cp12 = new ConnectPoint(did1, PortNumber.portNumber(2, "TRANSCEIVER"));
    cp21 = new ConnectPoint(did2, PortNumber.portNumber(1, "TRANSCEIVER"));
    cp22 = new ConnectPoint(did2, PortNumber.portNumber(2, "TRANSCEIVER"));
    context = new DefaultContext();
    topology = TapiTopologyHandler.create().getModelObject();
    DefaultTopologyContext topologyContext = TapiTopologyContextHandler.create().getModelObject();
    DefaultAugmentedTapiCommonContext augmentedTopologyContext = new DefaultAugmentedTapiCommonContext();
    Augmentable augmentableContext = context;
    augmentableContext.addAugmentation(augmentedTopologyContext);
    augmentedTopologyContext.topologyContext(topologyContext);
    topologyContext.addToTopology(topology);
    node1 = TapiNodeHandler.create().setTopologyUuid(topology.uuid()).setDeviceId(did1).getModelObject();
    node2 = TapiNodeHandler.create().setTopologyUuid(topology.uuid()).setDeviceId(did2).getModelObject();
    sip11 = TapiSipHandler.create().setConnectPoint(cp11).getModelObject();
    sip21 = TapiSipHandler.create().setConnectPoint(cp21).getModelObject();
    nep11 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp11).addSip(sip11.uuid()).getModelObject();
    nep12 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node1.uuid()).setConnectPoint(cp12).getModelObject();
    nep21 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp21).addSip(sip21.uuid()).getModelObject();
    nep22 = TapiNepHandler.create().setTopologyUuid(topology.uuid()).setNodeUuid(node2.uuid()).setConnectPoint(cp22).getModelObject();
}
Also used : DefaultTopologyContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.augmentedtapicommoncontext.DefaultTopologyContext) DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext) ConnectPoint(org.onosproject.net.ConnectPoint) Augmentable(org.onosproject.yang.model.Augmentable)

Example 4 with DefaultAugmentedTapiCommonContext

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext 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 5 with DefaultAugmentedTapiCommonContext

use of org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.context.DefaultAugmentedTapiCommonContext in project onos by opennetworkinglab.

the class TapiTopologyContextHandler method getParentModelObjectId.

@Override
public ModelObjectId getParentModelObjectId() {
    DefaultAugmentedTapiCommonContext context = new DefaultAugmentedTapiCommonContext();
    context.topologyContext(obj);
    return ModelObjectId.builder().addChild(DefaultContext.class).build();
}
Also used : DefaultAugmentedTapiCommonContext(org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext) DefaultContext(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)

Aggregations

DefaultContext (org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext)5 DefaultAugmentedTapiCommonContext (org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.DefaultAugmentedTapiCommonContext)4 ConnectPoint (org.onosproject.net.ConnectPoint)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)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 DeviceId (org.onosproject.net.DeviceId)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