Re: [netconf] [netmod] A question about YANG identifier design

Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de> Tue, 24 May 2022 10:15 UTC

Return-Path: <J.Schoenwaelder@jacobs-university.de>
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 553E3C14F723; Tue, 24 May 2022 03:15:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=jacobsuniversity.onmicrosoft.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PLe13aRQhq7t; Tue, 24 May 2022 03:15:54 -0700 (PDT)
Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2053.outbound.protection.outlook.com [40.107.20.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 651C3C14F720; Tue, 24 May 2022 03:15:52 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=atxfx+iMF1GzFzxRJBIbV93ODRlUJM9waYYXEpCZCseRXtj5i3atvP6PvowU59CXc9Ik0sco8xJPYGeYocx9pvaQEbekJbwzhYL2ILd8sbML7OmjrK5OM+5Z2kMu0OgRL9WUqTJxRoEzYPWWma4d41/qDayOPhq5ywIPDsvtrSlmYy1HN4hy6sc9yboocedIwZQpIfwJqZ0lGMxat7BJLaifgYo3S9vp230/dqejhRV9Eat1X/QfDc4dhx6WhvIQHeGwVNM2GOpHsn6Ti04v4hDvP0417Qde+TACltUETBTkdVvUXsjSFSwHrMwhuCQirJCSmogopOMKCZ5WgkzUJw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eahAQAq5I2RgSpGf8NCc+xqXvfBtLZW4bSSNqS5GCkU=; b=WB0PsIiL1/Jo7UbaZyhX9C5ah0h+R6ZXpANM+Vb7FaTGhjy9z5z/YgnIx2A+3X/QZDYH2dpfOHm08xwuEzdAJwzSUlOVdtP6qTnqvzEZ+uY6BLq8NfCg0bQGauBlFvmgUeCbrFGAAfZFtjhEAtVcTlm2LuMaM8biPtEM7f+iPeRDQNUvxoxcqCjMivQRrKAPxMmqNvCSVN0iizhqjXEMR0j4NoLtwjwbpkbk4fjzcUUOiCg2usiWza9EpyuAklzdZCiTcGPOAyBgoplWElr7MVLVjfcBb8NTp/Q9vFGU8YCuNLP+JIh0EJg3fomCqKJCtzcbV8WnmRHg+JTyeN6HFQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jacobs-university.de; dmarc=pass action=none header.from=jacobs-university.de; dkim=pass header.d=jacobs-university.de; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jacobsuniversity.onmicrosoft.com; s=selector2-jacobsuniversity-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eahAQAq5I2RgSpGf8NCc+xqXvfBtLZW4bSSNqS5GCkU=; b=jmQ36dbKphZkWn5D56Tb4fibw3BcESz26o+IFI2yhNWflvYvnJ7GB4Kedc6SeDFrqAT1+erZUObRbnYGf9DZ/VDZtR6lKDyz8XixU2PBwMkEao1ZpmFS8mHroVifs3O6JjF0kwnbIDLg9kwDbkyml99WtbTcYibk4RbZs8oq8iw=
Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jacobs-university.de;
Received: from GVXP190MB1991.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:3::6) by PRAP190MB1738.EURP190.PROD.OUTLOOK.COM (2603:10a6:102:27b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5273.22; Tue, 24 May 2022 10:15:48 +0000
Received: from GVXP190MB1991.EURP190.PROD.OUTLOOK.COM ([fe80::64d3:b182:f717:5176]) by GVXP190MB1991.EURP190.PROD.OUTLOOK.COM ([fe80::64d3:b182:f717:5176%9]) with mapi id 15.20.5273.022; Tue, 24 May 2022 10:15:48 +0000
Date: Tue, 24 May 2022 12:15:46 +0200
From: Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>
To: yuchaode <yuchaode=40huawei.com@dmarc.ietf.org>
Cc: "'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>
Message-ID: <20220524101546.cfzkzi55dsutfyic@anna>
Reply-To: Jürgen Schönwälder <j.schoenwaelder@jacobs-university.de>
Mail-Followup-To: yuchaode <yuchaode=40huawei.com@dmarc.ietf.org>, "'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>
References: <de9b838f10a448c9991d0a381d426716@huawei.com>
Content-Type: text/plain; charset="utf-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <de9b838f10a448c9991d0a381d426716@huawei.com>
X-ClientProxiedBy: AM0PR10CA0044.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::24) To GVXP190MB1991.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:3::6)
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-Office365-Filtering-Correlation-Id: 84301c2b-0a08-4f79-c793-08da3d6e5f39
X-MS-TrafficTypeDiagnostic: PRAP190MB1738:EE_
X-Microsoft-Antispam-PRVS: <PRAP190MB1738B9BE9D49AC2432094488DED79@PRAP190MB1738.EURP190.PROD.OUTLOOK.COM>
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
X-Microsoft-Antispam-Message-Info: zEmK0UOnBV9TdmtYJ4vtL6VeVH7YN79Zx3nyYmm/ad/Ec1YwYm4rI63CQsMQTb1T5N+wsyZ1eDMDdmEeS8GHxg7I4YYDzV4wthtXtR5ZMTuHMQsRg7yZee56CtKrHKrUUAOg/tUeBeW5juZx9vqwEOQ45U5xPNKeSiK/DwEDsLpjTaoBj20t8KEP7NJzF43VppO23vPAn2xlGJQ75YU60L3G6h4WGPTdKO2mvOzuwtlK7oYuOysQdEAjcPXdW4NOz16enQdITab1t0lO69GLt1xcYa1Fl1S0fbtK/SehRbIl/6r1ciABbcSYRgzt90qPN+PacFni19idnlfRpS0hvSagUUw0Ft4vRZl+d57qqWqzo2ppfX4n8Z+MmtMtzllN6V88/5t9hdec8UvHwtf75ltw+eSZjRmccCul/lqSy8TQVqkkz4jSa0E+gNFPxLnA/11TFqtmoMhCslLtS6Ko3pWJuSBIj90B8c9AtpbNaNHBnpGo8e1aK5w7n3KE2m5Ga9kwzpDKfhX5k2CZZOTZg7c9lO3CUK0bFmM6dIUF6gBtKOaNWMegPlX9kE44xTmAVfZVUeM/wUxDmMfZKunAj6zaFKqaYQ+J9886m7zmynJjD/jTwORaSIYZAGB4Qk6Xq7s8OHoSE/OOkOA25QjgLSa2vxqzyR49pjJU9qAjwX89jzwhNe+MtFjB1IWPl8cn++VAx+94jUdf2+zrzDxjtNWtUQ1TdCiG0kclPijKQ5NDm2ENcpfD77gr/aOkmCsagakHWK9QdBjtJ663jJ7SiMPuJQXFrxzGwRTwebM/iImzv/apkzzcKuwAMSwe3tWrj8OQp1bVJr2GU478AwCEsw==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GVXP190MB1991.EURP190.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(7916004)(366004)(33716001)(8936002)(66556008)(66946007)(83380400001)(8676002)(66476007)(86362001)(508600001)(38100700002)(4326008)(40140700001)(6486002)(966005)(2906002)(38350700002)(26005)(316002)(6512007)(9686003)(786003)(54906003)(1076003)(85202003)(66574015)(52116002)(5660300002)(3450700001)(6506007)(85182001)(186003); DIR:OUT; SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: uGyLP7Y+RSNZVM1AyVSwWmf7wcQ4nKoAKaeKDjyYi5zDVVastgkxiba7TqnjTKdqnrYKDUDXC7gvV65c81WSxsaN8e3e+Hg51jQ3TAXlZvMPvfhLiOEC/3UqGk46TKXuD8brdxUkGv9nv3tdhLnCSTpaiZLSwvAWF7lkU4wLIdLnxHn3kwvBEel1UPsrcLpo36SqiKPEaPoM8a9fbK8UNKpLVlHmnn33Df02ZBhSB5LVmwGdm3xGB70e41s6fmX0ccisaYurNnt2Py2Pa+kVvhgybOerDHAwDxIgz3bu8cVFgbsGRVha8zKwd3tw8mlUv5fJ3u403rRm23SRSmuswsIe/PiwNQCo6rDV+KMEk58p+1Ala5TbiePSJyIXgj98XBUODYv9Hmt13WCdHsKCy1D466xbNNa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s4hExISJdh9zdtiBbd9cBymPUAODzwXa54uk0E5MUQ7tvxoYQ66a6IGablMRePv7XQ+TTZc1DwGnD0Cs4yVju1+0ev76N4+DqQQfakHzToCCeyf2Qwq1O3G+vZz1TRlPaosoWQVuBxAsUtbXGcJt/SXB57s0GYJvfzsZy+khE8/7Xdmi1wy5qaXHTz0KaUW2JAbCR6Jm/yg4enXFHGho+4FHaOGwuy11/C+MtoYHvBSNid9VV9dmDd8iM9u6lB0ey66qPP8riAXYASR8ACvPEHkfvnU52keek+Zl17/0ik3r7Lnrw4
X-OriginatorOrg: jacobs-university.de
X-MS-Exchange-CrossTenant-Network-Message-Id: 84301c2b-0a08-4f79-c793-08da3d6e5f39
X-MS-Exchange-CrossTenant-AuthSource: GVXP190MB1991.EURP190.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2022 10:15:48.1696 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: f78e973e-5c0b-4ab8-bbd7-9887c95a8ebd
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: zoOpW6GlgqtRUhFP6Rx7m6ETCMZLIdpJpnTKJpb1CcYFL66Bc+f9T7sBEIy7D2hiarsVg25cSHIMVXOnUEs7gfdb1UMnp/HMEgKNu67Y4yI=
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PRAP190MB1738
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/TkITESbF9RJG80uI4aGIYIgtcn0>
Subject: Re: [netconf] [netmod] A question about YANG identifier design
X-BeenThere: netconf@ietf.org
X-Mailman-Version: 2.1.34
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: Tue, 24 May 2022 10:15:58 -0000

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

/js

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:
> https://{{host:port}}/{{restconf}}/data/ietf-example:root/list-a={leaf-1}/list-b={leaf-3}/list-c={leaf-5}.
> 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!
> 
> B.R.
> Chaode
> 

> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod


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