Skip to content

Commit 971b182

Browse files
committed
context UPDATE add ietf-yang-library-augmentedby support
Add the list of modules that augment a particular yang module. The modules and their augmentations are visible under the "/ietf-yang-library:yang-library xpath". Link: https://datatracker.ietf.org/doc/html/draft-ietf-netconf-yang-library-augmentedby Signed-off-by: Jeremie Leska <[email protected]>
1 parent af84dac commit 971b182

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

models/[email protected]

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
module ietf-yang-library-augmentedby {
2+
yang-version 1.1;
3+
namespace "urn:ietf:params:xml:ns:yang:ietf-yang-library-augmentedby";
4+
prefix yanglib-aug;
5+
6+
import ietf-yang-library {
7+
prefix yanglib;
8+
reference
9+
"RFC 8525: YANG Library";
10+
}
11+
12+
organization
13+
"IETF NETCONF (Network Configuration) Working Group";
14+
contact
15+
"WG Web: <https://datatracker.ietf.org/wg/netconf/>
16+
WG List: <mailto:[email protected]>
17+
18+
Author: Zhuoyao Lin
19+
20+
Benoit Claise
21+
22+
IGNACIO DOMINGUEZ MARTINEZ-CASANUEVA
23+
<matilto:[email protected]>";
24+
25+
description
26+
"This module augments the ietf-yang-library defined in
27+
[RFC8525] to provide not only the deviation list, but also
28+
the augmented-by list, in order to give sufficient
29+
information about the YANG modules reverse dependency. It
30+
facilitates the process of obtaining the entire
31+
dependencies of YANG module.
32+
33+
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
34+
'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
35+
'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
36+
are to be interpreted as described in BCP 14 (RFC 2119)
37+
(RFC 8174) when, and only when, they appear in all
38+
capitals, as shown here.
39+
40+
Copyright (c) 2022 IETF Trust and the persons identified as
41+
authors of the code. All rights reserved.
42+
43+
Redistribution and use in source and binary forms, with or
44+
without modification, is permitted pursuant to, and subject
45+
to the license terms contained in, the Revised BSD License
46+
set forth in Section 4.c of the IETF Trust's Legal Provisions
47+
Relating to IETF Documents
48+
(https://trustee.ietf.org/license-info).
49+
This version of this YANG module is part of RFC XXXX; see the
50+
RFC itself for full legal notices. ";
51+
52+
revision 2023-10-27 {
53+
description
54+
"Added list augmented-by in yang-library/module-set/module to
55+
make the module store the entire reverse dependency information
56+
(augmented-by and deviation).";
57+
reference
58+
"RFC XXXX: Support of augmentedby in ietf-yang-library";
59+
}
60+
61+
augment "/yanglib:yang-library/yanglib:module-set/yanglib:module" {
62+
description
63+
"Augment the augmented-by list from module info with the
64+
module-augmented-by grouping" ;
65+
66+
leaf-list augmented-by {
67+
type leafref {
68+
path "../../yanglib:module/yanglib:name";
69+
}
70+
71+
description
72+
"Leaf-list of the augmentation used by this server to
73+
modify the conformance of the module associated with
74+
this entry. Note that the same module can be used for
75+
augmented-by for multiple modules, so the same
76+
entry MAY appear within multiple 'module' entries.
77+
78+
This reference MUST NOT (directly or indirectly)
79+
refer to the module being augmented.
80+
81+
Robust clients may want to make sure that they handle a
82+
situation where a module augments itself (directly or
83+
indirectly) gracefully.";
84+
}
85+
}
86+
}

src/context.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,26 @@ ylib_deviation(struct lyd_node *parent, const struct lys_module *cur_mod, ly_boo
11581158
return LY_SUCCESS;
11591159
}
11601160

1161+
static LY_ERR
1162+
ylib_augmentedby(struct lyd_node *parent, const struct lys_module *cur_mod)
1163+
{
1164+
struct lys_module *mod, *ylab_mod;
1165+
LY_ARRAY_COUNT_TYPE i;
1166+
1167+
ylab_mod = ly_ctx_get_module_implemented(LYD_CTX(parent), "ietf-yang-library-augmentedby");
1168+
1169+
if (!cur_mod->implemented || !ylab_mod) {
1170+
return LY_SUCCESS;
1171+
}
1172+
1173+
LY_ARRAY_FOR(cur_mod->augmented_by, i) {
1174+
mod = cur_mod->augmented_by[i];
1175+
LY_CHECK_RET(lyd_new_term(parent, ylab_mod, "augmented-by", mod->name, 0, NULL));
1176+
}
1177+
1178+
return LY_SUCCESS;
1179+
}
1180+
11611181
static LY_ERR
11621182
ylib_submodules(struct lyd_node *parent, const struct lysp_module *pmod, ly_bool bis)
11631183
{
@@ -1303,6 +1323,9 @@ ly_ctx_get_yanglib_data(const struct ly_ctx *ctx, struct lyd_node **root_p, cons
13031323

13041324
/* deviation */
13051325
LY_CHECK_GOTO(ret = ylib_deviation(cont, mod, 1), error);
1326+
1327+
/* augmentation list */
1328+
LY_CHECK_GOTO(ret = ylib_augmentedby(cont, mod), error);
13061329
}
13071330
}
13081331

0 commit comments

Comments
 (0)