From 0bf838eb8c3d8f1d69ac796b22af3e425977502e Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 19 Mar 2019 11:55:44 +0100 Subject: [PATCH] added module-revision Yang --- doc/startup.md | 16 +- lib/src/clixon_yang.c | 2 +- yang/standard/Makefile.in | 1 + .../ietf-module-revision@2018-08-08.yang | 392 ++++++++++++++++++ 4 files changed, 401 insertions(+), 10 deletions(-) create mode 100644 yang/standard/ietf-module-revision@2018-08-08.yang diff --git a/doc/startup.md b/doc/startup.md index c8b755f8..c3a18b0f 100644 --- a/doc/startup.md +++ b/doc/startup.md @@ -196,7 +196,7 @@ syntax errors or invalidated XML. ## Repair -If the system is in the failsafe mode (or fails to start), a user can +If the system is in failsafe mode (or fails to start), a user can repair a broken configuration and then restart the backend. This can be done out-of-band by editing the startup db and then restarting clixon. @@ -207,7 +207,7 @@ shows how to repair a startup datastore on-line. However, on-line repair _cannot_ be made in the following circumstances: * The broken configuration contains syntactic errors - the system cannot parse the XML. -* The startup mode is `running`. In this case, the broken config is in the `tmp` datastore that is not a recognized Netconf datastore, it has to be accessed out-of-band. +* The startup mode is `running`. In this case, the broken config is in the `tmp` datastore that is not a recognized Netconf datastore, and has to be accessed out-of-band. * Netconf must be used. Restconf cannot separately access the different datastores. First, copy the (broken) startup config to candidate. This is necessary since you cannot make `edit-config` calls to the startup db: @@ -233,7 +233,7 @@ For example, assume `x` is obsolete syntax, then this is _not_ accepted: ``` -Instead, assuming `y` is a valid syntax, this is allowed (`x` is not explicitly accessed): +Instead, assuming `y` is a valid syntax, the following operation is allowed since `x` is not explicitly accessed: ``` @@ -252,7 +252,7 @@ Finally, the candidate is validate and committed: ``` -This example is also used as a [test script](../test/test_upgrade_repair.sh). +The example shown in this Section is also available as a regression [test script](../test/test_upgrade_repair.sh). ## Flowcharts @@ -261,14 +261,14 @@ the configuration databases in the startup phase. The flowchart starts in one of the modes (none, init, startup, running): -### init mode +### Init mode ``` reset running |--------+------------> GOTO EXTRA XML ``` -### running mode +### Running mode ``` running ----+ |----------+--------> GOTO EXTRA XML @@ -277,7 +277,7 @@ tmp ------+-------+------+-----------+ ``` -### startup mode +### Startup mode ``` reset running |--------+------------> GOTO EXTRA XML @@ -313,8 +313,6 @@ candidate +---------------------> CANDIDATE repair restart tmp/startup --------+---------+-----------------------> - - ## Thanks Thanks matt smith and dave cornejo for input diff --git a/lib/src/clixon_yang.c b/lib/src/clixon_yang.c index f4d93e15..bd709907 100644 --- a/lib/src/clixon_yang.c +++ b/lib/src/clixon_yang.c @@ -716,7 +716,7 @@ yang_order(yang_stmt *y) ypp = yp->yn_parent; /* yang spec */ for (i=0; iyn_len; i++){ /* iterate through other modules */ ym = ypp->yn_stmt[i]; - if (yp == ym) + if (yp == (yang_node*)ym) break; tot += ym->ys_len; } diff --git a/yang/standard/Makefile.in b/yang/standard/Makefile.in index 6da576ae..288c1c6a 100644 --- a/yang/standard/Makefile.in +++ b/yang/standard/Makefile.in @@ -52,6 +52,7 @@ YANGSPECS += ietf-netconf@2011-06-01.yang YANGSPECS += ietf-netconf-acm@2018-02-14.yang YANGSPECS += ietf-restconf-monitoring@2017-01-26.yang YANGSPECS += ietf-netconf-monitoring@2010-10-04.yang +YANGSPECS += ietf-module-revision@2018-08-08.yang all: diff --git a/yang/standard/ietf-module-revision@2018-08-08.yang b/yang/standard/ietf-module-revision@2018-08-08.yang new file mode 100644 index 00000000..b7b6b7a1 --- /dev/null +++ b/yang/standard/ietf-module-revision@2018-08-08.yang @@ -0,0 +1,392 @@ +module ietf-module-revision { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:ietf-module-revision"; + prefix ml; + + import ietf-yang-library { + prefix yanglib; + } + import ietf-yang-types { + prefix yang; + } + + organization + "IETF Network Modeling (NETMOD) Working Group"; + contact + "WG Web: + + WG List: + + Author: Qin Wu + + Zitao Wang + "; + description + "This YANG module defines an module log."; + + revision 2018-08-08 { + description + "Initial revision."; + reference "RFC XXXX: Using Metadata with YANG for Module revisions"; + } + + identity operation-type { + description + "Abstract base identity for the operation type "; + } + + identity create { + base operation-type; + description + "Denotes create new data nodes"; + } + + identity delete { + base operation-type; + description + "Denotes delete the target node"; + } + + identity move { + base operation-type; + description + "Denote move the target node."; + } + + identity modify { + base operation-type; + description + "Denote modify the target data node."; + } + + identity statement-type { + description + "Base identity for statement type"; + } + + identity feature-statement { + base statement-type; + description + "feature statement, if this type be chose, it means that the + feature or if-feature statement been modified"; + } + identity identity-statement { + base statement-type; + description + "identity statement, if this type be chose, it means that the + identity statement been modified, for example, add new identity, etc."; + } + + identity grouping-statement { + base statement-type; + description + "grouping statement, if this type be chose, it means that the grouping + statement been modified."; + } + + identity typedef-statement { + base statement-type; + description + "typedef statement, if this type be chose, it means that the typedef + statement been modified."; + } + + identity augment-statement { + base statement-type; + description + "augment statement, if this type be chose, it means that the augment + statement been modified."; + } + + identity rpc-statement { + base statement-type; + description + "rpc statement, if this type be chose, it means that the rpc + statement been modified."; + } + + identity notification-statement { + base statement-type; + description + "notification statement, if this type be chose, it means that the notification + statement been modified."; + } + + extension purpose { + argument name; + description + "The purpose can be used to mark the data nodes change purpose. + The name argument can be specified in the following recommended mode + - bug-fix, which can help user to understand the data nodes' changes present bug fix, + - new-function, which can help user to understand the data nodes' changes present new function, + - nmda-conform, which can help user to understand the data nodes' changes conform to NMDA, + + and note that the user can argument the purpose name according to their sepcific requirements."; + } + + grouping data-definition { + container data-definition { + leaf target-node { + type yang:xpath1.0; + mandatory true; + description + "Identifies the target data node for update. + Notice that, if the update-type equal to move or delete, + this target-node must point to the data node of old version. + \t + For example, suppose the target node is a YANG leaf named a, + and the previous version is: + \t + container foo { + leaf a { type string; } + leaf b { type int32; } + } + \t + the new version is: + container foo { + leaf b {type int32;} + } + \t + Therefore, the targe-node should be /foo/a."; + } + leaf location-point { + type yang:xpath1.0; + description + "Identifies the location point where the updates happened."; + } + leaf where { + when "derived-from-or-self(../../change-operation, 'move')" { + description + "This leaf only applies for 'move' + updates."; + } + type enumeration { + enum "before" { + description + "Insert or move a data node before the data resource + identified by the 'point' parameter."; + } + enum "after" { + description + "Insert or move a data node after the data resource + identified by the 'point' parameter."; + } + enum "first" { + description + "Insert or move a data node so it becomes ordered + as the first entry."; + } + enum "last" { + description + "Insert or move a data node so it becomes ordered + as the last entry."; + } + } + default "last"; + description + "Identifies where a data resource will be inserted + or moved."; + } + anydata data-definition { + when "derived-from-or-self(../../change-operation, 'modify')" { + description + "This nodes only be present when + the 'change-operation' equal to 'modify'."; + } + description + "This nodes used for present the definitions before updated. + And this nodes only be present when + the 'change-operation' equal to 'modify'."; + } + description + "Container for data statement"; + } + description + "Grouping for data definition"; + } + + grouping other-statement { + container other-statement { + leaf statement-name { + type identityref { + base statement-type; + } + description + "Statement name, for example, identity, feature, typedef, etc."; + } + anydata statement-definition { + description + "This nodes used for present new the definitions."; + } + list substatements { + key "statement-name"; + leaf statement-name { + type identityref { + base statement-type; + } + description + "Statement name, for example, identity, feature, typedef, etc."; + } + anydata substatement-definition { + description + "This nodes used for present new the definitions."; + } + description + "List for substatements updates"; + } + description + "Container for header statement updates"; + } + description + "Grouping for header statement"; + } + + grouping change-log { + list revision-change-log { + key "index"; + leaf index { + type uint32; + description + "Index for module change log"; + } + leaf change-operation { + type identityref { + base operation-type; + } + mandatory true; + description + "This leaf indicate the change operation, such as create, move, delete, modify, etc."; + } + choice yang-statements { + description + "Choice for various YANG statements that have been impacted."; + case data-definition-statement { + uses data-definition; + } + case other-statement { + uses other-statement; + } + } + description + "List for module revision change log"; + } + description + "Grouping for module revision change log"; + } + + container yang-modules { + config false; + list module { + key "name revision"; + leaf name { + type yang:yang-identifier; + description + "The YANG module or submodule name."; + } + leaf revision { + type yanglib:revision-identifier; + description + "The YANG module or submodule revision date. If no revision + statement is present in the YANG module or submodule, this + leaf is not instantiated."; + } + leaf backward-compatible { + type boolean; + description + "Indicates whether it is a backward compatible version. + If this parameter is set to true, it means that this version is + a backwards compatible version"; + } + uses change-log; + description + "List for module updated log"; + } + description + "This container present the modules updated log."; + } + augment "/yanglib:yang-library/yanglib:module-set/yanglib:module" { + description + "Augment the yang library with backward compatibility indication."; + leaf backward-compatible { + type boolean; + description + "backward compatibility indication."; + } + } + augment "/yanglib:yang-library/yanglib:module-set/yanglib:module/yanglib:submodule" { + description + "Augment the yang library with backward compatibility indication."; + leaf backward-compatible { + type boolean; + description + "backward compatibility indication."; + } + } + rpc module-revision-change { + description + "Module Node change query operation."; + input { + leaf source-module-name { + type yang:yang-identifier; + mandatory true; + description + "The Source YANG module or submodule name."; + } + leaf source-revision { + type yanglib:revision-identifier; + description + "The Source YANG module revision date. If no revision + statement is present in the YANG module or submodule, this + leaf is not instantiated."; + } + leaf target-module-name { + type yang:yang-identifier; + mandatory true; + description + "The Target YANG module or submodule name."; + } + leaf target-revision { + type yanglib:revision-identifier; + description + "The target YANG module revision date. If no revision + statement is present in the YANG module or submodule, this + leaf is not instantiated."; + } + } + output { + choice status-response{ + leaf wrong-match{ + type empty; + description + "This leaf indicates that two modules have nothing in common."; + } + list data-nodes { + key "data-node-name"; + description + "Each entry represents a data node of a given module that + have been changed from source revision of + a module to target revision of the module."; + leaf data-node-name { + type string; + description + "a data node name of a given module that + has been changed."; + } + leaf is-new-node { + type boolean; + description + "indicate the data node is newly introduced node in the target revision."; + } + leaf change-operation { + type identityref { + base operation-type; + } + description + "This leaf indicate the change operation, + such as create, move, delete, modify, etc."; + } + } + } + } + } +}