X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fntsim-ng%2Fcore%2Fapp%2Fnetwork_function.c;h=e34d85c2e8b03485e9b54f7c761d92ce9a997747;hb=338a7e9c4ad76118e73cfda7bc6241d628e1c925;hp=d7909c4db1f5a72ccbd19920ffaea70bd1876f2e;hpb=fd9a6164f9cff51682fcebe77f53d99b8d882bc7;p=sim%2Fo1-interface.git diff --git a/ntsimulator/ntsim-ng/core/app/network_function.c b/ntsimulator/ntsim-ng/core/app/network_function.c index d7909c4..e34d85c 100644 --- a/ntsimulator/ntsim-ng/core/app/network_function.c +++ b/ntsimulator/ntsim-ng/core/app/network_function.c @@ -33,6 +33,7 @@ #include "core/context.h" #include "core/session.h" #include "core/xpath.h" +#include "core/datastore/schema.h" #include "core/datastore/populate.h" #include "core/faults/faults.h" @@ -43,8 +44,10 @@ #include "features/manual_notification/manual_notification.h" #include "features/netconf_call_home/netconf_call_home.h" #include "features/web_cut_through/web_cut_through.h" +#include "features/ves_o1_pnf_registration/ves_o1_pnf_registration.h" #include "app_common.h" +#include "nf_oran_du.h" #define NF_FUNCTION_CONTROL_BUFFER_LENGTH 32 @@ -216,6 +219,14 @@ int network_function_run(void) { log_add(1,"\n"); } + if(strcmp(framework_environment.nts.function_type, "NTS_FUNCTION_TYPE_O_RAN_O_DU") == 0) { + rc = nf_oran_du_init(); + if(rc != NTS_ERR_OK) { + log_error("nf_oran_du_init failed\n"); + return NTS_ERR_FAILED; + } + } + while(!framework_sigint) { pthread_mutex_lock(&nf_function_control_lock); while(nf_function_control_buffer_in != nf_function_control_buffer_out) { @@ -227,10 +238,36 @@ int network_function_run(void) { } if(strstr(nf_function_control_string, "datastore-populate") != 0) { - rc = datastore_populate(3); + rc = datastore_populate_all(); if(rc != NTS_ERR_OK) { - log_error("datastore_populate() failed\n"); + log_error("datastore_populate_all() failed\n"); + } + + //subscribe to any changes so the operational is dynamic + char **xpaths = 0; + char **modules = 0; + int xpaths_count = datastore_schema_get_running_xpaths(&xpaths, &modules); + if(xpaths_count < 0) { + log_error("datastore_schema_get_running_xpaths failed\n"); + return NTS_ERR_FAILED; + } + + for(int i = 0; i < xpaths_count; i++) { + //subscribe + log_add_verbose(1, "subscribing to %s on module %s... ", xpaths[i], modules[i]); + rc = sr_module_change_subscribe(session_running, modules[i], xpaths[i], datastore_dynamic_operational_auto_callback, 0, 0, SR_SUBSCR_DONE_ONLY | SR_SUBSCR_CTX_REUSE, &session_subscription); + if(rc != SR_ERR_OK) { + log_error("sr_module_change_subscribe error\n"); + } + else { + log_add(1, "done\n"); + } + + free(xpaths[i]); + free(modules[i]); } + free(modules); + free(xpaths); } if(strstr(nf_function_control_string, "ves-file-ready") != 0) { @@ -260,6 +297,16 @@ int network_function_run(void) { } } + if(strstr(nf_function_control_string, "ves-o1-pnf-registration") != 0) { + if(nf_function_control_string[0] == '1') { + // check if O1 PNF registration is enabled and send PNF registration message if so + rc = ves_o1_pnf_registration_feature_start(session_running); + if(rc != 0) { + log_error("ves_o1_pnf_registration_feature_start() failed\n"); + } + } + } + if(strstr(nf_function_control_string, "ves-heartbeat") != 0) { if(nf_function_control_string[0] == '1') { // start feature for handling the heartbeat VES message @@ -330,6 +377,7 @@ int network_function_run(void) { } faults_free(); + nf_oran_du_free(); return NTS_ERR_OK; } @@ -661,7 +709,11 @@ static int network_function_info_get_items_cb(sr_session_ctx_t *session, const c if(web_cut_through_feature_get_status()) { strcat(started_features, "web-cut-through "); } - + + if(ves_o1_pnf_registration_feature_get_status()) { + strcat(started_features, "ves-o1-pnf-registration "); + } + if(strlen(started_features)) { started_features[strlen(started_features) - 1] = 0; }