* Clixon transaction mechanism has changed which may affect your backend plugin callbacks:

* Validate-only transactions are terminated by an `end` or `abort` callback.
* If a commit user callback fails, a new `revert` callback will be made to plugins that have made a succesful commit.
This commit is contained in:
Olof hagsand 2019-05-10 14:35:34 +02:00
parent 99b7a1fe5b
commit b103599a1a
9 changed files with 422 additions and 87 deletions

View file

@ -85,8 +85,7 @@ main_begin(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "begin");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
/*! This is called on validate (and commit). Check validity of candidate
@ -96,7 +95,7 @@ main_validate(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "validate");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
@ -105,7 +104,7 @@ main_complete(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "complete");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
@ -113,7 +112,7 @@ main_complete(clicon_handle h,
*/
int
main_commit(clicon_handle h,
transaction_data td)
transaction_data td)
{
cxobj *target = transaction_target(td); /* wanted XML tree */
cxobj **vec = NULL;
@ -121,7 +120,8 @@ main_commit(clicon_handle h,
size_t len;
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "commit");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
/* Get all added i/fs */
if (xpath_vec_flag(target, "//interface", XML_FLAG_ADD, &vec, &len) < 0)
return -1;
@ -134,12 +134,21 @@ main_commit(clicon_handle h,
return 0;
}
int
main_revert(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
int
main_end(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "end");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
@ -148,7 +157,7 @@ main_abort(clicon_handle h,
transaction_data td)
{
if (_transaction_log)
transaction_log(h, td, LOG_NOTICE, "abort");
transaction_log(h, td, LOG_NOTICE, __FUNCTION__);
return 0;
}
@ -568,6 +577,7 @@ static clixon_plugin_api api = {
.ca_trans_validate=main_validate, /* trans validate */
.ca_trans_complete=main_complete, /* trans complete */
.ca_trans_commit=main_commit, /* trans commit */
.ca_trans_revert=main_revert, /* trans revert */
.ca_trans_end=main_end, /* trans end */
.ca_trans_abort=main_abort /* trans abort */
};
@ -594,7 +604,7 @@ clixon_plugin_init(clicon_handle h)
goto done;
opterr = 0;
optind = 1;
while ((c = getopt(argc, argv, "rsut")) != -1)
while ((c = getopt(argc, argv, "rsut:")) != -1)
switch (c) {
case 'r':
_reset = 1;