Skip to content

Commit daf06b4

Browse files
committed
schema diff UPDATE generate submodule information
1 parent c05a66f commit daf06b4

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

modules/[email protected]

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ module ietf-schema-comparison {
8989
"Type of the statement that a change affects.";
9090
}
9191

92+
typedef revision-or-empty {
93+
type union {
94+
type empty;
95+
type yanglib:revision-identifier;
96+
}
97+
description
98+
"Module or submodule revision. If it has none, an empty value is used.";
99+
}
100+
92101
grouping ext-instance-changes {
93102
description
94103
"Describes an extension-instance statement change.";
@@ -582,14 +591,28 @@ module ietf-schema-comparison {
582591
"Compared module name.";
583592
}
584593
leaf revision {
585-
type union {
586-
type empty;
587-
type yanglib:revision-identifier;
588-
}
594+
type revision-or-empty;
589595
mandatory true;
590596
description
591597
"Compared module revision.";
592598
}
599+
list submodule {
600+
key "name revision";
601+
leaf name {
602+
type yang:yang-identifier;
603+
mandatory true;
604+
description
605+
"Submodule name.";
606+
}
607+
leaf revision {
608+
type revision-or-empty;
609+
mandatory true;
610+
description
611+
"Submodule revision.";
612+
}
613+
description
614+
"Submodule of the main module.";
615+
}
593616
leaf-list enabled-feature {
594617
type yang:yang-identifier;
595618
description
@@ -679,12 +702,12 @@ module ietf-schema-comparison {
679702
uses change-info;
680703
container old {
681704
description
682-
"Changed statements in the older revision of the YANG module.";
705+
"All the node substatements in the older revision of the YANG module.";
683706
uses node-changes;
684707
}
685708
container new {
686709
description
687-
"Changed statements in the newer revision of the YANG module.";
710+
"All the node substatements in the newer revision of the YANG module.";
688711
uses node-changes;
689712
}
690713
}

src/schema_diff_tree.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,33 @@ schema_diff_enabled_features(const struct lys_module *mod, struct lyd_node *pare
12301230
return LY_SUCCESS;
12311231
}
12321232

1233+
/**
1234+
* @brief Create list of submodules of the module as part of cmp YANG data.
1235+
*
1236+
* @param[in] mod Module to use.
1237+
* @param[in,out] parent Node to append to.
1238+
* @return LY_ERR value.
1239+
*/
1240+
static LY_ERR
1241+
schema_diff_submodules(const struct lys_module *mod,struct lyd_node *parent)
1242+
{
1243+
LY_ERR rc = LY_SUCCESS;
1244+
LY_ARRAY_COUNT_TYPE u;
1245+
const struct lysp_submodule *submod;
1246+
const char *revision;
1247+
1248+
LY_ARRAY_FOR(mod->parsed->includes, u) {
1249+
submod = mod->parsed->includes[u].submodule;
1250+
1251+
/* add the includes */
1252+
revision = submod->revs ? submod->revs[0].date : NULL;
1253+
LY_CHECK_GOTO(rc = lyd_new_list(parent, NULL, "submodule", 0, NULL, submod->name, revision), cleanup);
1254+
}
1255+
1256+
cleanup:
1257+
return rc;
1258+
}
1259+
12331260
/**
12341261
* @brief Create cmp YANG data from module imports.
12351262
*
@@ -1264,6 +1291,8 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
12641291
/* add the imports, recursively */
12651292
LY_CHECK_GOTO(rc = lyd_new_list(diff_list, NULL, schema->name, 0, &mod_list, imp->name, imp->revision), cleanup);
12661293
LY_CHECK_GOTO(rc = schema_diff_enabled_features(imp, mod_list), cleanup);
1294+
LY_CHECK_GOTO(rc = schema_diff_submodules(imp, mod_list), cleanup);
1295+
12671296
LY_CHECK_GOTO(rc = schema_diff_imports(imp, schema, diff_list), cleanup);
12681297
}
12691298

@@ -2049,6 +2078,7 @@ lysc_diff_tree(const struct lys_module *mod1, const struct lys_module *mod2, con
20492078
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "module", mod1->name, 0, NULL), cleanup);
20502079
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "revision", mod1->revision, 0, NULL), cleanup);
20512080
LY_CHECK_GOTO(rc = schema_diff_enabled_features(mod1, mod_cont), cleanup);
2081+
LY_CHECK_GOTO(rc = schema_diff_submodules(mod1, mod_cont), cleanup);
20522082

20532083
imp_schema = lys_find_path(NULL, diff_list->schema, "source-import", 0);
20542084
LY_CHECK_GOTO(rc = schema_diff_imports(mod1, imp_schema, diff_list), cleanup);
@@ -2058,6 +2088,7 @@ lysc_diff_tree(const struct lys_module *mod1, const struct lys_module *mod2, con
20582088
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "module", mod2->name, 0, NULL), cleanup);
20592089
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "revision", mod2->revision, 0, NULL), cleanup);
20602090
LY_CHECK_GOTO(rc = schema_diff_enabled_features(mod2, mod_cont), cleanup);
2091+
LY_CHECK_GOTO(rc = schema_diff_submodules(mod2, mod_cont), cleanup);
20612092

20622093
imp_schema = lys_find_path(NULL, diff_list->schema, "target-import", 0);
20632094
LY_CHECK_GOTO(rc = schema_diff_imports(mod2, imp_schema, diff_list), cleanup);

0 commit comments

Comments
 (0)