Search in sources :

Example 1 with Filter

use of org.onosproject.config.Filter in project onos by opennetworkinglab.

the class DynamicDeviceConfigServiceViewTest method testReadNode.

@Test
public void testReadNode() {
    Filter filter = null;
    DataNode returned = view.readNode(relIntf, filter);
    assertTrue(ResourceIds.isPrefix(rid, realPath));
// FIXME test realFilter
// TODO do we expect something to happen on returned?
}
Also used : Filter(org.onosproject.config.Filter) DataNode(org.onosproject.yang.model.DataNode) Test(org.junit.Test)

Example 2 with Filter

use of org.onosproject.config.Filter 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 3 with Filter

use of org.onosproject.config.Filter in project onos by opennetworkinglab.

the class RestconfManager method runGetOperationOnDataResource.

@Override
public ObjectNode runGetOperationOnDataResource(URI uri) throws RestconfException {
    DataResourceLocator rl = DataResourceLocator.newInstance(uri);
    // TODO: define Filter (if there is any requirement).
    Filter filter = Filter.builder().build();
    DataNode dataNode;
    try {
        if (!dynamicConfigService.nodeExist(rl.ridForDynConfig())) {
            return null;
        }
        dataNode = dynamicConfigService.readNode(rl.ridForDynConfig(), filter);
    } catch (FailedException e) {
        log.error("ERROR: DynamicConfigService: ", e);
        throw new RestconfException("ERROR: DynamicConfigService", e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR, Optional.of(uri.getPath()));
    }
    ObjectNode rootNode = convertDataNodeToJson(rl.ridForYangRuntime(), dataNode);
    return rootNode;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Filter(org.onosproject.config.Filter) DataNode(org.onosproject.yang.model.DataNode) RestconfUtils.convertJsonToDataNode(org.onosproject.restconf.utils.RestconfUtils.convertJsonToDataNode) FailedException(org.onosproject.config.FailedException) RestconfException(org.onosproject.restconf.api.RestconfException)

Aggregations

Filter (org.onosproject.config.Filter)3 DataNode (org.onosproject.yang.model.DataNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 FailedException (org.onosproject.config.FailedException)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 CONNECTION_ID (org.onosproject.odtn.behaviour.OdtnDeviceDescriptionDiscovery.CONNECTION_ID)1 DcsBasedTapiObjectRefFactory (org.onosproject.odtn.utils.tapi.DcsBasedTapiObjectRefFactory)1 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)1 TapiNodeRef (org.onosproject.odtn.utils.tapi.TapiNodeRef)1 DEVICE_ID (org.onosproject.odtn.utils.tapi.TapiObjectHandler.DEVICE_ID)1