revert clixon-err on XML

restconf backend config
This commit is contained in:
Olof hagsand 2020-11-17 14:42:12 +01:00
parent eb549b4c21
commit daaf3f17df
10 changed files with 52 additions and 31 deletions

View file

@ -376,7 +376,6 @@ char*
xml_name(cxobj *xn)
{
if (xn == NULL) {
clicon_err(OE_XML, EINVAL, "x is NULL");
return NULL;
}
return xn->x_name;
@ -570,7 +569,6 @@ cxobj*
xml_parent(cxobj *xn)
{
if (xn == NULL) {
clicon_err(OE_XML, EINVAL, "xn is NULL");
return NULL;
}
return xn->x_up;
@ -713,7 +711,6 @@ enum cxobj_type
xml_type(cxobj *xn)
{
if (xn == NULL) {
clicon_err(OE_XML, EINVAL, "xn is NULL");
return CX_ERROR;
}
return xn->x_type;
@ -808,7 +805,6 @@ xml_child_i(cxobj *xn,
int i)
{
if (xn == NULL || i < 0) {
clicon_err(OE_XML, EINVAL, "xn is NULL or invalid child nr");
return NULL;
}
if (!is_element(xn))
@ -1221,7 +1217,6 @@ xml_find(cxobj *xp,
cxobj *x = NULL;
if (xp == NULL || name == NULL) {
clicon_err(OE_XML, EINVAL, "xp or name is NULL");
return NULL;
}
if (!is_element(xp))
@ -1838,8 +1833,7 @@ xml_free(cxobj *x)
cxobj *xc;
if (x == NULL){
clicon_err(OE_XML, EINVAL, "x is NULL");
return -1;
return 0;
}
if (x->x_name)
free(x->x_name);

View file

@ -927,10 +927,10 @@ yang_parse_module(clicon_handle h,
goto done;
if (nr == 0){
if (revision)
clicon_err(OE_YANG, ENOENT, "No1 yang files found matching \"%s@%s\" in the list of CLICON_YANG_DIRs",
clicon_err(OE_YANG, ENOENT, "No yang files found matching \"%s@%s\" in the list of CLICON_YANG_DIRs",
module, revision);
else
clicon_err(OE_YANG, ENOENT, "No2 yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module);
clicon_err(OE_YANG, ENOENT, "No yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module);
goto done;
}
filename = cbuf_get(fbuf);

18
test/restconf_config.sh Normal file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Create restconf backend config with a single socket
# ipv4 no-ssl
RESTCONFIG=$(cat <<EOF
<restconf xmlns="https://clicon.org/restconf">
<ssl-enable>false</ssl-enable>
<auth-type>password</auth-type>
<socket><namespace>default</namespace><address>0.0.0.0</address><port>80</port><ssl>false</ssl></socket>
</restconf>
EOF
)
new "netconf edit config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RESTCONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"

View file

@ -228,6 +228,9 @@ if [ $BE -ne 0 ]; then
new "waiting"
wait_backend
# Load restconf config
. ./restconf_config.sh
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre

View file

@ -167,6 +167,9 @@ fi
new "waiting"
wait_backend
# Load restconf config
. ./restconf_config.sh
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
@ -189,7 +192,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><ca
</interface></interfaces></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf verify get with refined ports"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface xmlns:mymod=\"urn:example:augment\"><name>e1</name><type>mymod:some-new-iftype</type><mymod:mandatory-leaf>true</mymod:mandatory-leaf><mymod:port>80</mymod:port><mymod:lport>8080</mymod:lport></interface></interfaces></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"><interface xmlns:mymod=\"urn:example:augment\"><name>e1</name><type>mymod:some-new-iftype</type><mymod:mandatory-leaf>true</mymod:mandatory-leaf><mymod:port>80</mymod:port><mymod:lport>8080</mymod:lport></interface></interfaces>"
new "netconf set identity defined in other"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">

View file

@ -119,6 +119,9 @@ fi
new "waiting"
wait_backend
# Load restconf config
. ./restconf_config.sh
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
@ -153,7 +156,7 @@ new "netconf set protocol tcp"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\"><protocol><tcp/></protocol></system></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf get protocol tcp"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><protocol><tcp/></protocol></system></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><protocol><tcp/></protocol></system>"
new "netconf commit protocol tcp"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
@ -162,7 +165,7 @@ new "netconf changing from TCP to UDP (RFC7950 7.9.6)"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS message-id=\"101\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\"><protocol><udp nc:operation=\"create\"/></protocol></system></config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS message-id=\"101\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><ok/></rpc-reply>]]>]]>$"
new "netconf get protocol udp"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><protocol><udp/></protocol></system></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><protocol><udp/></protocol></system>"
new "netconf commit protocol udp"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"

View file

@ -154,6 +154,9 @@ fi
new "waiting"
wait_backend
# Load restconf config
. ./restconf_config.sh
if [ $RC -ne 0 ]; then
new "kill old restconf daemon"
stop_restconf_pre
@ -276,7 +279,7 @@ new "restconf get own identity"
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"aes"}'
new "netconf get own identity as set by restconf"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\">aes</crypto></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\">aes</crypto>"
new "restconf delete identity"
expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content"
@ -297,7 +300,7 @@ new "restconf get other identity"
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}'
new "netconf get other identity"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\" xmlns:des=\"urn:example:des\">des:des3</crypto></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\" xmlns:des=\"urn:example:des\">des:des3</crypto>"
new "restconf delete identity"
expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content"
@ -313,7 +316,7 @@ new "restconf get other identity (set by netconf)"
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}'
new "netconf get other identity"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\" xmlns:des=\"urn:example:des\">des:des3</crypto></data></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><get-config><source><running/></source></get-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><data><crypto xmlns=\"urn:example:my-crypto\" xmlns:des=\"urn:example:des\">des:des3</crypto>"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"

View file

@ -72,7 +72,7 @@ state='{"clixon-example:state":{"op":\["41","42","43"\]}'
if $IPv6; then
# For backend config, create 4 sockets, all combinations IPv4/IPv6 + http/https
RESTCONFCONFIG=$(cat <<EOF
RESTCONFIG=$(cat <<EOF
<restconf xmlns="https://clicon.org/restconf">
<ssl-enable>true</ssl-enable>
<auth-type>password</auth-type>
@ -88,7 +88,7 @@ EOF
)
else
# For backend config, create 4 sockets, all combinations IPv4/IPv6 + http/https
RESTCONFCONFIG=$(cat <<EOF
RESTCONFIG=$(cat <<EOF
<restconf xmlns="https://clicon.org/restconf">
<ssl-enable>true</ssl-enable>
<auth-type>password</auth-type>
@ -136,7 +136,7 @@ testrun()
if [ $config = backend ] ; then # Create a backend config
# restconf backend config
new "netconf edit config"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RESTCONFCONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config>$RESTCONFIG</config></edit-config></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
new "netconf commit"
expecteof "$clixon_netconf -qf $cfg" 0 "<rpc $DEFAULTNS><commit/></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><ok/></rpc-reply>]]>]]>$"
@ -147,11 +147,11 @@ testrun()
stop_restconf_pre
if [ $config = backend ] ; then # Add -b option
new "start restconf daemon -b"
start_restconf -f $cfg -b
new "start restconf daemon -o CLICON_RESTCONF_CONFIG=true"
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true
else
new "start restconf daemon"
start_restconf -f $cfg
new "start restconf daemon -o CLICON_RESTCONF_CONFIG=false"
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false
fi
fi
new "wait restconf"

View file

@ -156,13 +156,8 @@ EOF
fi # genkeys
# Set a clixon-restconf config
if [ ${RCPROTO} = "https" ]; then
ssl=true
port=443
else
ssl=false
port=80
fi
ssl=true
port=443
authtype=client-certificate
# Run with and without getting config from backend
@ -219,10 +214,10 @@ EOF
stop_restconf_pre
if $USEBACKEND; then
new "start restconf daemon -b -- -s"
start_restconf -f $cfg -b -- -s
start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true -- -s
else
new "start restconf daemon -s -c -- -s"
start_restconf -f $cfg -s -c -- -s
start_restconf -f $cfg -s -c -o CLICON_RESTCONF_CONFIG=false -- -s
fi
fi

View file

@ -35,6 +35,7 @@ cat <<EOF > $cfg
<clixon-config xmlns="http://clicon.org/config">
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
<CLICON_FEATURE>ni-ieee1588-ptp:cmlds</CLICON_FEATURE>
<CLICON_FEATURE>ietf-alarms:alarm-shelving</CLICON_FEATURE>
<CLICON_YANG_DIR>$YANGMODELS/standard/ietf/RFC</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802.1/Qcr</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$YANGMODELS/standard/ieee/draft/802</CLICON_YANG_DIR>
@ -85,6 +86,7 @@ new "yangmodel Standard IEEE 802.1: $YANGMODELS/standard/ieee/published/802.3"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/published/802.3 show version)" 0 "$version."
# Standard IETF
# XXX fails on augmenting "action"
new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC"
expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "$version."