mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
buildroot: bump to latest kkit branch for ugprades of sysrepo et al
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+1
-1
Submodule buildroot updated: b7cdb9b4b8...f5435bd048
@@ -0,0 +1,27 @@
|
||||
From 1175168ef202c32ce07a674b0c14678c5c130274 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Thu, 22 Jun 2023 10:24:57 +0200
|
||||
Subject: [PATCH] Allow 'factory' as copy-from (only) in rpc copy-config
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/netconf.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/netconf.c b/src/netconf.c
|
||||
index 840debb..fa778d5 100644
|
||||
--- a/src/netconf.c
|
||||
+++ b/src/netconf.c
|
||||
@@ -332,6 +332,8 @@ np2srv_rpc_copyconfig_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), con
|
||||
ds = SR_DS_STARTUP;
|
||||
} else if (!strcmp(nodeset->dnodes[0]->schema->name, "candidate")) {
|
||||
ds = SR_DS_CANDIDATE;
|
||||
+ } else if (!strcmp(nodeset->dnodes[0]->schema->name, "factory")) {
|
||||
+ ds = SR_DS_FACTORY_DEFAULT; /* only allowed as copy-from */
|
||||
} else {
|
||||
assert(!strcmp(nodeset->dnodes[0]->schema->name, "url"));
|
||||
#ifdef NP2SRV_URL_CAPAB
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
From 519b1368bf36cda4bc761c6390697cc730e73f63 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 24 May 2023 06:55:41 +0200
|
||||
Subject: [PATCH] netopeer2-server: add support for running in foreground with
|
||||
syslog
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
doc/netopeer2-server.8 | 7 +++++--
|
||||
src/main.c | 9 +++++++--
|
||||
2 files changed, 12 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/doc/netopeer2-server.8 b/doc/netopeer2-server.8
|
||||
index 4caf0f7..617c552 100644
|
||||
--- a/doc/netopeer2-server.8
|
||||
+++ b/doc/netopeer2-server.8
|
||||
@@ -2,13 +2,13 @@
|
||||
.\" groff -man -Tascii netopeer2-server.8
|
||||
.\"
|
||||
|
||||
-.TH "netopeer2-server" 8 "2021-11-10" "Netopeer"
|
||||
+.TH "netopeer2-server" 8 "2023-05-25" "Netopeer"
|
||||
.SH NAME
|
||||
netopeer2-server \- NETCONF server daemon build on libnetconf2 with sysrepo datastore
|
||||
.
|
||||
.SH SYNOPSIS
|
||||
.B netopeer2-server
|
||||
-[\fB-dhV\fP] [\fB-p\fP \fIPATH\fP] [\fB-U\fP[\fIPATH\fP]] [\fB-m\fP \fIMODE\fP] [\fB-u\fP \fIUID\fP]
|
||||
+[\fB-dFhV\fP] [\fB-p\fP \fIPATH\fP] [\fB-U\fP[\fIPATH\fP]] [\fB-m\fP \fIMODE\fP] [\fB-u\fP \fIUID\fP]
|
||||
[\fB-g\fP \fIGID\fP] [\fB-t\fP \fITIMEOUT\fP] [\fB-v\fP \fILEVEL\fP] [\fB-c\fP \fICATEGORY\fP]
|
||||
.br
|
||||
.
|
||||
@@ -22,6 +22,9 @@ YANG module data in sysrepo.
|
||||
.BR "\-d"
|
||||
Debug mode (do not daemonize and print verbose messages to stderr instead of syslog).
|
||||
.TP
|
||||
+.BR "\-F"
|
||||
+Run in foreground (do not daemonize) and log to syslog.
|
||||
+.TP
|
||||
.BR "\-h"
|
||||
Display help.
|
||||
.TP
|
||||
diff --git a/src/main.c b/src/main.c
|
||||
index 59cc87e..b210d40 100644
|
||||
--- a/src/main.c
|
||||
+++ b/src/main.c
|
||||
@@ -1078,9 +1078,10 @@ print_version(void)
|
||||
static void
|
||||
print_usage(char *progname)
|
||||
{
|
||||
- fprintf(stdout, "Usage: %s [-dhV] [-p PATH] [-U[PATH]] [-m MODE] [-u UID] [-g GID] [-t TIMEOUT] [-x PATH]\n", progname);
|
||||
+ fprintf(stdout, "Usage: %s [-dFhV] [-p PATH] [-U[PATH]] [-m MODE] [-u UID] [-g GID] [-t TIMEOUT] [-x PATH]\n", progname);
|
||||
fprintf(stdout, " [-v LEVEL] [-c CATEGORY]\n");
|
||||
fprintf(stdout, " -d Debug mode (do not daemonize and print verbose messages to stderr instead of syslog).\n");
|
||||
+ fprintf(stdout, " -F Run in foreground, like -d, but log to syslog.\n");
|
||||
fprintf(stdout, " -h Display help.\n");
|
||||
fprintf(stdout, " -V Show program version.\n");
|
||||
fprintf(stdout, " -p PATH Path to pidfile (default path is \"%s\").\n", NP2SRV_PID_FILE_PATH);
|
||||
@@ -1152,11 +1153,15 @@ main(int argc, char *argv[])
|
||||
np2srv.server_dir = SERVER_DIR;
|
||||
|
||||
/* process command line options */
|
||||
- while ((c = getopt(argc, argv, "dhVp:f:U::m:u:g:n:i:t:x:v:c:")) != -1) {
|
||||
+ while ((c = getopt(argc, argv, "dFhVp:f:U::m:u:g:n:i:t:x:v:c:")) != -1) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
daemonize = 0;
|
||||
break;
|
||||
+ case 'F':
|
||||
+ daemonize = 0;
|
||||
+ np2_stderr_log = 0;
|
||||
+ break;
|
||||
case 'h':
|
||||
print_usage(argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
+20
-13
@@ -1,16 +1,20 @@
|
||||
commit 6fc440089353d76a9b8cb7c480402ee911a1387d
|
||||
Author: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Tue Mar 28 10:37:53 2023 +0200
|
||||
From 49c660c412342e1af76735e75cd3f286ae655b82 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Tue, 28 Mar 2023 10:37:53 +0200
|
||||
Subject: [PATCH 1/4] sysrepo-plugind: add support for running in foreground
|
||||
with syslog
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
sysrepo-plugind: add support for running in foreground with syslog
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/executables/sysrepo-plugind.c | 10 +++++++++-
|
||||
1 file changed, 9 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/executables/sysrepo-plugind.c b/src/executables/sysrepo-plugind.c
|
||||
index bd584ed5..3079a855 100644
|
||||
index 9ab59cb3..e689f930 100644
|
||||
--- a/src/executables/sysrepo-plugind.c
|
||||
+++ b/src/executables/sysrepo-plugind.c
|
||||
@@ -97,6 +97,7 @@ help_print(void)
|
||||
@@ -98,6 +98,7 @@ help_print(void)
|
||||
" Change verbosity to a level (none, error, warning, info, debug) or\n"
|
||||
" number (0, 1, 2, 3, 4).\n"
|
||||
" -d, --debug Debug mode - is not daemonized and logs to stderr instead of syslog.\n"
|
||||
@@ -18,7 +22,7 @@ index bd584ed5..3079a855 100644
|
||||
" -P, --plugin-install <path>\n"
|
||||
" Install a sysrepo-plugind plugin. The plugin is simply copied\n"
|
||||
" to the designated plugin directory.\n"
|
||||
@@ -200,6 +201,8 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
@@ -201,6 +202,8 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
|
||||
if (debug) {
|
||||
handle_signals();
|
||||
@@ -27,7 +31,7 @@ index bd584ed5..3079a855 100644
|
||||
sr_log_stderr(log_level);
|
||||
return;
|
||||
}
|
||||
@@ -240,6 +243,7 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
@@ -241,6 +244,7 @@ daemon_init(int debug, sr_log_level_t log_level)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@@ -35,7 +39,7 @@ index bd584ed5..3079a855 100644
|
||||
/* set verbosity */
|
||||
sr_log_syslog("sysrepo-plugind", log_level);
|
||||
}
|
||||
@@ -459,6 +463,7 @@ main(int argc, char **argv)
|
||||
@@ -466,6 +470,7 @@ main(int argc, char **argv)
|
||||
{"version", no_argument, NULL, 'V'},
|
||||
{"verbosity", required_argument, NULL, 'v'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
@@ -43,7 +47,7 @@ index bd584ed5..3079a855 100644
|
||||
{"plugin-install", required_argument, NULL, 'P'},
|
||||
{"pid-file", required_argument, NULL, 'p'},
|
||||
{"fatal-plugin-fail", no_argument, NULL, 'f'},
|
||||
@@ -467,7 +472,7 @@ main(int argc, char **argv)
|
||||
@@ -474,7 +479,7 @@ main(int argc, char **argv)
|
||||
|
||||
/* process options */
|
||||
opterr = 0;
|
||||
@@ -52,7 +56,7 @@ index bd584ed5..3079a855 100644
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
version_print();
|
||||
@@ -499,6 +504,9 @@ main(int argc, char **argv)
|
||||
@@ -506,6 +511,9 @@ main(int argc, char **argv)
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
@@ -62,3 +66,6 @@ index bd584ed5..3079a855 100644
|
||||
case 'P':
|
||||
/* plugin-install */
|
||||
if (get_plugins_dir(&plugins_dir)) {
|
||||
--
|
||||
2.34.1
|
||||
|
||||
+13
-12
@@ -1,7 +1,8 @@
|
||||
From 5e919a20585392b4f2e0344bee2ac54d59c91ba4 Mon Sep 17 00:00:00 2001
|
||||
From 87224ddce4ed1a118b3efb24e0dc7167f8754c22 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Wed, 7 Jun 2023 15:19:13 +0200
|
||||
Subject: [PATCH] Refactor _sr_install_modules() to use ly_ctx_load_module()
|
||||
Subject: [PATCH 2/4] Refactor _sr_install_modules() to use
|
||||
ly_ctx_load_module()
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
This fixes issues with sysrepo discarding searchpaths and thus not
|
||||
@@ -16,10 +17,10 @@ Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
3 files changed, 22 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/common.c b/src/common.c
|
||||
index 08630446..84149063 100644
|
||||
index f8acfb81..bef98f9a 100644
|
||||
--- a/src/common.c
|
||||
+++ b/src/common.c
|
||||
@@ -3601,7 +3601,7 @@ sr_get_trim_predicates(const char *expr, char **expr2)
|
||||
@@ -3596,7 +3596,7 @@ sr_get_trim_predicates(const char *expr, char **expr2)
|
||||
}
|
||||
|
||||
sr_error_info_t *
|
||||
@@ -28,7 +29,7 @@ index 08630446..84149063 100644
|
||||
{
|
||||
sr_error_info_t *err_info = NULL;
|
||||
const char *ptr;
|
||||
@@ -3631,6 +3631,9 @@ sr_get_schema_name_format(const char *schema_path, char **module_name, LYS_INFOR
|
||||
@@ -3626,6 +3626,9 @@ sr_get_schema_name_format(const char *schema_path, char **module_name, LYS_INFOR
|
||||
if (ptr) {
|
||||
/* truncate revision */
|
||||
((char *)ptr)[0] = '\0';
|
||||
@@ -39,7 +40,7 @@ index 08630446..84149063 100644
|
||||
|
||||
return NULL;
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index d955ba49..d8448da4 100644
|
||||
index 00cc909f..ca5c08ca 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -958,10 +958,11 @@ sr_error_info_t *sr_get_trim_predicates(const char *expr, char **expr2);
|
||||
@@ -56,10 +57,10 @@ index d955ba49..d8448da4 100644
|
||||
/**
|
||||
* @brief Get datastore string name.
|
||||
diff --git a/src/sysrepo.c b/src/sysrepo.c
|
||||
index 7271c273..2c0d61fd 100644
|
||||
index 1387ea9d..ee30c462 100644
|
||||
--- a/src/sysrepo.c
|
||||
+++ b/src/sysrepo.c
|
||||
@@ -1226,6 +1226,10 @@ sr_install_module_set_searchdirs(struct ly_ctx *new_ctx, const char *search_dirs
|
||||
@@ -1243,6 +1243,10 @@ sr_install_module_set_searchdirs(struct ly_ctx *new_ctx, const char *search_dirs
|
||||
sdirs_str = strdup(search_dirs);
|
||||
SR_CHECK_MEM_GOTO(!sdirs_str, err_info, cleanup);
|
||||
|
||||
@@ -70,7 +71,7 @@ index 7271c273..2c0d61fd 100644
|
||||
/* add each search dir */
|
||||
for (ptr = strtok_r(sdirs_str, ":", &ptr2); ptr; ptr = strtok_r(NULL, ":", &ptr2)) {
|
||||
if (!ly_ctx_set_searchdir(new_ctx, ptr)) {
|
||||
@@ -1304,15 +1308,15 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
@@ -1321,15 +1325,15 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
{
|
||||
sr_error_info_t *err_info = NULL;
|
||||
const struct lys_module *ly_mod;
|
||||
@@ -88,7 +89,7 @@ index 7271c273..2c0d61fd 100644
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -1345,14 +1349,9 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
@@ -1362,14 +1366,9 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ index 7271c273..2c0d61fd 100644
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -1375,8 +1374,12 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
@@ -1392,8 +1391,12 @@ sr_install_modules_prepare_mod(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, sr_i
|
||||
}
|
||||
|
||||
cleanup:
|
||||
@@ -121,7 +122,7 @@ index 7271c273..2c0d61fd 100644
|
||||
return err_info;
|
||||
}
|
||||
|
||||
@@ -1834,7 +1837,7 @@ sr_update_modules_prepare(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, const cha
|
||||
@@ -1851,7 +1854,7 @@ sr_update_modules_prepare(struct ly_ctx *new_ctx, sr_conn_ctx_t *conn, const cha
|
||||
for (i = 0; i < schema_path_count; ++i) {
|
||||
/* learn about the module */
|
||||
upd_mods[i].schema_path = schema_paths[i];
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
From bef358ba11b01c248b45fbe003d8d3ded0acb657 Mon Sep 17 00:00:00 2001
|
||||
From 2d3b9524b1448dd6a8ef83e4e101e509d2552dcc Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Fri, 16 Jun 2023 12:13:16 +0200
|
||||
Subject: [PATCH 2/2] Add support for loading /etc/sysrepo/factory-default
|
||||
Subject: [PATCH 3/4] Add support for loading /etc/sysrepo/factory-default
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Follow-up to 3d07270 which adds support for compile-time defaults, this
|
||||
@@ -16,10 +16,10 @@ Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
3 files changed, 57 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/common.c b/src/common.c
|
||||
index 84149063..ff9ba96e 100644
|
||||
index bef98f9a..bbb0c949 100644
|
||||
--- a/src/common.c
|
||||
+++ b/src/common.c
|
||||
@@ -1317,6 +1317,35 @@ sr_path_conn_lockfile(sr_cid_t cid, int creat, char **path)
|
||||
@@ -1306,6 +1306,35 @@ sr_path_conn_lockfile(sr_cid_t cid, int creat, char **path)
|
||||
return err_info;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ index 84149063..ff9ba96e 100644
|
||||
sr_remove_evpipes(void)
|
||||
{
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index d8448da4..37f7ede6 100644
|
||||
index ca5c08ca..e8d394ef 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -479,6 +479,17 @@ sr_error_info_t *sr_path_yang_file(const char *mod_name, const char *mod_rev, ch
|
||||
@@ -1,186 +0,0 @@
|
||||
From 429d89a2254b29cd51758e4c6d2f7178d8b2120a Mon Sep 17 00:00:00 2001
|
||||
From: Michal Vasko <mvasko@cesnet.cz>
|
||||
Date: Thu, 15 Jun 2023 09:36:57 +0200
|
||||
Subject: [PATCH 1/2] lyd mods UPDATE allow custom start data for internal
|
||||
modules
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Compile-time variable with the path to a file with the data.
|
||||
NOTE: Squashed two upstream commits in backport to kkit.
|
||||
|
||||
Signed-off-by: Michal Vasko <mvasko@cesnet.cz>
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
CMakeLists.txt | 24 +++++++++++++++-
|
||||
README.md | 5 ++++
|
||||
src/config.h.in | 4 +++
|
||||
src/lyd_mods.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
4 files changed, 103 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index f4b0b2f2..08480779 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -100,7 +100,29 @@ endif()
|
||||
option(ENABLE_EXAMPLES "Build examples." ON)
|
||||
option(ENABLE_COVERAGE "Build code coverage report from tests" OFF)
|
||||
option(INSTALL_SYSCTL_CONF "Install sysctl conf file to allow shared access to SHM files." OFF)
|
||||
-set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/sysrepo" CACHE STRING "Directory where to copy the YANG modules to")
|
||||
+set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/sysrepo" CACHE STRING "Directory where to copy the YANG modules to.")
|
||||
+set(INTERNAL_MODULE_DATA_PATH "" CACHE STRING "Path to a file with startup and factory-default data of internal modules. Contents of the file are compiled into the library.")
|
||||
+if(INTERNAL_MODULE_DATA_PATH)
|
||||
+ if(NOT EXISTS "${INTERNAL_MODULE_DATA_PATH}")
|
||||
+ message(FATAL_ERROR "File \"${INTERNAL_MODULE_DATA_PATH}\" does not exist.")
|
||||
+ endif()
|
||||
+ string(REGEX MATCH "[.](xml|json)$" EXT ${INTERNAL_MODULE_DATA_PATH})
|
||||
+ if(NOT EXT)
|
||||
+ message(FATAL_ERROR "File \"${INTERNAL_MODULE_DATA_PATH}\" with an unknown extension.")
|
||||
+ endif()
|
||||
+
|
||||
+ file(READ "${INTERNAL_MODULE_DATA_PATH}" INTERNAL_MODULE_DATA_RAW)
|
||||
+ string(REPLACE "\n" "\\\n" INTERNAL_MODULE_DATA ${INTERNAL_MODULE_DATA_RAW})
|
||||
+
|
||||
+ if(${EXT} STREQUAL ".xml")
|
||||
+ set(INTERNAL_MODULE_DATA_FORMAT LYD_XML)
|
||||
+ else()
|
||||
+ set(INTERNAL_MODULE_DATA_FORMAT LYD_JSON)
|
||||
+ endif()
|
||||
+else()
|
||||
+ # empty data but the code needs a format
|
||||
+ set(INTERNAL_MODULE_DATA_FORMAT LYD_XML)
|
||||
+endif()
|
||||
|
||||
# ietf-yang-library revision
|
||||
set(YANGLIB_REVISION "2019-01-04" CACHE STRING
|
||||
diff --git a/README.md b/README.md
|
||||
index 3d0e7aa4..39c47473 100644
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -147,6 +147,11 @@ Set [NACM](#NACM) configuration data and 'sysrepo-monitoring' default permission
|
||||
```
|
||||
-DNACM_SRMON_DATA_PERM=000
|
||||
```
|
||||
+
|
||||
+Set `startup` and `factory-default` datastore data for internal modules (such as `ietf-netconf-acm`):
|
||||
+```
|
||||
+-DINTERNAL_MODULE_DATA_PATH=/etc/config/factory_default_config.xml
|
||||
+```
|
||||
### Useful CMake Build Options
|
||||
|
||||
#### Changing Compiler
|
||||
diff --git a/src/config.h.in b/src/config.h.in
|
||||
index 92040b0e..7f7b915c 100644
|
||||
--- a/src/config.h.in
|
||||
+++ b/src/config.h.in
|
||||
@@ -76,6 +76,10 @@
|
||||
/** if not set, defaults to "SR_REPO_PATH/yang" */
|
||||
#define SR_YANG_PATH "@YANG_MODULE_PATH@"
|
||||
|
||||
+/** internal module startup and factory-default data and their format */
|
||||
+#define SR_INT_MOD_DATA "@INTERNAL_MODULE_DATA@"
|
||||
+#define SR_INT_MOD_DATA_FORMAT @INTERNAL_MODULE_DATA_FORMAT@
|
||||
+
|
||||
/** where SHM files are stored */
|
||||
#define SR_SHM_DIR "@SHM_DIR@"
|
||||
|
||||
diff --git a/src/lyd_mods.c b/src/lyd_mods.c
|
||||
index 13397fa8..94e97b97 100644
|
||||
--- a/src/lyd_mods.c
|
||||
+++ b/src/lyd_mods.c
|
||||
@@ -4,8 +4,8 @@
|
||||
* @brief Sysrepo module data routines
|
||||
*
|
||||
* @copyright
|
||||
- * Copyright (c) 2018 - 2022 Deutsche Telekom AG.
|
||||
- * Copyright (c) 2018 - 2022 CESNET, z.s.p.o.
|
||||
+ * Copyright (c) 2018 - 2023 Deutsche Telekom AG.
|
||||
+ * Copyright (c) 2018 - 2023 CESNET, z.s.p.o.
|
||||
*
|
||||
* This source code is licensed under BSD 3-Clause License (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
@@ -943,6 +943,70 @@ sr_lydmods_print(struct lyd_node **sr_mods)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * @brief Set startup and factory-default datastore data for implemented internal modules.
|
||||
+ *
|
||||
+ * @param[in] ly_ctx Context with the internal modules.
|
||||
+ * @return err_info, NULL on success.
|
||||
+ */
|
||||
+static sr_error_info_t *
|
||||
+sr_lydmods_create_data(const struct ly_ctx *ly_ctx)
|
||||
+{
|
||||
+ sr_error_info_t *err_info = NULL;
|
||||
+ const struct lys_module *ly_mod;
|
||||
+ struct lyd_node *data = NULL, *mod_data = NULL, *mod_diff = NULL;
|
||||
+ uint32_t idx = 0;
|
||||
+ int rc;
|
||||
+
|
||||
+ if (!strlen(SR_INT_MOD_DATA)) {
|
||||
+ /* no data to set */
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ /* parse and validate the data */
|
||||
+ if (lyd_parse_data_mem(ly_ctx, SR_INT_MOD_DATA, SR_INT_MOD_DATA_FORMAT, 0, LYD_VALIDATE_NO_STATE, &data)) {
|
||||
+ sr_errinfo_new_ly(&err_info, ly_ctx, NULL);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ while ((ly_mod = ly_ctx_get_module_iter(ly_ctx, &idx))) {
|
||||
+ if (!ly_mod->implemented) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* get the data for this module */
|
||||
+ lyd_free_siblings(mod_data);
|
||||
+ mod_data = sr_module_data_unlink(&data, ly_mod);
|
||||
+ if (!mod_data) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ /* generate a diff */
|
||||
+ lyd_free_siblings(mod_diff);
|
||||
+ if (lyd_diff_siblings(NULL, mod_data, LYD_DIFF_DEFAULTS, &mod_diff)) {
|
||||
+ sr_errinfo_new_ly(&err_info, ly_ctx, mod_data);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ assert(mod_diff);
|
||||
+
|
||||
+ /* store the data using the internal JSON plugin */
|
||||
+ if ((rc = srpds_json.store_cb(ly_mod, SR_DS_STARTUP, mod_diff, mod_data))) {
|
||||
+ SR_ERRINFO_DSPLUGIN(&err_info, rc, "store", srpds_json.name, ly_mod->name);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ if ((rc = srpds_json.store_cb(ly_mod, SR_DS_FACTORY_DEFAULT, mod_diff, mod_data))) {
|
||||
+ SR_ERRINFO_DSPLUGIN(&err_info, rc, "store", srpds_json.name, ly_mod->name);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+cleanup:
|
||||
+ lyd_free_siblings(mod_data);
|
||||
+ lyd_free_siblings(mod_diff);
|
||||
+ lyd_free_siblings(data);
|
||||
+ return err_info;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* @brief Create default sysrepo module data. All libyang internal implemented modules
|
||||
* are installed into sysrepo. Sysrepo internal modules ietf-netconf, ietf-netconf-with-defaults,
|
||||
@@ -1042,6 +1106,11 @@ sr_lydmods_create(struct ly_ctx *ly_ctx, struct lyd_node **sr_mods_p)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
+ /* set the startup and factory-default data, if any */
|
||||
+ if ((err_info = sr_lydmods_create_data(ly_ctx))) {
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
cleanup:
|
||||
free(new_mods);
|
||||
if (err_info) {
|
||||
--
|
||||
2.34.1
|
||||
|
||||
+12
-12
@@ -1,18 +1,18 @@
|
||||
From 1d5954d87cdc8a180d917a1d807000e0b4a3a2de Mon Sep 17 00:00:00 2001
|
||||
From 7726017815243818f07936e4ff3bb979e9291f04 Mon Sep 17 00:00:00 2001
|
||||
From: Joachim Wiberg <troglobit@gmail.com>
|
||||
Date: Fri, 16 Jun 2023 16:17:27 +0200
|
||||
Subject: [PATCH] sysrepoctl: add support for -Cfactory -d running
|
||||
Subject: [PATCH 4/4] sysrepoctl: add support for -Cfactory -d running
|
||||
Organization: Addiva Elektronik
|
||||
|
||||
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
|
||||
---
|
||||
src/common.h | 3 +++
|
||||
src/executables/sysrepocfg.c | 2 ++
|
||||
src/executables/sysrepocfg.c | 2 +-
|
||||
src/sysrepo.c | 2 +-
|
||||
3 files changed, 6 insertions(+), 1 deletion(-)
|
||||
3 files changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/common.h b/src/common.h
|
||||
index 37f7ede6..a092728f 100644
|
||||
index e8d394ef..39fcce3a 100644
|
||||
--- a/src/common.h
|
||||
+++ b/src/common.h
|
||||
@@ -42,6 +42,9 @@ struct srplg_ntf_s;
|
||||
@@ -26,23 +26,23 @@ index 37f7ede6..a092728f 100644
|
||||
#define SR_IS_STANDARD_DS(ds) (SR_IS_CONVENTIONAL_DS(ds) || (ds == SR_DS_OPERATIONAL))
|
||||
|
||||
diff --git a/src/executables/sysrepocfg.c b/src/executables/sysrepocfg.c
|
||||
index 4067063c..839f093b 100644
|
||||
index 0c719e2c..65e56696 100644
|
||||
--- a/src/executables/sysrepocfg.c
|
||||
+++ b/src/executables/sysrepocfg.c
|
||||
@@ -647,6 +647,8 @@ arg_get_ds(const char *optarg, sr_datastore_t *ds)
|
||||
@@ -730,7 +730,7 @@ arg_get_ds(const char *optarg, sr_datastore_t *ds)
|
||||
*ds = SR_DS_CANDIDATE;
|
||||
} else if (!strcmp(optarg, "operational")) {
|
||||
*ds = SR_DS_OPERATIONAL;
|
||||
+ } else if (!strcmp(optarg, "factory")) {
|
||||
+ *ds = SR_DS_FACTORY_DEFAULT;
|
||||
- } else if (!strcmp(optarg, "factory-default")) {
|
||||
+ } else if (!strcmp(optarg, "factory-default") || !strcmp(optarg, "factory")) {
|
||||
*ds = SR_DS_FACTORY_DEFAULT;
|
||||
} else {
|
||||
error_print(0, "Unknown datastore \"%s\"", optarg);
|
||||
return -1;
|
||||
diff --git a/src/sysrepo.c b/src/sysrepo.c
|
||||
index 2c0d61fd..26c65851 100644
|
||||
index ee30c462..ca2a20b7 100644
|
||||
--- a/src/sysrepo.c
|
||||
+++ b/src/sysrepo.c
|
||||
@@ -4012,7 +4012,7 @@ sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_
|
||||
@@ -4037,7 +4037,7 @@ sr_copy_config(sr_session_ctx_t *session, const char *module_name, sr_datastore_
|
||||
struct sr_mod_info_s mod_info;
|
||||
const struct lys_module *ly_mod = NULL;
|
||||
|
||||
Reference in New Issue
Block a user