From 4ecffa6885b4fd8ea9b649ea041d925c7202c627 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 11 Nov 2020 13:09:58 +0100 Subject: [PATCH] test systemctl; better rpc namespace errormsg --- apps/backend/backend_client.c | 16 ++++++++++++++-- test/lib.sh | 32 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/apps/backend/backend_client.c b/apps/backend/backend_client.c index f330e2a3..14d2f1aa 100644 --- a/apps/backend/backend_client.c +++ b/apps/backend/backend_client.c @@ -1643,11 +1643,23 @@ from_client_msg(clicon_handle h, if (xml2ns(x, rpcprefix, &namespace) < 0) goto done; /* Only accept resolved NETCONF base namespace */ - if (namespace == NULL || strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){ - if (netconf_unknown_namespace(cbret, "protocol", rpcprefix, "No appropriate namespace associated with prefix") < 0) + if (namespace == NULL){ + if (netconf_bad_element(cbret, "protocol", rpcname, "No namespace associated with prefix") < 0) goto done; goto reply; } + else if (strcmp(namespace, NETCONF_BASE_NAMESPACE) != 0){ + cbuf *cbmsg; + if ((cbmsg = cbuf_new()) == NULL){ + clicon_err(OE_UNIX, errno, "cbuf_new"); + goto done; + } + cprintf(cbmsg, "No appropriate namespace found for: %s %s", rpcprefix, rpcname); + if (netconf_unknown_namespace(cbret, "protocol", namespace, cbuf_get(cbmsg)) < 0) + goto done; + cbuf_free(cbmsg); + goto reply; + } if (strcmp(rpcname, "rpc") == 0){ ; /* continue below */ diff --git a/test/lib.sh b/test/lib.sh index 009f6939..b1a9b742 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -49,23 +49,23 @@ if [ -f ./site.sh ]; then done fi -# Auto-start nginx -if false; then # Does not work on some platforms -nginxactive=$(systemctl show nginx |grep ActiveState=active) -if [ "${WITH_RESTCONF}" = "fcgi" ]; then - if [ -z "$nginxactive" ]; then - echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with systemctl start nginx" - echo -e "\e[0m" - exit -1 +# Sanity nginx running on systemd platforms +if systemctl > /dev/null; then + nginxactive=$(systemctl show nginx |grep ActiveState=active) + if [ "${WITH_RESTCONF}" = "fcgi" ]; then + if [ -z "$nginxactive" ]; then + echo -e "\e[31m\nwith-restconf=fcgi set but nginx not running, start with systemctl start nginx" + echo -e "\e[0m" + exit -1 + fi + else + if [ -n "$nginxactive" ]; then + echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with systemctl stop nginx" + echo -e "\e[0m" + exit -1 + fi fi -else - if [ -n "$nginxactive" ]; then - echo -e "\e[31m\nwith-restconf=fcgi not set but nginx running, stop with systemctl stop nginx" - echo -e "\e[0m" - exit -1 - fi -fi -fi +fi # systemctl # Test number from start : ${testnr:=0}