Restricted yang (sub)module file match to match RFC6020 exactly

This commit is contained in:
Olof hagsand 2017-06-25 17:48:21 +02:00
parent 148d5d9432
commit 43c39160a5
10 changed files with 86 additions and 55 deletions

View file

@ -104,6 +104,7 @@ expand_dbvar(void *h,
cxobj *xt = NULL;
char *xpath = NULL;
cxobj **xvec = NULL;
cxobj *xerr;
size_t xlen = 0;
cxobj *x;
char *bodystr;
@ -140,8 +141,12 @@ expand_dbvar(void *h,
if (api_path_fmt2xpath(api_path, cvv, &xpath) < 0)
goto done;
/* XXX read whole configuration, why not send xpath? */
if (clicon_rpc_get_config(h, dbstr, "/", 0, &xt) < 0)
if (clicon_rpc_get_config(h, dbstr, "/", &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
clicon_rpc_generate_error(xerr);
goto done;
}
/* One round to detect duplicates
* XXX The code below would benefit from some cleanup
*/
@ -379,6 +384,7 @@ cli_show_config(clicon_handle h,
char *val = NULL;
cxobj *xt = NULL;
cxobj *xc;
cxobj *xerr;
enum genmodel_type gt;
if (cvec_len(argv) != 3 && cvec_len(argv) != 4){
@ -426,8 +432,12 @@ cli_show_config(clicon_handle h,
else
cprintf(cbxpath, "%s", xpath);
/* Get configuration from database */
if (clicon_rpc_get_config(h, db, cbuf_get(cbxpath), 0, &xt) < 0)
if (clicon_rpc_get_config(h, db, cbuf_get(cbxpath), &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
clicon_rpc_generate_error(xerr);
goto done;
}
/* Print configuration according to format */
switch (format){
case FORMAT_XML:
@ -487,6 +497,7 @@ show_conf_xpath(clicon_handle h,
char *xpath;
cg_var *cv;
cxobj *xt = NULL;
cxobj *xerr;
cxobj **xv = NULL;
size_t xlen;
int i;
@ -505,8 +516,12 @@ show_conf_xpath(clicon_handle h,
}
cv = cvec_find_var(cvv, "xpath");
xpath = cv_string_get(cv);
if (clicon_rpc_get_config(h, str, xpath, 0, &xt) < 0)
if (clicon_rpc_get_config(h, str, xpath, &xt) < 0)
goto done;
if ((xerr = xpath_first(xt, "/rpc-error")) != NULL){
clicon_rpc_generate_error(xerr);
goto done;
}
if (xpath_vec(xt, xpath, &xv, &xlen) < 0)
goto done;
for (i=0; i<xlen; i++)