New clixon-restconf@2025-02-01.yang revision: timeout parameter

This commit is contained in:
Olof hagsand 2025-02-18 10:13:59 +01:00
parent 18c29f018a
commit a7cc1c6362
7 changed files with 47 additions and 20 deletions

View file

@ -1,6 +1,6 @@
# Clixon Changelog # Clixon Changelog
* [7.4.0](#730) Planned: April 2025 * [7.4.0](#740) Planned: April 2025
* [7.3.0](#730) 30 January 2025 * [7.3.0](#730) 30 January 2025
* [7.2.0](#720) 28 October 2024 * [7.2.0](#720) 28 October 2024
* [7.1.0](#710) 3 July 2024 * [7.1.0](#710) 3 July 2024
@ -19,6 +19,8 @@ Planned: April 2025
### Features ### Features
* Added new `ca_userdef` callback * Added new `ca_userdef` callback
* New `clixon-restconf@2025-02-01.yang` revision
* Added timeout parameter
## 7.3.0 ## 7.3.0
30 January 2025 30 January 2025

View file

@ -1187,6 +1187,7 @@ from_client_create_subscription(clixon_handle h,
struct timeval stop; struct timeval stop;
cvec *nsc = NULL; cvec *nsc = NULL;
clixon_debug(CLIXON_DBG_STREAM, "");
/* XXX should use prefix cf edit_config */ /* XXX should use prefix cf edit_config */
if ((nsc = xml_nsctx_init(NULL, EVENT_RFC5277_NAMESPACE)) == NULL) if ((nsc = xml_nsctx_init(NULL, EVENT_RFC5277_NAMESPACE)) == NULL)
goto done; goto done;

View file

@ -676,13 +676,13 @@ restconf_clixon_backend(clixon_handle h,
clicon_session_id_set(h, id); clicon_session_id_set(h, id);
break; break;
} }
/* XXX HARDCODED NAMESPACE NEEDS GENERIC MECHANISM
* It works if one uses "import clixon-restconf"
* But not if one does uses clixon-restdonf in which case the namespace is
* the local (top-level).
*/
if ((nsc = xml_nsctx_init(NULL, if ((nsc = xml_nsctx_init(NULL,
/* XXX HARDCODED NAMESPACE NEEDS GENERIC MECHANISM */
#if 1
"http://clicon.org/controller"
#else
CLIXON_RESTCONF_NS CLIXON_RESTCONF_NS
#endif
)) == NULL) )) == NULL)
goto done; goto done;
if ((pw = getpwuid(getuid())) == NULL){ if ((pw = getpwuid(getuid())) == NULL){
@ -822,15 +822,15 @@ openssl_init_socket(clixon_handle h,
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] dbg0 Manually set debug flag, if set overrides configuration setting * @param[in] dbg0 Manually set debug flag, if set overrides configuration setting
* @param[in] xrestconf XML tree containing restconf config * @param[in] xrestconf XML tree containing restconf config
* @param[in] timeout Terminate notification stream after number of seconds * @param[in] timeout0 Command-line timeout (overrides if set config timeout)
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
*/ */
int static int
restconf_openssl_init(clixon_handle h, restconf_openssl_init(clixon_handle h,
int dbg0, int dbg0,
cxobj *xrestconf, cxobj *xrestconf,
int timeout) int timeout0)
{ {
int retval = -1; int retval = -1;
SSL_CTX *ctx; /* SSL context */ SSL_CTX *ctx; /* SSL context */
@ -847,12 +847,22 @@ restconf_openssl_init(clixon_handle h,
cxobj **vec = NULL; cxobj **vec = NULL;
size_t veclen; size_t veclen;
int i; int i;
int timeout = 0;
clixon_debug(CLIXON_DBG_RESTCONF, ""); clixon_debug(CLIXON_DBG_RESTCONF, "");
/* flag used for sanity of certs */ /* flag used for sanity of certs */
ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL; ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL;
/* Auth type set in config */ /* Auth type set in config */
auth_type = restconf_auth_type_get(h); auth_type = restconf_auth_type_get(h);
/* Timeout */
if ((x = xpath_first(xrestconf, nsc, "timeout")) != NULL &&
(bstr = xml_body(x)) != NULL){
timeout = atoi(bstr);
}
/* Command-line overrides */
if (timeout0 != 0)
timeout = timeout0;
/* Only set debug from config if not set manually */ /* Only set debug from config if not set manually */
if (dbg0 == 0 && if (dbg0 == 0 &&
(x = xpath_first(xrestconf, nsc, "debug")) != NULL && (x = xpath_first(xrestconf, nsc, "debug")) != NULL &&
@ -1311,7 +1321,7 @@ main(int argc,
if (clicon_option_add(h, "CLICON_RESTCONF_PRIVILEGES", "none") < 0) if (clicon_option_add(h, "CLICON_RESTCONF_PRIVILEGES", "none") < 0)
goto done; goto done;
break; break;
case 'W': /* Run restconf daemon as this user (afetr drop) */ case 'W': /* Run restconf daemon as this user (after drop) */
if (clicon_option_add(h, "CLICON_RESTCONF_USER", optarg) < 0) if (clicon_option_add(h, "CLICON_RESTCONF_USER", optarg) < 0)
goto done; goto done;
break; break;
@ -1372,7 +1382,7 @@ main(int argc,
retval = 0; retval = 0;
goto done; goto done;
} }
/* Create and stroe global openssl handle */ /* Create and store global openssl handle */
if ((rn = malloc(sizeof *rn)) == NULL){ if ((rn = malloc(sizeof *rn)) == NULL){
clixon_err(OE_UNIX, errno, "malloc"); clixon_err(OE_UNIX, errno, "malloc");
goto done; goto done;

View file

@ -53,7 +53,7 @@
#define CLIXON_LOG_SYSLOG 0x01 /* print logs on syslog */ #define CLIXON_LOG_SYSLOG 0x01 /* print logs on syslog */
#define CLIXON_LOG_STDERR 0x02 /* print logs on stderr */ #define CLIXON_LOG_STDERR 0x02 /* print logs on stderr */
#define CLIXON_LOG_STDOUT 0x04 /* print logs on stdout */ #define CLIXON_LOG_STDOUT 0x04 /* print logs on stdout */
#define CLIXON_LOG_FILE 0x08 /* print logs on clixon_log_filename */ #define CLIXON_LOG_FILE 0x08 /* print logs on clixon_log_file() */
/* What kind of log (only for customizable error/logs) */ /* What kind of log (only for customizable error/logs) */
enum clixon_log_type{ enum clixon_log_type{

View file

@ -299,12 +299,11 @@ fi
test-pause test-pause
sleep 5 sleep 5
# Try parallell # Start curl in background and save PID
# start background job
curl $CURLOPTS -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" "$RCPROTO://localhost/streams/EXAMPLE" & # > /dev/null & curl $CURLOPTS -X GET -H "Accept: text/event-stream" -H "Cache-Control: no-cache" -H "Connection: keep-alive" "$RCPROTO://localhost/streams/EXAMPLE" & # > /dev/null &
PID=$! PID=$!
new "Start subscriptions in parallell" new "Start subscription"
ret=$($clixon_util_stream -u $RCPROTO://localhost/streams/EXAMPLE -t 8) ret=$($clixon_util_stream -u $RCPROTO://localhost/streams/EXAMPLE -t 8)
expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event xmlns=\"urn:example:clixon\"><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>" expect="data: <notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\"><eventTime>${DATE}T[0-9:.]*Z</eventTime><event xmlns=\"urn:example:clixon\"><event-class>fault</event-class><reportingEntity><card>Ethernet0</card></reportingEntity><severity>major</severity></event>"

View file

@ -46,7 +46,7 @@ YANGSPECS = clixon-config@2024-11-01.yang # 7.3
YANGSPECS += clixon-lib@2024-11-01.yang # 7.3 YANGSPECS += clixon-lib@2024-11-01.yang # 7.3
YANGSPECS += clixon-rfc5277@2008-07-01.yang YANGSPECS += clixon-rfc5277@2008-07-01.yang
YANGSPECS += clixon-xml-changelog@2019-03-21.yang YANGSPECS += clixon-xml-changelog@2019-03-21.yang
YANGSPECS += clixon-restconf@2022-08-01.yang # 5.9 YANGSPECS += clixon-restconf@2025-02-01.yang # 7.4
YANGSPECS += clixon-autocli@2024-08-01.yang # 7.2 YANGSPECS += clixon-autocli@2024-08-01.yang # 7.2
all: all:

View file

@ -17,7 +17,7 @@ module clixon-restconf {
"This YANG module provides a data-model for the Clixon RESTCONF daemon. "This YANG module provides a data-model for the Clixon RESTCONF daemon.
There is also clixon-config also including some restconf options. There is also clixon-config also including some restconf options.
The separation is not always logical but there are some reasons for the split: The separation is not always logical but there are some reasons for the split:
1. Some data (ie 'socket') is structurally complex and cannot be expressed as a 1. Some data (ie 'socket') is structurally complex and cannot be expressed as a
simple option simple option
2. clixon-restconf is defined as a macro/grouping and can be included in 2. clixon-restconf is defined as a macro/grouping and can be included in
other YANGs. In particular, it can be used inside a datastore, which other YANGs. In particular, it can be used inside a datastore, which
@ -53,6 +53,11 @@ module clixon-restconf {
***** END LICENSE BLOCK *****"; ***** END LICENSE BLOCK *****";
revision 2025-02-01 {
description
"Added timeout parameter
Released in Clixon 7.4";
}
revision 2022-03-21 { revision 2022-03-21 {
description description
"Added feature: "Added feature:
@ -185,8 +190,9 @@ module clixon-restconf {
} }
leaf log-destination { leaf log-destination {
description description
"Log destination. "Log destination.
If debug is not set, only notice, error and warning will be logged"; If debug is not set, only notice, error and warning will be logged
If log-destination is file, the actual file is /var/log/clixon_restconf.log";
type log-destination; type log-destination;
default syslog; default syslog;
} }
@ -243,6 +249,14 @@ module clixon-restconf {
"Path to server CA cert file "Path to server CA cert file
Note only applies if socket has ssl enabled"; Note only applies if socket has ssl enabled";
} }
leaf timeout {
description
"Timeout of individual sessions.
Useful when debugging long-poll server-sent event streams";
type uint32;
default 0;
units "seconds";
}
list socket { list socket {
description description
"List of server sockets that the restconf daemon listens to. "List of server sockets that the restconf daemon listens to.
@ -272,7 +286,8 @@ module clixon-restconf {
} }
container restconf { container restconf {
description description
"This presence is strictly not necessary since the enable flag "If imported, this container appears in top-level configuration.
The presence statement is strictly not necessary since the enable flag
in clixon-restconf is the flag bearing the actual semantics. in clixon-restconf is the flag bearing the actual semantics.
However, removing the presence leads to default config in all However, removing the presence leads to default config in all
clixon installations, even those which do not use backend-started restconf. clixon installations, even those which do not use backend-started restconf.