Skip to content

Commit 94e29bd

Browse files
committed
init: add a info log to inform user about sysrepo module loading
Signed-off-by: ali aqrabawi <aaqrabaw@okdanetworks.com>
1 parent 8ebb6f7 commit 94e29bd

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

src/commands/yang_core/data_factory.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
9595
}
9696

9797
sprintf(xpath, "%s", get_relative_path(y_node));
98-
struct lyd_node *curr_parent, *new_parent = NULL;
98+
struct lyd_node *curr_parent = NULL, *new_parent = NULL;
9999
// set current parent and xpath based on the list location in the tree.
100100
if (parent_data == NULL) {
101101
lysc_path(y_node, LYSC_PATH_DATA, xpath, 256);
@@ -124,22 +124,19 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
124124
struct lyd_node *next = NULL;
125125
struct lyd_node *orderd_nodes = lyd_first_sibling(new_parent);
126126

127-
LY_LIST_FOR(orderd_nodes, next)
128-
{
127+
LY_LIST_FOR(orderd_nodes, next) {
129128
if (index < curr_indx) {
130129
ret = lyd_insert_before(next, new_parent);
131130
if (ret != LY_SUCCESS) {
132131
lyd_free_tree(new_parent);
133132
goto done;
134133
}
135134
break;
136-
137135
}
138136
curr_indx += 10;
139137
}
140138
}
141139
if (edit_type == EDIT_DATA_ADD) {
142-
143140
if (!item_found) {
144141
ret = sr_set_item(sysrepo_get_session(), all_xpath, NULL, 0);
145142
if (ret != SR_ERR_OK)
@@ -152,14 +149,13 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
152149
ret = sr_delete_item(sysrepo_get_session(), all_xpath, 0);
153150
if (ret != SR_ERR_OK)
154151
goto done;
155-
}
156-
else
152+
} else
157153
cli_print(cli, " item not found in datastore!");
158154
lyd_free_tree(new_parent);
159155
}
160156

161157

162-
done:
158+
done:
163159
if (ret != LY_SUCCESS) {
164160
print_ly_err(ly_err_first(sysrepo_ctx), "data_factory.c", cli);
165161
}
@@ -175,8 +171,7 @@ int add_data_node_list(struct lysc_node *y_node, int index, struct cli_def *cli,
175171
}
176172

177173
int delete_data_node_list(struct lysc_node *y_node, struct cli_def *cli) {
178-
return edit_node_data_tree_list(y_node, EDIT_DATA_DEL, 0, cli, 0);// no index use key for delete
179-
174+
return edit_node_data_tree_list(y_node, EDIT_DATA_DEL, 0, cli, 0); // no index use key for delete
180175
}
181176

182177

@@ -185,7 +180,7 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
185180
char xpath[256];
186181
memset(xpath, '\0', 256);
187182
struct ly_ctx *sysrepo_ctx = (struct ly_ctx *) sysrepo_get_ctx();
188-
183+
char all_xpath[1024] = {0};
189184

190185
if (!sysrepo_ctx) {
191186
LOG_ERROR(" add_data_node(): Failure: failed to get sysrepo_ctx");
@@ -225,7 +220,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
225220
else {
226221
lyd_free_tree(new_parent);
227222
if (item_found) {
228-
char all_xpath[1024] = {0};
229223
lyd_path(parent_data, LYD_PATH_STD, all_xpath, 1024);
230224
strlcat(all_xpath, "/", sizeof(all_xpath));
231225
strlcat(all_xpath, xpath, sizeof(all_xpath));
@@ -237,7 +231,7 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
237231
break;
238232
}
239233
}
240-
break;
234+
break;
241235

242236
case LYS_LEAF:
243237
case LYS_LEAFLIST:
@@ -248,7 +242,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
248242

249243
struct lyd_node *new_leaf = NULL;
250244
int item_found = 1;
251-
char all_xpath[1024] = {0};
252245
lyd_path(parent_data, LYD_PATH_STD, all_xpath, 1024);
253246
strlcat(all_xpath, "/", sizeof(all_xpath));
254247
strlcat(all_xpath, xpath, sizeof(all_xpath));
@@ -270,7 +263,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
270263
if (ret != SR_ERR_OK)
271264
break;
272265
}
273-
274266
} else {
275267
lyd_free_tree(new_leaf);
276268
if (item_found) {
@@ -281,7 +273,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
281273
cli_print(cli, " item not found in datastore!");
282274
}
283275
break;
284-
285276
}
286277
if (ret != LY_SUCCESS)
287278
print_ly_err(ly_err_first(sysrepo_ctx), "data_factory.c", cli);

src/onm_cli.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ int onm_cli_init() {
4040
cli = cli_init();
4141
char banner[1024];
4242
memset(banner, '\0', 1024);
43-
sprintf(banner, "\n\nonmcli version: %s.%s.%s\nby Okda networks (c) 2024", MAJOR, MINOR, PATCH);
43+
sprintf(banner, "\n\nonmcli version: %s.%s.%s\nby Okda Networks (c) 2025", MAJOR, MINOR, PATCH);
4444

4545
cli_telnet_protocol(cli, 0);
4646
cli_set_banner(cli, banner);

src/onm_logger.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,5 @@ void onm_logger_close() {
106106
int onm_logger_init() {
107107
// Initialize the logger
108108
initLogger(LOGFILE_NAME);
109-
110-
111109
return 0;
112-
}
110+
}

src/onm_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ int main() {
6666
return -1;
6767
}
6868

69+
printf("[INF] Loading Sysrepo3 modules... This may take time.\n");
70+
6971
ret = onm_sysrepo_init();
7072
if (ret != EXIT_SUCCESS) {
7173
LOG_ERROR("failed to initialize yang context: existing...");
@@ -87,5 +89,5 @@ int main() {
8789
onm_sysrepo_done();
8890

8991
LOG_INFO("onmcli exiting...");
90-
92+
return 0;
9193
}

0 commit comments

Comments
 (0)