Move validation flag to include diff
This commit is contained in:
parent
48a7eac096
commit
fe8636bb77
2 changed files with 17 additions and 20 deletions
|
|
@ -465,6 +465,7 @@ startup_commit(clicon_handle h,
|
||||||
* @param[in] h Clicon handle
|
* @param[in] h Clicon handle
|
||||||
* @param[in] db The (candidate) database. The wanted backend state
|
* @param[in] db The (candidate) database. The wanted backend state
|
||||||
* @param[in] td Transaction data
|
* @param[in] td Transaction data
|
||||||
|
* @param[in] vlev Validation level (0: full validation)
|
||||||
* @param[out] xret Error XML tree, if retval is 0. Free with xml_free after use
|
* @param[out] xret Error XML tree, if retval is 0. Free with xml_free after use
|
||||||
* @retval 1 Validation OK
|
* @retval 1 Validation OK
|
||||||
* @retval 0 Validation failed (with xret set)
|
* @retval 0 Validation failed (with xret set)
|
||||||
|
|
@ -477,6 +478,7 @@ static int
|
||||||
validate_common(clicon_handle h,
|
validate_common(clicon_handle h,
|
||||||
char *db,
|
char *db,
|
||||||
transaction_data_t *td,
|
transaction_data_t *td,
|
||||||
|
validate_level vlev,
|
||||||
cxobj **xret)
|
cxobj **xret)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
@ -544,6 +546,7 @@ validate_common(clicon_handle h,
|
||||||
if (plugin_transaction_begin_all(h, td) < 0)
|
if (plugin_transaction_begin_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
if (vlev == VL_FULL){
|
||||||
/* 5. Make generic validation on all new or changed data.
|
/* 5. Make generic validation on all new or changed data.
|
||||||
Note this is only call that uses 3-values */
|
Note this is only call that uses 3-values */
|
||||||
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
if ((ret = generic_validate(h, yspec, td, xret)) < 0)
|
||||||
|
|
@ -554,6 +557,7 @@ validate_common(clicon_handle h,
|
||||||
/* 6. Call plugin transaction validate callbacks */
|
/* 6. Call plugin transaction validate callbacks */
|
||||||
if (plugin_transaction_validate_all(h, td) < 0)
|
if (plugin_transaction_validate_all(h, td) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* 7. Call plugin transaction complete callbacks */
|
/* 7. Call plugin transaction complete callbacks */
|
||||||
if (plugin_transaction_complete_all(h, td) < 0)
|
if (plugin_transaction_complete_all(h, td) < 0)
|
||||||
|
|
@ -594,7 +598,7 @@ candidate_validate(clicon_handle h,
|
||||||
if ((td = transaction_new()) == NULL)
|
if ((td = transaction_new()) == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
/* Common steps (with commit) */
|
/* Common steps (with commit) */
|
||||||
if ((ret = validate_common(h, db, td, &xret)) < 0){
|
if ((ret = validate_common(h, db, td, VL_FULL, &xret)) < 0){
|
||||||
/* A little complex due to several sources of validation fails or errors.
|
/* A little complex due to several sources of validation fails or errors.
|
||||||
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
* (1) xerr is set -> translate to cbret; (2) cbret set use that; otherwise
|
||||||
* use clicon_err.
|
* use clicon_err.
|
||||||
|
|
@ -675,15 +679,8 @@ candidate_commit(clicon_handle h,
|
||||||
/* Common steps (with validate). Load candidate and running and compute diffs
|
/* Common steps (with validate). Load candidate and running and compute diffs
|
||||||
* Note this is only call that uses 3-values
|
* Note this is only call that uses 3-values
|
||||||
*/
|
*/
|
||||||
switch (vlev){
|
if ((ret = validate_common(h, db, td, vlev, &xret)) < 0)
|
||||||
case VL_FULL:
|
|
||||||
if ((ret = validate_common(h, db, td, &xret)) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the confirmed-commit feature is enabled, execute phase 2:
|
/* If the confirmed-commit feature is enabled, execute phase 2:
|
||||||
* - If a valid confirming-commit, cancel the rollback event
|
* - If a valid confirming-commit, cancel the rollback event
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ xml_cmp(cxobj *x1,
|
||||||
break;
|
break;
|
||||||
} /* switch */
|
} /* switch */
|
||||||
done:
|
done:
|
||||||
clicon_debug(CLIXON_DBG_DETAIL, "%s %s %s eq:%d nr: %d %d yi: %d %d", __FUNCTION__, xml_name(x1), xml_name(x2), equal, nr1, nr2, yi1, yi2);
|
clicon_debug(CLIXON_DBG_EXTRA, "%s %s %s eq:%d nr: %d %d yi: %d %d", __FUNCTION__, xml_name(x1), xml_name(x2), equal, nr1, nr2, yi1, yi2);
|
||||||
return equal;
|
return equal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue