Merge branch 'master' into develop
This commit is contained in:
commit
89cfe2a9b3
5 changed files with 49 additions and 32 deletions
|
|
@ -86,6 +86,7 @@ If you submit "nopresence" without a leaf, it will automatically be removed:
|
|||
* You need to define state data in a backend callback. See the example and documentation for more details.
|
||||
|
||||
### Minor changes:
|
||||
* Added prefix parsing of xpath, allowing eg /p:x/p:y, but prefix ignored.
|
||||
* Corrected Yang union CLI generation and type validation. Recursive unions did not work.
|
||||
* Corrected Yang pattern type escaping problem, ie '\.' did not work properly. This requires update of cligen as well.
|
||||
* Compliance with RFC: Rename yang xpath to schema_nodeid and syntaxnode to datanode.
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ from_client_msg(clicon_handle h,
|
|||
cxobj *xt = NULL;
|
||||
cxobj *x;
|
||||
cxobj *xe;
|
||||
char *name;
|
||||
char *name = NULL;
|
||||
char *db;
|
||||
cbuf *cbret = NULL; /* return message */
|
||||
int pid;
|
||||
|
|
|
|||
|
|
@ -1979,9 +1979,6 @@ xml_merge(cxobj *x0,
|
|||
cxobj *x1c; /* mod child */
|
||||
yang_stmt *yc;
|
||||
|
||||
/* Assure top-levels are 'config' */
|
||||
assert(x0 && strcmp(xml_name(x0),"config")==0);
|
||||
assert(x1 && strcmp(xml_name(x1),"config")==0);
|
||||
/* Loop through children of the modification tree */
|
||||
x1c = NULL;
|
||||
while ((x1c = xml_child_each(x1, x1c, CX_ELMNT)) != NULL) {
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ struct xpath_predicate{
|
|||
struct xpath_element{
|
||||
struct xpath_element *xe_next;
|
||||
enum axis_type xe_type;
|
||||
char *xe_prefix; /* eg for namespaces */
|
||||
char *xe_str; /* eg for child */
|
||||
struct xpath_predicate *xe_predicate; /* eg within [] */
|
||||
};
|
||||
|
|
@ -217,6 +218,7 @@ xpath_element_new(enum axis_type atype,
|
|||
struct xpath_element *xe;
|
||||
char *str1 = NULL;
|
||||
char *pred;
|
||||
char *local;
|
||||
|
||||
if ((xe = malloc(sizeof(*xe))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "malloc");
|
||||
|
|
@ -232,7 +234,18 @@ xpath_element_new(enum axis_type atype,
|
|||
if (xpath_split(str1, &pred) < 0) /* Can be more predicates */
|
||||
goto done;
|
||||
if (strlen(str1)){
|
||||
if ((xe->xe_str = strdup(str1)) == NULL){
|
||||
/* Split into prefix and localname */
|
||||
if ((local = index(str1, ':')) != NULL){
|
||||
*local = '\0';
|
||||
local++;
|
||||
if ((xe->xe_prefix = strdup(str1)) == NULL){
|
||||
clicon_err(OE_XML, errno, "%s: strdup", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else
|
||||
local = str1;
|
||||
if ((xe->xe_str = strdup(local)) == NULL){
|
||||
clicon_err(OE_XML, errno, "%s: strdup", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -264,6 +277,8 @@ xpath_element_free(struct xpath_element *xe)
|
|||
|
||||
if (xe->xe_str)
|
||||
free(xe->xe_str);
|
||||
if (xe->xe_prefix)
|
||||
free(xe->xe_prefix);
|
||||
while ((xp = xe->xe_predicate) != NULL){
|
||||
xe->xe_predicate = xp->xp_next;
|
||||
if (xp->xp_expr)
|
||||
|
|
|
|||
|
|
@ -11,40 +11,30 @@ clixon_cli=clixon_cli
|
|||
|
||||
cat <<EOF > /tmp/leafref.yang
|
||||
module example{
|
||||
typedef admin-status{
|
||||
type string;
|
||||
}
|
||||
list interface {
|
||||
key "name";
|
||||
leaf name {
|
||||
type string;
|
||||
}
|
||||
leaf admin-status {
|
||||
type admin-status;
|
||||
}
|
||||
list address {
|
||||
key "ip";
|
||||
leaf ip {
|
||||
type string;
|
||||
}
|
||||
}
|
||||
import ietf-ip {
|
||||
prefix ip;
|
||||
}
|
||||
container default-address {
|
||||
leaf ifname {
|
||||
leaf absname {
|
||||
type leafref {
|
||||
path "../../interface/name";
|
||||
path "/ip:interfaces/ip:interface/ip:name";
|
||||
}
|
||||
}
|
||||
leaf relname {
|
||||
type leafref {
|
||||
path "../../interfaces/interface/name";
|
||||
}
|
||||
}
|
||||
leaf address {
|
||||
type leafref {
|
||||
path "../../interface[name=eth0]"
|
||||
path "../../interfaces/interface[name=eth0]"
|
||||
+ "/address/ip";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
# path "../../interface[name = current()/../ifname]"
|
||||
# XXX not eth0 path "../../interface[name = current()/../ifname]"
|
||||
|
||||
# kill old backend (if any)
|
||||
new "kill old backend"
|
||||
|
|
@ -61,16 +51,17 @@ if [ $? -ne 0 ]; then
|
|||
fi
|
||||
|
||||
new "leafref base config"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><interface><name>eth0</name><admin-status>up</admin-status><address><ip>192.0.2.1</ip></address><address><ip>192.0.2.2</ip></address></interface><interface><name>lo</name><admin-status>up</admin-status><address><ip>127.0.0.1</ip></address></interface></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><interfaces>
|
||||
<interface><name>eth0</name> <type>eth</type> <ipv4><address><ip>192.0.2.1</ip></address></ipv4> <ipv4><address><ip>192.0.2.2</ip></address></ipv4></interface><interface><name>lo</name><type>lo</type><ipv4><address><ip>127.0.0.1</ip></address></ipv4></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "leafref get config"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf" '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<rpc-reply><data><interface><name>eth0</name>'
|
||||
expecteof "$clixon_netconf -qf $clixon_cf" '<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>' '^<rpc-reply><data><interfaces><interface><name>eth0</name>'
|
||||
|
||||
new "leafref base commit"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "leafref add wrong ref"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><default-address><ifname>eth3</ifname><address>10.0.4.6</address></default-address></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><default-address><absname>eth3</absname><address>10.0.4.6</address></default-address></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "leafref validate"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-tag>missing-attribute</error-tag>"
|
||||
|
|
@ -78,18 +69,31 @@ expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><validate>
|
|||
new "leafref discard-changes"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf" "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "leafref add correct ref"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><default-address><ifname>eth0</ifname><address>192.0.2.2</address></default-address></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
new "leafref add correct absref"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><default-address><absname>eth0</absname></default-address></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "leafref add correct relref"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><default-address><relname>eth0</relname></default-address></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
# XXX add address
|
||||
|
||||
new "leafref validate (ok)"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>"
|
||||
|
||||
new "leafref delete leaf"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><interface operation=\"delete\"><name>eth0</name></interface></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><edit-config><target><candidate/></target><config><interfaces><interface operation=\"delete\"><name>eth0</name></interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>"
|
||||
|
||||
new "leafref validate (should fail)"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf -y /tmp/leafref.yang" "<rpc><validate><source><candidate/></source></validate></rpc>]]>]]>" "^<rpc-reply><rpc-error><error-tag>missing-attribute</error-tag>"
|
||||
|
||||
new "leafref discard-changes"
|
||||
expecteof "$clixon_netconf -qf $clixon_cf" "<rpc><discard-changes/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
|
||||
|
||||
new "cli leafref lo"
|
||||
expectfn "$clixon_cli -1f $clixon_cf -y /tmp/leafref.yang -l o set default-address absname lo" "^$"
|
||||
|
||||
new "cli leafref validate"
|
||||
expectfn "$clixon_cli -1f $clixon_cf -y /tmp/leafref.yang -l o validate" "^$"
|
||||
|
||||
new "Kill backend"
|
||||
# Check if still alive
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue