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

Henning Rogge <hrogge@gmail.com> Wed, 29 April 2020 17:30 UTC

Return-Path: <hrogge@gmail.com>
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 B31103A14A2 for <netconf@ietfa.amsl.com>; Wed, 29 Apr 2020 10:30:37 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.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 E5-Lhl5t52LD for <netconf@ietfa.amsl.com>; Wed, 29 Apr 2020 10:30:35 -0700 (PDT)
Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 4B3183A149C for <netconf@ietf.org>; Wed, 29 Apr 2020 10:30:35 -0700 (PDT)
Received: by mail-lf1-x141.google.com with SMTP id r17so2401687lff.2 for <netconf@ietf.org>; Wed, 29 Apr 2020 10:30:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/1qAu3OY/q0sG6kZOU38EgvcnxSrLoVKUOBoecLqm1E=; b=BwVSxmO1F/YQzDyMcCJ6AQEv3V4pEigd/ofUuVlqPqlwgkCgH7OtEh5gq0lVTkZzvb 86Pz0zPg7o+V8JPrSe7e9wIzWXQDo3QiRZyhsbGZHNTGudykvf9seNh1/0ani2nV3Rjn j9xNyjVdH6OFONYoiBygphLqYpFOfh3NOT8cfOT5zYi8wdI5fBCemqmOJTemCmNFyGqZ oJx4C6paji833FyP/9Oes+xv/k/krrf/Adxtm79EdO6M5pwWkuD3DyxClIHPeQ1nH6HS 2EEyV4QGj0BMQEjAQ2QOVLOi/STbPdD52lKPi0xcwFla/tJOOKPUCW5myQ0RbbrJw5mn ShwA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/1qAu3OY/q0sG6kZOU38EgvcnxSrLoVKUOBoecLqm1E=; b=tIBMkDJsfwtGiNkUtyodiKxJqhbW0DbyIRLI1ploDhF901NjRofAapYVwmwZ2SXs7C wD5ZctwqJkKtQ0Kbp/mGw/fPCFWYnScrcj4lYLc8QuxTKEMN744zRDTs2zdXoF7GnNj1 EVcAYwsc1bDc0d/zV6w2g63JJJA2X2QRRuvQF5ywnOVU4vM94yQX1ceALio0W8fxKVUx GaPbNGHvCZlc4H/Eqiq3IFxbedrAeYHhzzXTFTz7s7kqt0XgwTbdDKB1unTW9CcVtR9K 1QaNnF8tJbKf6ZeTzWp+mGVx4tnYUcidzLuw4uuLstLvTWDGT04mH0gvQhPvQ3IxnykQ gO4Q==
X-Gm-Message-State: AGi0Pub+aY6UFGycOfGMglkAUSCTf7lTAFEpniwRVAcf9UtfcIr5jlIO tAqPXUb9dHsx+yTfeJrWlLMVzmOw3mLMNUzBWOmUmIakVQA=
X-Google-Smtp-Source: APiQypKdIXkazaRzBqo1A51drIgV491F030xa2fYa3ZC+JiTXMaUhqx8EnVdZEgvzxak2skQCEs788NJ2y9vneA9UPk=
X-Received: by 2002:a19:ca0e:: with SMTP id a14mr23696096lfg.105.1588181433091; Wed, 29 Apr 2020 10:30:33 -0700 (PDT)
MIME-Version: 1.0
References: <CAGnRvuqPwW4=6sZbuem94gaW5dnZ8mXgkrALbYHb05JTh_RAaA@mail.gmail.com> <01000171c68f6fc0-d63b2b6e-4dc1-42b7-bd7c-9473803b4f39-000000@email.amazonses.com>
In-Reply-To: <01000171c68f6fc0-d63b2b6e-4dc1-42b7-bd7c-9473803b4f39-000000@email.amazonses.com>
From: Henning Rogge <hrogge@gmail.com>
Date: Wed, 29 Apr 2020 19:30:06 +0200
Message-ID: <CAGnRvuq8CmvA7weG_U_RHe9LtT3vx4ncsXdVEqj0pt0OyghTqw@mail.gmail.com>
To: Kent Watsen <kent+ietf@watsen.net>, Martin Björklund <mbj+ietf@4668.se>
Cc: "netconf@ietf.org" <netconf@ietf.org>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/pnwFJdKAT6Ee4HR05XAnzIB_EMY>
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 17:30:38 -0000

On Wed, Apr 29, 2020 at 5:30 PM Kent Watsen <kent+ietf@watsen.net> wrote:
> 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?

No, I am working on a generic Python server library... based on the
yangson (https://github.com/CZ-NIC/yangson) library for the data
model.
Currently I am patching yangson for XML support (and hope I can
upstream the code later).

> > 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...

I think there is a 1-to-1 mapping between RFC 7951 JSON encoding and
the internal state of the Netconf/Restconf data model.
This is not true for the XML encoding described in RFC 7950 (If I got
it right). There is a "collision" between 1-entry leaf-lists and
normal leaf nodes... and between a list with one entry and a
container. This means there is a definite mapping from the data state
to XML... but no definite way to guess the structure from reading the
XML data. Which leads to the "anydata" trouble when receiving XML.

> > 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?

I am trying to write a generic server.

> 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:

Yes, binary would be a replacement... as would be "store anyxml in a
string for JSON transport". But RFC 7951 definitely says "encode in
I-JSON"... whatever that means (see RFC 7951, section 5.6).

> > 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?

Good to know that its really deprecated, maybe I will just skip the
support for anyxml... (at least for the XML transport).

That sounds like I good advice. Thank you.



On Wed, Apr 29, 2020 at 5:40 PM Martin Björklund <mbj+ietf@4668.se> wrote:
> > 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.
>
> In order to properly convert between JSON/XML for anydata in the
> general case, you need the YANG model that describes the anydata
> content.

Yes... but RFC 7950 and RFC 7951 seem to suggest otherwise... most
likely it was easy to do before the JSON based encoding was
introduced.

> I don't think anyxml can be converted in the general case; remember
> that it can contain *any* XML, including processing instructions,
> mixed content etc.

So the best solution might be "demand YANG schema for anydata nodes"
and "just ignore anyxml". Thank you.

Henning Rogge