mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 22:57:45 +00:00
Merge pull request #14800 from idryzhov/nb-validate-errors
Print all errors when validating NB configuration
This commit is contained in:
commit
520bb404f5
@ -871,9 +871,14 @@ int nb_candidate_update(struct nb_config *candidate)
|
|||||||
int nb_candidate_validate_yang(struct nb_config *candidate, bool no_state,
|
int nb_candidate_validate_yang(struct nb_config *candidate, bool no_state,
|
||||||
char *errmsg, size_t errmsg_len)
|
char *errmsg, size_t errmsg_len)
|
||||||
{
|
{
|
||||||
if (lyd_validate_all(&candidate->dnode, ly_native_ctx,
|
uint32_t options = LYD_VALIDATE_MULTI_ERROR;
|
||||||
no_state ? LYD_VALIDATE_NO_STATE
|
|
||||||
: LYD_VALIDATE_PRESENT,
|
if (no_state)
|
||||||
|
SET_FLAG(options, LYD_VALIDATE_NO_STATE);
|
||||||
|
else
|
||||||
|
SET_FLAG(options, LYD_VALIDATE_PRESENT);
|
||||||
|
|
||||||
|
if (lyd_validate_all(&candidate->dnode, ly_native_ctx, options,
|
||||||
NULL) != 0) {
|
NULL) != 0) {
|
||||||
yang_print_errors(ly_native_ctx, errmsg, errmsg_len);
|
yang_print_errors(ly_native_ctx, errmsg, errmsg_len);
|
||||||
return NB_ERR_VALIDATION;
|
return NB_ERR_VALIDATION;
|
||||||
|
15
lib/yang.c
15
lib/yang.c
@ -676,7 +676,6 @@ static void ly_log_cb(LY_LOG_LEVEL level, const char *msg, const char *path)
|
|||||||
const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf, size_t buf_len)
|
const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf, size_t buf_len)
|
||||||
{
|
{
|
||||||
struct ly_err_item *ei;
|
struct ly_err_item *ei;
|
||||||
const char *path;
|
|
||||||
|
|
||||||
ei = ly_err_first(ly_ctx);
|
ei = ly_err_first(ly_ctx);
|
||||||
if (!ei)
|
if (!ei)
|
||||||
@ -684,18 +683,16 @@ const char *yang_print_errors(struct ly_ctx *ly_ctx, char *buf, size_t buf_len)
|
|||||||
|
|
||||||
strlcpy(buf, "YANG error(s):\n", buf_len);
|
strlcpy(buf, "YANG error(s):\n", buf_len);
|
||||||
for (; ei; ei = ei->next) {
|
for (; ei; ei = ei->next) {
|
||||||
strlcat(buf, " ", buf_len);
|
if (ei->path) {
|
||||||
|
strlcat(buf, " Path: ", buf_len);
|
||||||
|
strlcat(buf, ei->path, buf_len);
|
||||||
|
strlcat(buf, "\n", buf_len);
|
||||||
|
}
|
||||||
|
strlcat(buf, " Error: ", buf_len);
|
||||||
strlcat(buf, ei->msg, buf_len);
|
strlcat(buf, ei->msg, buf_len);
|
||||||
strlcat(buf, "\n", buf_len);
|
strlcat(buf, "\n", buf_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = ly_errpath(ly_ctx);
|
|
||||||
if (path) {
|
|
||||||
strlcat(buf, " YANG path: ", buf_len);
|
|
||||||
strlcat(buf, path, buf_len);
|
|
||||||
strlcat(buf, "\n", buf_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
ly_err_clean(ly_ctx, NULL);
|
ly_err_clean(ly_ctx, NULL);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user