[NETCONF-740] RFC8040 compliance: API Resource Created: 02/Nov/20  Updated: 22/Jun/23

Status: Confirmed
Project: netconf
Component/s: restconf-nb
Affects Version/s: Aluminium
Fix Version/s: 7.0.0

Type: Bug Priority: Medium
Reporter: Valentin Mayamsin Assignee: Ivan Hrasko
Resolution: Unresolved Votes: 0
Labels: pick-next, pt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:
  • ODL aluminum
  • feature:install odl-restconf-nb-rfc8040
  • feature:install odl-toaster

Issue Links:
Relates
relates to NETCONF-855 RESTCONF mis-represents the root name... Confirmed

 Description   

https://tools.ietf.org/html/rfc8040#section-3.3

 The \{+restconf} root resource name used in responses representing the
 root of the "ietf-restconf" module MUST identify the "ietf-restconf"
 YANG module. For example, a request to GET the root resource
 "/restconf" in JSON format will return a representation of the API
 resource named "ietf-restconf:restconf".

> curl -u admin:admin http://localhost:8181/rests

< 404 Not Found



 Comments   
Comment by Robert Varga [ 19/Jul/21 ]

This requires updating JAX-RS structure so that we also service the root element and return the combination of individual API resources.

     +---- {+restconf}
           +---- data
           | ...
           +---- operations?
           | ...
           +--ro yang-library-version    string

i.e. we are servicing /data, /yang-library-version and /operations, but do not service /.

Comment by Ivan Hrasko [ 29/Nov/22 ]

We need to find out some way how to return a combination of /data, /yang-library-version and /operations.

The problem of patchset 9 is that we are not able to read other data except of YANG library version.

There are at least these possibilities:
1. Rewrite RestconfImpl class to implement all needed services (RestconfDataService, RestconfOperationsService) via delegation.

It requires the constructor as following:

    public RestconfImpl(final DatabindProvider databindProvider, final RestconfDataService dataService,
            final RestconfOperationsService operationsService) {
        this.databindProvider = requireNonNull(databindProvider);
        this.dataService = requireNonNull(dataService);
        this.operationsService = requireNonNull(operationsService);
    }

and additional changes in RestconfApplication and  maybe also in restconf-bp.xml.

2. Refactor RestconfDataServiceImpl and RestconfOperationsServiceImpl logic into utility methods which allows us to read data and operations from RestconfImpl class.

3. Copy and paste code which we need...

Comment by Ivan Hrasko [ 09/Dec/22 ]

Following solution will not work for similar reasons like in NETCONF-822. We cannot create full data like this:

final var libVersion = getLibraryVersion().getData();
final var data = ((NormalizedNodePayload) readData(uriInfo).getEntity()).getData();

final var result = Builders.containerBuilder()
        .withNodeIdentifier(NodeIdentifier.create(Restconf.QNAME))
        .withChild((LeafNode) libVersion)
        .withChild((ContainerNode) data)
        .build(); 

because then we get a failure from writers:

Caused by: java.lang.IllegalArgumentException: Data tree child (urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring?revision=2017-01-26)restconf-state not present in schema parent (urn:ietf:params:xml:ns:yang:ietf-restconf?revision=2017-01-26)restconf
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.notPresent(SchemaInferenceStack.java:1046) ~[?:?]
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.lambda$pushData$6(SchemaInferenceStack.java:853) ~[?:?]
    at java.util.Optional.orElseThrow(Optional.java:403) ~[?:?]
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.pushData(SchemaInferenceStack.java:853) ~[?:?]
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.pushData(SchemaInferenceStack.java:847) ~[?:?]
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.pushData(SchemaInferenceStack.java:841) ~[?:?]
    at org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack.enterDataTree(SchemaInferenceStack.java:531) ~[?:?]
    at org.opendaylight.yangtools.yang.data.util.NormalizedNodeStreamWriterStack.enterDataTree(NormalizedNodeStreamWriterStack.java:204) ~[?:?]
    at org.opendaylight.yangtools.yang.data.util.NormalizedNodeStreamWriterStack.startContainerNode(NormalizedNodeStreamWriterStack.java:276) ~[?:?]
    at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.startContainerNode(JSONNormalizedNodeStreamWriter.java:406) ~[?:?]
    at org.opendaylight.restconf.nb.rfc8040.jersey.providers.ParameterAwareNormalizedNodeWriter.wasProcessedAsCompositeNode(ParameterAwareNormalizedNodeWriter.java:273) ~[?:?]

what's true because Restconf YANG model defines data as just empty container .

Comment by Ivan Hrasko [ 09/Dec/22 ]

OK.. we can maybe try to adjust little bit - but I expect it will not work anyway..

Generated at Wed Feb 07 20:15:46 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.