mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 21:33:02 +02:00
libsrx: Remove srx_require_module API
Not needed anymore since all YANG modules should be loaded at build.
This commit is contained in:
committed by
Tobias Waldekranz
parent
b1a6606728
commit
b9a8d65e61
@@ -1,6 +1,5 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/common.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
#include <jansson.h>
|
||||
#include <ftw.h>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
@@ -18,12 +17,6 @@
|
||||
#define XPATH "/infix-dhcp-client:dhcp-client"
|
||||
#define CACHE_TEMPLATE "/var/lib/misc/%s.cache"
|
||||
|
||||
static const struct srx_module_requirement reqs[] = {
|
||||
{ .dir = YANG_PATH_, .name = MODULE, .rev = "2024-01-30" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
||||
static char *ip_cache(const char *ifname, char *str, size_t len)
|
||||
{
|
||||
|
||||
@@ -407,10 +400,6 @@ int infix_dhcp_init(struct confd *confd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = srx_require_modules(confd->conn, reqs);
|
||||
if (rc)
|
||||
goto fail;
|
||||
|
||||
REGISTER_CHANGE(confd->session, MODULE, XPATH, 0, change, confd, &confd->sub);
|
||||
REGISTER_CHANGE(confd->cand, MODULE, XPATH"//.", SR_SUBSCR_UPDATE, cand, confd, &confd->sub);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <srx/common.h>
|
||||
#include <srx/lyx.h>
|
||||
#include <srx/srx_module.h>
|
||||
#include <srx/srx_val.h>
|
||||
|
||||
#include "core.h"
|
||||
@@ -51,13 +50,6 @@ struct mdns_svc {
|
||||
{ ssh, "ssh", "_ssh._tcp", 22, "Secure shell command line interface (CLI)", NULL },
|
||||
};
|
||||
|
||||
static const struct srx_module_requirement reqs[] = {
|
||||
{ .dir = YANG_PATH_, .name = "infix-services", .rev = "2024-04-08" },
|
||||
{ .dir = YANG_PATH_, .name = "ieee802-dot1ab-lldp", .rev = "2022-03-15" },
|
||||
{ .dir = YANG_PATH_, .name = "infix-lldp", .rev = "2023-08-23" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* On hostname changes we need to update the mDNS records, in particular
|
||||
* the ones advertising an adminurl (standarized by Apple), because they
|
||||
@@ -295,10 +287,6 @@ int infix_services_init(struct confd *confd)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = srx_require_modules(confd->conn, reqs);
|
||||
if (rc)
|
||||
goto fail;
|
||||
|
||||
REGISTER_CHANGE(confd->session, "infix-services", "/infix-services:mdns",
|
||||
0, mdns_change, confd, &confd->sub);
|
||||
REGISTER_MONITOR(confd->session, "ietf-system", "/ietf-system:system/hostname",
|
||||
|
||||
@@ -6,12 +6,11 @@ libsrx_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0:0:0
|
||||
libsrx_la_SOURCES = common.c common.h \
|
||||
helpers.c helpers.h \
|
||||
lyx.c lyx.h \
|
||||
srx_module.c srx_module.h \
|
||||
srx_val.c srx_val.h \
|
||||
systemv.c systemv.h
|
||||
|
||||
pkgincludedir = $(includedir)/srx
|
||||
pkginclude_HEADERS = common.h helpers.h lyx.h srx_module.h srx_val.h systemv.h
|
||||
pkginclude_HEADERS = common.h helpers.h lyx.h srx_val.h systemv.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libsrx.pc
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <syslog.h>
|
||||
#include <sysrepo.h>
|
||||
#include <sysrepo.h>
|
||||
#include "srx_module.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
extern int debug;
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <errno.h>
|
||||
#include <libyang/libyang.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "srx_module.h"
|
||||
|
||||
sr_error_t srx_require_module(sr_conn_ctx_t *conn, const struct srx_module_requirement *mr)
|
||||
{
|
||||
sr_error_t err = SR_ERR_OK;
|
||||
char *path;
|
||||
int len;
|
||||
|
||||
len = asprintf(&path, "%s%s%s.yang", mr->name, mr->rev ? "@" : "", mr->rev ? : "");
|
||||
if (len == -1) {
|
||||
ERROR("failed asprintf(): %s", strerror(errno));
|
||||
return SR_ERR_SYS;
|
||||
}
|
||||
|
||||
err = sr_install_module2(conn, path, mr->dir, mr->features, NULL,
|
||||
"root", "wheel", 0660, NULL, NULL, 0);
|
||||
free(path);
|
||||
if (err == SR_ERR_EXISTS) {
|
||||
/* Probably loaded as a dependency */
|
||||
err = 0;
|
||||
|
||||
/* Ensure all requested features are enabled */
|
||||
for (int i = 0; mr->features[i]; i++) {
|
||||
err = sr_enable_module_feature(conn, mr->name, mr->features[i]);
|
||||
if (err) {
|
||||
ERROR("failed enabling %s:%s, error %d", mr->name, mr->features[i], err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
sr_error_t srx_require_modules(sr_conn_ctx_t *conn, const struct srx_module_requirement *mrs)
|
||||
{
|
||||
sr_error_t err = SR_ERR_OK;
|
||||
|
||||
for (; mrs->name && !err; mrs++)
|
||||
err = srx_require_module(conn, mrs);
|
||||
|
||||
return err;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#ifndef CONFD_SR_EXT_H_
|
||||
#define CONFD_SR_EXT_H_
|
||||
|
||||
#include <sysrepo.h>
|
||||
|
||||
struct srx_module_requirement {
|
||||
const char *dir;
|
||||
const char *name;
|
||||
const char *rev;
|
||||
const char **features;
|
||||
};
|
||||
|
||||
sr_error_t srx_require_module(sr_conn_ctx_t *conn,
|
||||
const struct srx_module_requirement *mr);
|
||||
sr_error_t srx_require_modules(sr_conn_ctx_t *conn,
|
||||
const struct srx_module_requirement *mrs);
|
||||
|
||||
#endif /* CONFD_SR_EXT_H_ */
|
||||
Reference in New Issue
Block a user