Re: [netconf] Guidelines for YANG anyxml/anydata statements in RFC8040 (Restconf)

Kent Watsen <kent+ietf@watsen.net> Wed, 29 April 2020 15:30 UTC

Return-Path: <01000171c68f6fc0-d63b2b6e-4dc1-42b7-bd7c-9473803b4f39-000000@amazonses.watsen.net>
X-Original-To: netconf@ietfa.amsl.com
Delivered-To: netconf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 01AA83A12F3 for <netconf@ietfa.amsl.com>; Wed, 29 Apr 2020 08:30:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Level:
X-Spam-Status: No, score=-1.898 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b1Zqnygv-wAm for <netconf@ietfa.amsl.com>; Wed, 29 Apr 2020 08:30:22 -0700 (PDT)
Received: from a48-90.smtp-out.amazonses.com (a48-90.smtp-out.amazonses.com [54.240.48.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A9EE83A12F2 for <netconf@ietf.org>; Wed, 29 Apr 2020 08:30:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1588174221; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:Feedback-ID; bh=P5tI27elPo7OVUqiBQCQR1MK2vlXT2FtIvwlnKjC9l8=; b=WsbgRGnQugfVJDmujqb3kNAcgfiOVOLpXFBd9I+3BZmd9JoH7yuVF9981dEvh9Kd F/mdSNiMTQWiSI0Zi/LyvSQ8MdMaf+F0g1fCATa2pQBdFqQc0uMpp03jyHQ7kBPUWlN ABy39TkP91MXt9QkS+70kyLNnWUn0BYt2xU0v9BU=
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
From: Kent Watsen <kent+ietf@watsen.net>
In-Reply-To: <CAGnRvuqPwW4=6sZbuem94gaW5dnZ8mXgkrALbYHb05JTh_RAaA@mail.gmail.com>
Date: Wed, 29 Apr 2020 15:30:21 +0000
Cc: "netconf@ietf.org" <netconf@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-ID: <01000171c68f6fc0-d63b2b6e-4dc1-42b7-bd7c-9473803b4f39-000000@email.amazonses.com>
References: <CAGnRvuqPwW4=6sZbuem94gaW5dnZ8mXgkrALbYHb05JTh_RAaA@mail.gmail.com>
To: Henning Rogge <hrogge@gmail.com>
X-Mailer: Apple Mail (2.3445.104.11)
X-SES-Outgoing: 2020.04.29-54.240.48.90
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/-DynCT-jj7hlBm1-IMJe7wVZFM0>
Subject: Re: [netconf] Guidelines for YANG anyxml/anydata statements in RFC8040 (Restconf)
X-BeenThere: netconf@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETCONF WG list <netconf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netconf>, <mailto:netconf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netconf/>
List-Post: <mailto:netconf@ietf.org>
List-Help: <mailto:netconf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netconf>, <mailto:netconf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Apr 2020 15:30:24 -0000

Hi Henning,


> I have some trouble with the anyxml/anydata YANG statements in
> Restconf... to be more precise in a Restconf-server that accepts both
> XML and JSON transport encoding.

Is the server bound to an application that can provide supplemental schema for the anyxml/anydata schema?


> The anydata issue is that there are some "data resources" that have
> the same XML transport encoding but different JSON encoding. Which
> means I cannot "guess" the YANG schema of incoming XML data for an
> anyxml statement.

Is the issue *only* with incoming XML data?  That is, is incoming JSON data always mappable to conforming XML data?  I think that this almost true, but my spider-sense is tingling.  Something beyond the XML-encoding’s [seemingly unnecessary] requirement that list keys are encoded first and in order...


> If I read RFC 7950 and 7951 correctly, then a (as an example)
> leaf-list with a single entry has the same encoding in XML as a leaf
> of the same name... but not in JSON. Same is true for a list with one
> element and a container.

Can the server mandate some limitations/conventions/annotations that would enable transcoding?    For instance, could the server require that "xsi:schemaLocation” be set in order to grok incoming XML ‘any’ data?    Or, alternately, define a proprietary XML-attriibute where needed?

If not, likely all that can be done is to treat the XML ‘any’ data as an opaque blob.   FWIW, this is in effect what RFC 8572 does by using “binary” instead of “anydata” for its “configuration” leaf:

          leaf configuration {
            type binary;
            description
              "Any configuration known to the device.  The use of
               the 'binary' type enables content (e.g., XML) to be
               embedded into a JSON document.  The exact encoding
               of the content, as with the scripts, is vendor
               specific.";
          }

          Note: the middle sentence should’ve been written: "The use of the
                   'binary' type enables content (e.g., XML) to be embedded
                    into a document with an alternate encoding (e.g., JSON).


> The problem with anyxml is the same and worse... RFC 7951 section 5.6
> demands transporting the data encoded in JSON (and not in a string
> that contains the XML data), but does not define how to encode the XML
> data into JSON and the other way around.

Does “anyxml” have to be supported, given that it’s effectively (albeit not yet officially) deprecated?


> Are there any guidelines/best-practices for this problem?

Not yet that I’m aware of, but it might make a nice I-D if we can come up with some.


Kent // contributor