Skip to content

Commit

Permalink
ietf-system-augeas: add hostname load functionality to the main plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
zinccyy committed Feb 9, 2023
1 parent fc9487f commit 232563d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/plugins/ietf-system/datastore/running/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include <utlist.h>

static int system_startup_load_hostname(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node);
static int system_startup_load_contact(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node);
static int system_startup_load_location(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node);
static int system_startup_load_timezone_name(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node);
Expand All @@ -57,6 +58,10 @@ int system_running_ds_load(system_ctx_t *ctx, sr_session_ctx_t *session)
sr_conn_ctx_t *conn_ctx = NULL;

srpc_startup_load_t load_values[] = {
{
"hostname",
system_startup_load_hostname,
},
{
"contact",
system_startup_load_contact,
Expand Down Expand Up @@ -133,6 +138,33 @@ int system_running_ds_load(system_ctx_t *ctx, sr_session_ctx_t *session)
return error;
}

static int system_startup_load_hostname(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node)
{
int error = 0;
system_ctx_t *ctx = (system_ctx_t *) priv;
char hostname_buffer[SYSTEM_HOSTNAME_LENGTH_MAX] = {0};

error = system_load_hostname(ctx, hostname_buffer);
if (error) {
SRPLG_LOG_ERR(PLUGIN_NAME, "system_load_hostname() error (%d)", error);
goto error_out;
}

error = system_ly_tree_create_hostname(ly_ctx, parent_node, hostname_buffer);
if (error) {
SRPLG_LOG_ERR(PLUGIN_NAME, "system_ly_tree_create_hostname() error (%d)", error);
goto error_out;
}

goto out;

error_out:
error = -1;

out:
return error;
}

static int system_startup_load_contact(void *priv, sr_session_ctx_t *session, const struct ly_ctx *ly_ctx, struct lyd_node *parent_node)
{
int error = 0;
Expand Down

0 comments on commit 232563d

Please sign in to comment.