Merge branch 'master' into develop

This commit is contained in:
Olof hagsand 2017-08-04 17:42:37 +02:00
commit bf6c87c9d1
8 changed files with 34 additions and 18 deletions

View file

@ -4,7 +4,7 @@
### Known issues
* Please use text datastore, key-value datastore no up-to-date
* Restconf RPC does not encode output correct
* leafref occuring within lists: cli expansion does not work
### Major changes:
* Added support for YANG anyxml.

View file

@ -1195,6 +1195,7 @@ cli_copy_config(clicon_handle h,
goto done;
if (xml_copy(x1, x2) < 0)
goto done;
xml_name_set(x2, "config");
cprintf(cb, "/%s", keyname);
if ((x = xpath_first(x2, cbuf_get(cb))) == NULL){
clicon_err(OE_PLUGIN, 0, "Field %s not found in copy tree", keyname);

View file

@ -165,6 +165,9 @@ expand_dbvar(void *h,
if ((xtop = xml_new("config", NULL)) == NULL)
goto done;
xbot = xtop;
/* This is primarily to get "y", XXX xbot can be broken (contains =%s)
* xpath2xml would have worked!!
*/
if (api_path && api_path2xml(api_path, yspec, xtop, 0, &xbot, &y) < 0)
goto done;
/* Special case for leafref. Detect leafref via Yang-type,
@ -182,7 +185,7 @@ expand_dbvar(void *h,
goto done;
}
xpathcur = ypath->ys_argument;
if (xml_merge(xt, xtop, yspec) < 0)
if (xml_merge(xt, xtop, yspec) < 0) /* Merge xtop into xt */
goto done;
if ((xcur = xpath_first(xt, xpath)) == NULL){
clicon_err(OE_DB, 0, "xpath %s should return merged content", xpath);

View file

@ -219,7 +219,7 @@ netconf_plugin_callbacks(clicon_handle h,
yang_stmt *yinput;
yang_stmt *youtput;
cxobj *xoutput;
cbuf *cb;
cbuf *cb = NULL;
if (deps != NULL){
nreg = deps;

View file

@ -21,7 +21,7 @@ debug("Debugging parts of the system"), cli_debug_cli((int32)1);{
}
copy("Copy and create a new object") {
interface("Copy interface"){
<name:string expand_dbvar("candidate","/interfaces/interface/name")>("name of interface to copy from") to("Copy to interface") <toname:string>("Name of interface to copy to"), cli_copy_config("candidate","//interface[%s=%s]","name","name","toname");
<name:string expand_dbvar("candidate","/interfaces/interface=%s/name")>("name of interface to copy from") to("Copy to interface") <toname:string>("Name of interface to copy to"), cli_copy_config("candidate","//interface[%s=%s]","name","name","toname");
}
}
discard("Discard edits (rollback 0)"), discard_changes();

View file

@ -1725,19 +1725,23 @@ api_path2xml_vec(char **vec,
/* The value is a list of keys: <key>[ <key>]* */
if ((cvk = yang_arg2cvec(ykey, " ")) == NULL)
goto done;
if (restval==NULL){
clicon_err(OE_XML, 0, "malformed key, expected '=<restval>'");
goto done;
}
if (valvec)
if (valvec){
free(valvec);
valvec = NULL;
}
if (restval==NULL){
// XXX patch to allow for lists without restval tobe backward compat
// clicon_err(OE_XML, 0, "malformed key, expected '=<restval>'");
// goto done;
}
else{
if ((valvec = clicon_strsep(restval, ",", &nvalvec)) == NULL)
goto done;
if (cvec_len(cvk) != nvalvec){
clicon_err(OE_XML, errno, "List %s key length mismatch", name);
goto done;
}
}
cvi = NULL;
/* create list object */
if ((x = xml_new_spec(name, x0, y)) == NULL)
@ -1747,13 +1751,14 @@ api_path2xml_vec(char **vec,
/* Create keys */
while ((cvi = cvec_each(cvk, cvi)) != NULL) {
keyname = cv_string_get(cvi);
val2 = valvec[j++];
if ((xn = xml_new(keyname, x)) == NULL)
goto done;
xml_type_set(xn, CX_ELMNT);
if ((xb = xml_new("body", xn)) == NULL)
goto done;
xml_type_set(xb, CX_BODY);
val2 = valvec?valvec[j++]:NULL;
if (xml_value_set(xb, val2) <0)
goto done;
}

View file

@ -1741,7 +1741,7 @@ schema_nodeid_vec(yang_node *yn,
int retval = -1;
char *arg;
yang_node *ynext;
char *nodeid;
char *nodeid = NULL;
int i;
yang_stmt *ys;
int match;
@ -1788,7 +1788,7 @@ schema_nodeid_vec(yang_node *yn,
if (yang_schemanode((yang_stmt*)ynext))
*yres = (yang_stmt*)ynext;
else
clicon_debug(1, "%s not schema node", nodeid);
clicon_debug(1, "%s not schema node", arg);
goto ok;
}
/* recursive call using ynext */

View file

@ -46,6 +46,8 @@ expectfn "$clixon_cli -1f $clixon_cf set interfaces interface eth/0/0" "^$"
new "cli show configuration"
expectfn "$clixon_cli -1f $clixon_cf show conf cli" "^interfaces interface name eth/0/0" "interfaces interface enabled true$"
new "cli failed validate"
expectfn "$clixon_cli -1f $clixon_cf -l o validate" "Missing mandatory variable"
@ -63,6 +65,9 @@ expectfn "$clixon_cli -1f $clixon_cf -l o delete interfaces interface eth/0/0 de
new "cli show xpath no description"
expectfn "$clixon_cli -1f $clixon_cf -l o show xpath /interfaces/interface/description" "^$"
new "cli copy interface"
expectfn "$clixon_cli -1f $clixon_cf copy interface eth/0/0 to eth99" "^$"
new "cli success validate"
expectfn "$clixon_cli -1f $clixon_cf -l o validate" "^$"
@ -72,6 +77,8 @@ expectfn "$clixon_cli -1f $clixon_cf -l o commit" "^$"
new "cli save"
expectfn "$clixon_cli -1f $clixon_cf -l o save /tmp/foo" "^$"
new "cli delete all"
expectfn "$clixon_cli -1f $clixon_cf -l o delete all" "^$"