[netmod] 答复: A question about YANG identifier design

yuchaode <yuchaode@huawei.com> Thu, 26 May 2022 02:18 UTC

Return-Path: <yuchaode@huawei.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost []) by ietfa.amsl.com (Postfix) with ESMTP id BDC3FC3A9174; Wed, 25 May 2022 19:18:32 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -6.799
X-Spam-Status: No, score=-6.799 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, HTTP_ESCAPED_HOST=0.1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([]) by localhost (ietfa.amsl.com []) (amavisd-new, port 10024) with ESMTP id en1YnP8Hx8YM; Wed, 25 May 2022 19:18:28 -0700 (PDT)
Received: from frasgout.his.huawei.com (frasgout.his.huawei.com []) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A4A81C3A9173; Wed, 25 May 2022 19:18:27 -0700 (PDT)
Received: from fraeml713-chm.china.huawei.com (unknown []) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4L7s670jMXz67fr9; Thu, 26 May 2022 10:17:51 +0800 (CST)
Received: from canpemm100003.china.huawei.com ( by fraeml713-chm.china.huawei.com ( with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 26 May 2022 04:18:22 +0200
Received: from canpemm500002.china.huawei.com ( by canpemm100003.china.huawei.com ( with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 26 May 2022 10:18:20 +0800
Received: from canpemm500002.china.huawei.com ([]) by canpemm500002.china.huawei.com ([]) with mapi id 15.01.2375.024; Thu, 26 May 2022 10:18:20 +0800
From: yuchaode <yuchaode@huawei.com>
To: 'Jan Lindblad' <janl@tail-f.com>
CC: Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>, "netmod@ietf.org" <netmod@ietf.org>, "netconf@ietf.org" <netconf@ietf.org>, Fatai Zhang <zhangfatai@huawei.com>, Zhenghaomian <zhenghaomian@huawei.com>, liuzhoulong <liuzhoulong@huawei.com>, "Chenchunhui (C)" <chenchunhui@huawei.com>
Thread-Topic: [netmod] A question about YANG identifier design
Thread-Index: AQHYcBeVP8EHE60kbkCS/l/s1+e94q0wYSvA
Date: Thu, 26 May 2022 02:18:20 +0000
Message-ID: <f8c16363a212480084767be3dc6a1c59@huawei.com>
References: <de9b838f10a448c9991d0a381d426716@huawei.com> <20220524101546.cfzkzi55dsutfyic@anna> <f97fd7815d8147a680798dd5159f0594@huawei.com> <20220525072213.udkoy7lejf2qk2iq@anna> <c85dc299766941f7b3749c1572c6ccb3@huawei.com> <20220525081828.kwpbiw43ck4wizw2@anna> <9af6251a5fbe4c338bace6cccece1cde@huawei.com> <20220525083544.ymzco56byey5zt4w@anna> <86c348fb32b14dda97644c8893057588@huawei.com> <C9B52EA3-7A59-4936-B7C8-8999031A730C@tail-f.com>
In-Reply-To: <C9B52EA3-7A59-4936-B7C8-8999031A730C@tail-f.com>
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
x-originating-ip: []
Content-Type: multipart/alternative; boundary="_000_f8c16363a212480084767be3dc6a1c59huaweicom_"
MIME-Version: 1.0
X-CFilter-Loop: Reflected
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/B8hWUbngkxmurEUmzbXsB50P2io>
Subject: [netmod] 答复: A question about YANG identifier design
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 26 May 2022 02:18:32 -0000

Thank you, Jan!

Yes, for whose people who are familiar with REST paradigm, a lot of RESTCONF designs look twisted and not as flexible and straightforward as REST interface. If, as you say, these are some compromises introduced to address some other issues, it is understandable.
Returning to our previous discussion, if RESTCONF suggests to use a readable string format, like name, as identifier, it is better to provide a format constraint when designing YANG modules. I found a lot of YANG modules is lack of this job. Since name is used as an identifier, it must be globally unique. This is a difficult job, considering in different scenarios, this name could be specified by RESTCONF client and server at the same time. If the data stored in different systems is inconsistent, it is difficult to ensure that this name identifier is global unique. So usually a lot of system would prefer to use UUID for identifier.
I think, for this name identifier, systems could use UUID when doing implementation. Because UUID is also a string format. The problem is it is a little bit weird when doing integration. For example, if the name is using UUID format, the readable label must to be set to another attribute, such as alias .etc. It is not perceptible for programing interface between application, but a lot of explanation is needed when the developers begin to interact this interface.
I think when design YANG module, it is better to define an id attribute which should use UUID format and define name attribute to specify readable label. The UUID information could be hided, just like you said, when using in GUI.

发件人: Jan Lindblad [mailto:janl@tail-f.com]
发送时间: 2022年5月25日 17:12
收件人: yuchaode <yuchaode@huawei.com>
抄送: Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>; netmod@ietf.org; netconf@ietf.org; Fatai Zhang <zhangfatai@huawei.com>; Zhenghaomian <zhenghaomian@huawei.com>; liuzhoulong <liuzhoulong@huawei.com>; Chenchunhui (C) <chenchunhui@huawei.com>
主题: Re: [netmod] A question about YANG identifier design


Thank you all the same for your comments!
And I also find peaple who are designing YANG module in IETF don’t like to use uuid. They prefer to use a string for identifier. String type is generic and easy for implementation but there is not a good way to make it global unique and easy for reference.

UUIDs have many good properties for identifying objects in computer programs, but they are quite bad when presented to humans. After many years of experience with SNMP, TL/1, Corba and many other mechanisms for network management, the IETF initiative behind YANG was based on the idea to unite the human interfaces and the programming interfaces into a single model. This implies computer programs should use the same names, concepts and management structures as the humans do. This makes it easy to automate the tasks currently performed by humans.

Clearly, this is different from the Web/REST approach where a fundamental assumption is that someone is writing a user interface (web) application that works with UUIDs internally, but hides them from the user and presents some sort of human readable label for every human visible object. Nothing wrong with that, but it does not address the problem YANG was created to solve. YANG is also addressing many other issues seen historically, such as lack of transactionality. YANG's (nearly) complete interface declaration is fundamental to the model driven approach, and enables management application programming that is more than an order of magnitude faster/easier than earlier (the data I'm basing this statement on is not publicly available, I'm afraid).

To get the most value out of both worlds, you can use RESTCONF. For someone coming right out of the REST paradigm, RESTCONF will appear to have taken a few odd choices here and there, but overall I'd say it's a pretty good compromise.

Best Regards,

发件人: Jürgen Schönwälder [mailto:j.schoenwaelder@jacobs-university.de]
发送时间: 2022年5月25日 16:36
收件人: yuchaode <yuchaode@huawei.com<mailto:yuchaode@huawei.com>>
抄送: 'netmod@ietf.org<mailto:netmod@ietf.org>' <netmod@ietf.org<mailto:netmod@ietf.org>>; 'netconf@ietf.org<mailto:netconf@ietf.org>' <netconf@ietf.org<mailto:netconf@ietf.org>>; Fatai Zhang <zhangfatai@huawei.com<mailto:zhangfatai@huawei.com>>; Zhenghaomian <zhenghaomian@huawei.com<mailto:zhenghaomian@huawei.com>>; liuzhoulong <liuzhoulong@huawei.com<mailto:liuzhoulong@huawei.com>>; Chenchunhui (C) <chenchunhui@huawei.com<mailto:chenchunhui@huawei.com>>
主题: Re: 答复: 答复: 答复: [netmod] A question about YANG identifier design

I am not sure that listing specific types in a protocol specification is what I would do for a generic solution. Anyway, people who were actively involved in the design of RESTCONF should get involved in this discussion.


On Wed, May 25, 2022 at 08:31:19AM +0000, yuchaode wrote:

How about the uuid type defined in RFC6991? I think it can be globally unique.

发件人: Jürgen Schönwälder [mailto:j.schoenwaelder@jacobs-university.de]
发送时间: 2022年5月25日 16:18
收件人: yuchaode <yuchaode@huawei.com<mailto:yuchaode@huawei.com>>
抄送: 'netmod@ietf.org<mailto:netmod@ietf.org>' <netmod@ietf.org<mailto:netmod@ietf.org>>; 'netconf@ietf.org<mailto:netconf@ietf.org>'
<netconf@ietf.org<mailto:netconf@ietf.org>>; Fatai Zhang <zhangfatai@huawei.com<mailto:zhangfatai@huawei.com>>; Zhenghaomian
<zhenghaomian@huawei.com<mailto:zhenghaomian@huawei.com>>; liuzhoulong <liuzhoulong@huawei.com<mailto:liuzhoulong@huawei.com>>;
Chenchunhui (C) <chenchunhui@huawei.com<mailto:chenchunhui@huawei.com>>
主题: Re: 答复: 答复: [netmod] A question about YANG identifier design

I do not think there is currently a way to specify in YANG that a key of a list is globally unique and hence a generic protocol engine won't know which list key's have this property. I assume the current text is there to cover the case where keys are not unique and you like to drill down the data tree by processing the URL left to right.


On Wed, May 25, 2022 at 08:06:13AM +0000, yuchaode wrote:

Thank you for your reference.

That is where I think it's not reasonable. If the terminal branch list-c's identifier can be global unique, specifying its parent's and grandparent's identifier is redundant.
Certainly, if list-c and its parent and grandparent identifier could not be global unique, that could be a problem. Multiple list-c instances would be return with a same identifier.
But how about list-b's and list-a's identifier are returned at the same time when querying list-c instance, if list-b and list-c's identifier could not be global unique and are not specified when querying?

发件人: Jürgen Schönwälder
发送时间: 2022年5月25日 15:22
收件人: yuchaode <yuchaode@huawei.com<mailto:yuchaode@huawei.com>>
抄送: 'netmod@ietf.org<mailto:netmod@ietf.org>' <netmod@ietf.org<mailto:netmod@ietf.org>>; 'netconf@ietf.org<mailto:netconf@ietf.org>'
<netconf@ietf.org<mailto:netconf@ietf.org>>; Fatai Zhang <zhangfatai@huawei.com<mailto:zhangfatai@huawei.com>>;
Zhenghaomian <zhenghaomian@huawei.com<mailto:zhenghaomian@huawei.com>>; liuzhoulong
<liuzhoulong@huawei.com<mailto:liuzhoulong@huawei.com>>; Chenchunhui (C) <chenchunhui@huawei.com<mailto:chenchunhui@huawei.com>>
主题: Re: 答复: [netmod] A question about YANG identifier design

RFC 8040 says on page 27 (good old times where RFCs still had page

If a data node in the path expression is a YANG list node, then the
key values for the list (if any) MUST be encoded according to the
following rules:

And also this one:

o All of the components in the "key" statement MUST be encoded.
Partial instance identifiers are not supported.


On Wed, May 25, 2022 at 01:36:43AM +0000, yuchaode wrote:

Thank you, Jürgen!

A generic identifier design is quite good for the other generic model design, just like the hardware components design mentioned by you.
But there have been some other models defined in a nesting level already, for example network topology and TE topology etc. If we want to reference a termination-point object, we need to specify its belonging network-id and node-id.
So for this kind of model, can we retrieve or reference terminal branch objects without its trunk branch objects' identifier if the RESTCONF server can guarantee the global uniqueness of terminal branch objects' identifier.
Just like the URL I mentioned in last email:

发件人: Jürgen Schönwälder
发送时间: 2022年5月24日 18:16
收件人: yuchaode <yuchaode@huawei.com<mailto:yuchaode@huawei.com>>
抄送: 'netmod@ietf.org<mailto:netmod@ietf.org>' <netmod@ietf.org<mailto:netmod@ietf.org>>; 'netconf@ietf.org<mailto:netconf@ietf.org>'
<netconf@ietf.org<mailto:netconf@ietf.org>>; Fatai Zhang <zhangfatai@huawei.com<mailto:zhangfatai@huawei.com>>;
Zhenghaomian <zhenghaomian@huawei.com<mailto:zhenghaomian@huawei.com>>; liuzhoulong
<liuzhoulong@huawei.com<mailto:liuzhoulong@huawei.com>>; Chenchunhui (C) <chenchunhui@huawei.com<mailto:chenchunhui@huawei.com>>
主题: Re: [netmod] A question about YANG identifier design

You need to fit your data model to the data modeling language and the protocol. This can be a challenge at times but this is what it is.

From what you are writing, it seems that you try to encode the
containment relationship of hardware components into the nesting
levels of a YANG model. This is likely not a good idea to start
with and this may be the root cause of the problems you are facing.
Note how RFC 8348 defines a hardware model that is essentially a
flat list of hardware components and the containment relationship
is modeled by additional contains-child etc. leafs. This approach
gives us a simple /hardware/component/name that can be used to
refer to any hardware component easily. Sure, the downside is that
retrieving all components contained in another components is a bit
more complex but being able to reference all hardware components
in the same way likely is a big enough advantage to go for a flat
list. (And once you think about it, the containment relationship
is just one relationship, there may be others. By using a flat
list with leafs, you can model multiple


On Tue, May 24, 2022 at 09:39:21AM +0000, yuchaode wrote:

Hello friends,

I have got some puzzles about YANG model design, to be more specific, it is about the identifier design in YANG model.

As we know, YANG model is a tree-like structure, different objects are defined in different branches according their different levels. E.G. there is such a YANG tree:
module: ietf-example
+--rw root
+--rw list-a* [leaf-1]
+--rw leaf-1 yang:uuid
+--rw leaf-2? string
+--rw list-b* [leaf-3]
+--rw leaf-3 yang:uuid
+--rw leaf-4? string
+--rw list-c* [leaf-5]
+--rw leaf-5 yang:uuid
+--rw leaf-6? string
List-c is child object of list-b and list-b is child object of list-a.

If we want to retrieve a list-c instance, we need to know his parent list-b's and his grandparent list-a's identifier to construct a RESTCONF GET request URL:
However, you can easily find that the identifier of list-a, list-b and list-c are all UUID format. Usually, UUID is required to be unique globally. If the RESTCONF server complies with UUID requirement strictly, the identifier of list-b and list-a are redundant.

Similarly, if there is a YANG data model want to reference list-c in its model, the reference identifier should include list-b and list-a's identifier at the same time besides list-c's identifier. If this list-c instance repeat a lot of time in this data model, there would be a lot of redundant list-b & list-a's identifier.

Besides, this hierarchical identifier brings some problems when we are designing generic model. For example, if we want to design an alarm model, considering that the main information of alarm includes alarm ID, alarm level, tips message, location etc. which are generic for all inventory objects, it is easy for us to choose to design a generic model. For the inventory object alarm happened on, we would like to use a generic inventory resource type and resource UUID to specify. But if we use hierarchical identifier, considering alarm could be happened on NE, board or port .etc. and NE contains boards and board contains ports, we cannot use a generic identifier attribute to specify NE, board and port at the same time. For NE, we need to use one attribute to define its ne-id. And for board we need two attributes to define its id, ne-id and board-id. And for port, we need three attributes to define its id, ne-id, board-id and port-id.

So I am wondering if for those objects which are using UUID as identifier, the server should implement this UUID globally unique. When retrieving these objects, there is no necessary to specify their parent's and grandparent's identifier. Just take the list-c retrieval above for example, the URL could be changed to be:
https://{{host:port}}/{{restconf}}/data/ietf-example:root/list-a/list-b/list-c={leaf-5}<https://%7b%7bhost:port%7d%7d/%7b%7brestconf%7d%7d/data/ietf-example:root/list-a/list-b/list-c=%7bleaf-5%7d>. And for model object reference scenario, we can also use list-c's identifier only.

This is just my consideration, any comments are welcome! Thank you!


netmod mailing list

Jürgen Schönwälder Jacobs University Bremen gGmbH
Phone: +49 421 200 3587 Campus Ring 1 | 28759 Bremen | Germany
Fax: +49 421 200 3103 <https://www.jacobs-university.de/>

Jürgen Schönwälder Jacobs University Bremen gGmbH
Phone: +49 421 200 3587 Campus Ring 1 | 28759 Bremen | Germany
Fax: +49 421 200 3103 <https://www.jacobs-university.de/>

Jürgen Schönwälder Jacobs University Bremen gGmbH
Phone: +49 421 200 3587 Campus Ring 1 | 28759 Bremen | Germany
Fax: +49 421 200 3103 <https://www.jacobs-university.de/>

Jürgen Schönwälder Jacobs University Bremen gGmbH
Phone: +49 421 200 3587 Campus Ring 1 | 28759 Bremen | Germany
Fax: +49 421 200 3103 <https://www.jacobs-university.de/>
netmod mailing list