Skip to content

Add support for finding the Root Resource as specified by RFC 8040. #1096

@drewtoto

Description

@drewtoto

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Expected Behavior

Correctly parse the Root Resource as specified by RESTCONF Protocol (RFC 8040) Section 3.1 from the "/.well-known/host-meta" resource when multiple <Link> elements are present. The Root Resource is determined by the <Link> element that contains "rel='restconf'" attribute.

See https://datatracker.ietf.org/doc/html/rfc8040#section-3.1

Example response from "/.well-known/host-meta" with multiple <Link>

<?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
   <Property type='http://example.org/example'>Example< /Property>
   <Link rel='copyright' href='/copyright'/>
   <Link rel='restconf' type='application/yang-data+json' href='/restconf'/>
</XRD>

Current Behavior

The first <Link> in the "/.well-known/host-meta" response is assumed to be the RESTCONF Root Resource without checking for the "rel='restconf'" attribute.

Steps to Reproduce

  1. Set up (build/install/etc) a YDK environment as specified by the documentation.
  2. Acquire (or configure) a RESTCONF server that contains multiple attributes where the RESTCONF is not the first in the list.
  3. Create an application that uses the YDK RestconfServiceProvider to connect to the server in step 2 (above).
  4. Notice that the Root Resource used by the YDK RestconfServiceProvider client is taken from the first , not the correct <Link> specifying the "rel='restconf'" attribute.

Your Script

from __future__ import print_function
from ydk.providers import RestconfServiceProvider
from ydk.path import Repository
from ydk.types import EncodingFormat
import ydk

if __name__ == "__main__":
    provider = RestconfServiceProvider(repo=Repository(REPO_PATH), address=TARGET_IP, username=TARGET_USER, password=TARGET_PASSWORD, port=PORT, encoding=EncodingFormat.JSON)

Logs

Enable logging and post the logs below


System Information

Python 3.8.10
Ubuntu 20.04.6 LTS
Intel x86_64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions