Merge pull request #252 from pheller/filter-and-xml-encoding-fixes
Testing dependency fixes, Netconf XML declaration and filter logic fix
This commit is contained in:
commit
e6022bc088
5 changed files with 59 additions and 53 deletions
|
|
@ -178,11 +178,7 @@ netconf_get_config(clicon_handle h,
|
||||||
/* ie <filter>...</filter> */
|
/* ie <filter>...</filter> */
|
||||||
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
||||||
ftype = xml_find_value(xfilter, "type");
|
ftype = xml_find_value(xfilter, "type");
|
||||||
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "xpath")==0){
|
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
||||||
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
else if (strcmp(ftype, "subtree")==0){
|
|
||||||
/* Get whole config first, then filter. This is suboptimal
|
/* Get whole config first, then filter. This is suboptimal
|
||||||
*/
|
*/
|
||||||
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
||||||
|
|
@ -190,8 +186,11 @@ netconf_get_config(clicon_handle h,
|
||||||
/* Now filter on whole tree */
|
/* Now filter on whole tree */
|
||||||
if (netconf_get_config_subtree(h, xfilter, xret) < 0)
|
if (netconf_get_config_subtree(h, xfilter, xret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
|
} else if (strcmp(ftype, "xpath") == 0) {
|
||||||
|
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0) {
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
else{
|
} else {
|
||||||
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
"<error-type>applicatio</error-type>"
|
"<error-type>applicatio</error-type>"
|
||||||
|
|
@ -390,11 +389,7 @@ netconf_get(clicon_handle h,
|
||||||
/* ie <filter>...</filter> */
|
/* ie <filter>...</filter> */
|
||||||
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
if ((xfilter = xpath_first(xn, nsc, "%s%sfilter", prefix ? prefix : "", prefix ? ":" : "")) != NULL)
|
||||||
ftype = xml_find_value(xfilter, "type");
|
ftype = xml_find_value(xfilter, "type");
|
||||||
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "xpath")==0){
|
if (xfilter == NULL || ftype == NULL || strcmp(ftype, "subtree") == 0) {
|
||||||
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
else if (strcmp(ftype, "subtree")==0){
|
|
||||||
/* Get whole config + state first, then filter. This is suboptimal
|
/* Get whole config + state first, then filter. This is suboptimal
|
||||||
*/
|
*/
|
||||||
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
||||||
|
|
@ -402,8 +397,10 @@ netconf_get(clicon_handle h,
|
||||||
/* Now filter on whole tree */
|
/* Now filter on whole tree */
|
||||||
if (netconf_get_config_subtree(h, xfilter, xret) < 0)
|
if (netconf_get_config_subtree(h, xfilter, xret) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
} else if (strcmp(ftype, "xpath") == 0) {
|
||||||
else{
|
if (clicon_rpc_netconf_xml(h, xml_parent(xn), xret, NULL) < 0)
|
||||||
|
goto done;
|
||||||
|
} else {
|
||||||
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
clixon_xml_parse_va(YB_NONE, NULL, xret, NULL, "<rpc-reply xmlns=\"%s\"><rpc-error>"
|
||||||
"<error-tag>operation-failed</error-tag>"
|
"<error-tag>operation-failed</error-tag>"
|
||||||
"<error-type>applicatio</error-type>"
|
"<error-type>applicatio</error-type>"
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,12 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><commit/></
|
||||||
new "wrong filter type"
|
new "wrong filter type"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get><filter type='foo'><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-tag>operation-failed</error-tag><error-type>applicatio</error-type><error-severity>error</error-severity><error-message>filter type not supported</error-message><error-info>type</error-info></rpc-error></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get><filter type='foo'><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-tag>operation-failed</error-tag><error-type>applicatio</error-type><error-severity>error</error-severity><error-message>filter type not supported</error-message><error-info>type</error-info></rpc-error></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get-config subtree one (subtree implicit)"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><running/></source><filter><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
new "get subtree one (subtree implicit)"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get><filter><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
new "get-config subtree one"
|
new "get-config subtree one"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><running/></source><filter type='subtree'><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><get-config><source><running/></source><filter type='subtree'><x xmlns='urn:example:filter'><y><a>1</a></y></x></filter></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><x xmlns=\"urn:example:filter\"><y><a>1</a><b>1</b></y></x></data></rpc-reply>]]>]]>$"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,10 @@ wait_backend
|
||||||
new "Netconf snd hello with xmldecl"
|
new "Netconf snd hello with xmldecl"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello $DEFAULTNS><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability></capabilities></hello>]]>]]>" '^$' '^$'
|
expecteof "$clixon_netconf -qf $cfg" 0 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><hello $DEFAULTNS><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability></capabilities></hello>]]>]]>" '^$' '^$'
|
||||||
|
|
||||||
|
# Hello, lowercase encoding
|
||||||
|
new "Netconf snd hello with xmldecl (lowercase encoding)"
|
||||||
|
expecteof "$clixon_netconf -qf $cfg" 0 "<?xml version=\"1.0\" encoding=\"utf-8\"?><hello $DEFAULTNS><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability></capabilities></hello>]]>]]>" '^$' '^$'
|
||||||
|
|
||||||
new "Netconf snd hello without xmldecl"
|
new "Netconf snd hello without xmldecl"
|
||||||
expecteof "$clixon_netconf -qf $cfg" 0 "<hello $DEFAULTNS><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability></capabilities></hello>]]>]]>" '^$' '^$'
|
expecteof "$clixon_netconf -qf $cfg" 0 "<hello $DEFAULTNS><capabilities><capability>urn:ietf:params:netconf:base:1.1</capability></capabilities></hello>]]>]]>" '^$' '^$'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,9 +215,7 @@ case $release in
|
||||||
;;
|
;;
|
||||||
native)
|
native)
|
||||||
# $sshcmd sudo apt install -y libevent-2.1
|
# $sshcmd sudo apt install -y libevent-2.1
|
||||||
$sshcmd sudo apt install -y libssl-dev
|
$sshcmd sudo apt install -y libevent-dev libssl-dev
|
||||||
$sshcmd sudo apt install -y libevent-dev # evhtp
|
|
||||||
$sshcmd sudo apt install -y libnghttp2-dev # nghttp2
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue