diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ac9f2a9..ef8aad59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Major changes: ### Minor changes: +* Experimental: Added CLICON_TRANSACTION_MOD configurqation option. If set, + modifications in validation and commit callbacks are written back + into the datastore. * Invalid key to api_path2xml gives warning instead of error and quit. * Added restconf/operations get, see RFC8040 Sec 3.3.2: * yang_find_topnode() and api_path2xml() schemanode parameter replaced with yang_class. Replace as follows: 0 -> YC_DATANODE, 1 -> YC_SCHEMANODE diff --git a/apps/backend/backend_commit.c b/apps/backend/backend_commit.c index 73753b63..ef73adf2 100644 --- a/apps/backend/backend_commit.c +++ b/apps/backend/backend_commit.c @@ -239,13 +239,20 @@ candidate_commit(clicon_handle h, if (plugin_transaction_commit(h, td) < 0) goto done; - /* 8. Success: Copy candidate to running */ + /* Optionally write (potentially modified) tree back to candidate */ + if (clicon_option_bool(h, "CLICON_TRANSACTION_MOD")) + if (xmldb_put(h, candidate, OP_REPLACE, td->td_target) < 0) + goto done; + /* 8. Success: Copy candidate to running + */ + if (xmldb_copy(h, candidate, "running") < 0) goto done; /* 9. Call plugin transaction end callbacks */ plugin_transaction_end(h, td); + /* 8. Copy running back to candidate in case end functions updated running */ if (xmldb_copy(h, "running", candidate) < 0){ /* ignore errors or signal major setback ? */ @@ -392,6 +399,10 @@ from_client_validate(clicon_handle h, clicon_err_reason); goto ok; } + /* Optionally write (potentially modified) tree back to candidate */ + if (clicon_option_bool(h, "CLICON_TRANSACTION_MOD")) + if (xmldb_put(h, "candidate", OP_REPLACE, td->td_target) < 0) + goto done; cprintf(cbret, ""); ok: retval = 0; diff --git a/yang/clixon-config@2018-02-12.yang b/yang/clixon-config@2018-02-12.yang index 883a002f..3bcc0ce2 100644 --- a/yang/clixon-config@2018-02-12.yang +++ b/yang/clixon-config@2018-02-12.yang @@ -300,5 +300,11 @@ module clixon-config { type startup_mode; description "Which method to boot/start clicon backend"; } + leaf CLICON_TRANSACTION_MOD { + type boolean; + default false; + description "If set, modifications in validation and commit + callbacks will be saved into running"; + } } }