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

View file

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

View file

@ -676,13 +676,13 @@ restconf_clixon_backend(clixon_handle h,
clicon_session_id_set(h, id);
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,
/* XXX HARDCODED NAMESPACE NEEDS GENERIC MECHANISM */
#if 1
"http://clicon.org/controller"
#else
CLIXON_RESTCONF_NS
#endif
)) == NULL)
goto done;
if ((pw = getpwuid(getuid())) == NULL){
@ -822,15 +822,15 @@ openssl_init_socket(clixon_handle h,
* @param[in] h Clixon handle
* @param[in] dbg0 Manually set debug flag, if set overrides configuration setting
* @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 -1 Error
*/
int
static int
restconf_openssl_init(clixon_handle h,
int dbg0,
cxobj *xrestconf,
int timeout)
int timeout0)
{
int retval = -1;
SSL_CTX *ctx; /* SSL context */
@ -847,12 +847,22 @@ restconf_openssl_init(clixon_handle h,
cxobj **vec = NULL;
size_t veclen;
int i;
int timeout = 0;
clixon_debug(CLIXON_DBG_RESTCONF, "");
/* flag used for sanity of certs */
ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL;
/* Auth type set in config */
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 */
if (dbg0 == 0 &&
(x = xpath_first(xrestconf, nsc, "debug")) != NULL &&
@ -1311,7 +1321,7 @@ main(int argc,
if (clicon_option_add(h, "CLICON_RESTCONF_PRIVILEGES", "none") < 0)
goto done;
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)
goto done;
break;
@ -1372,7 +1382,7 @@ main(int argc,
retval = 0;
goto done;
}
/* Create and stroe global openssl handle */
/* Create and store global openssl handle */
if ((rn = malloc(sizeof *rn)) == NULL){
clixon_err(OE_UNIX, errno, "malloc");
goto done;

View file

@ -53,7 +53,7 @@
#define CLIXON_LOG_SYSLOG 0x01 /* print logs on syslog */
#define CLIXON_LOG_STDERR 0x02 /* print logs on stderr */
#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) */
enum clixon_log_type{

View file

@ -299,12 +299,11 @@ fi
test-pause
sleep 5
# Try parallell
# start background job
# Start curl in background and save PID
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=$!
new "Start subscriptions in parallell"
new "Start subscription"
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>"

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-rfc5277@2008-07-01.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
all:

View file

@ -53,6 +53,11 @@ module clixon-restconf {
***** END LICENSE BLOCK *****";
revision 2025-02-01 {
description
"Added timeout parameter
Released in Clixon 7.4";
}
revision 2022-03-21 {
description
"Added feature:
@ -186,7 +191,8 @@ module clixon-restconf {
leaf log-destination {
description
"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;
default syslog;
}
@ -243,6 +249,14 @@ module clixon-restconf {
"Path to server CA cert file
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 {
description
"List of server sockets that the restconf daemon listens to.
@ -272,7 +286,8 @@ module clixon-restconf {
}
container restconf {
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.
However, removing the presence leads to default config in all
clixon installations, even those which do not use backend-started restconf.