X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fsrc%2Fo-ran-notifications%2Fo-ran-notifications.c;h=230fad26bdc949da572725faedfbd94d1ecc56e9;hb=a19f893a70c03dee9312e1208301d079409d84ac;hp=ae6e0c69eb10dbdca262889db4400bb9ce88ded9;hpb=0c00182421feb00a63a76555844dba5b72639b8e;p=sim%2Fo1-interface.git diff --git a/ntsimulator/src/o-ran-notifications/o-ran-notifications.c b/ntsimulator/src/o-ran-notifications/o-ran-notifications.c index ae6e0c6..230fad2 100644 --- a/ntsimulator/src/o-ran-notifications/o-ran-notifications.c +++ b/ntsimulator/src/o-ran-notifications/o-ran-notifications.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "sysrepo.h" #include "sysrepo/values.h" @@ -35,6 +36,21 @@ volatile int exit_application = 0; +static counterAlarms netconf_alarm_counter = { + .normal = 0, + .warning = 0, + .minor = 0, + .major = 0, + .critical = 0 +}; +static counterAlarms ves_alarm_counter= { + .normal = 0, + .warning = 0, + .minor = 0, + .major = 0, + .critical = 0 +}; + struct faultAlarms { int faultId; @@ -85,7 +101,7 @@ static int send_fault_ves_message(char *alarm_condition, char *alarm_object, cha { int rc = SR_ERR_OK; CURLcode res; - static sequence_id = 0; + static int sequence_id = 0; int netconf_port_base = 0; prepare_ves_message_curl(curl); @@ -129,6 +145,10 @@ static int send_fault_ves_message(char *alarm_condition, char *alarm_object, cha if (faultFields == NULL) { printf("Could not create JSON object: faultFields\n"); + if (postDataJson != NULL) + { + cJSON_Delete(postDataJson); + } return 1; } cJSON_AddItemToObject(event, "faultFields", faultFields); @@ -157,41 +177,6 @@ static int send_fault_ves_message(char *alarm_condition, char *alarm_object, cha return SR_ERR_OK; } -static int send_dummy_notif_file_mgmt(sr_session_ctx_t *sess) -{ - int rc; - - sr_val_t *vnotif; - size_t current_num_of_values= 0; - - CREATE_NEW_VALUE(rc, vnotif, current_num_of_values); - - sr_val_build_xpath(&vnotif[current_num_of_values - 1], "%s", "/o-ran-file-management:file-upload-notification/local-logical-file-path"); - sr_val_set_str_data(&vnotif[current_num_of_values - 1], SR_STRING_T, "odsanzucjsdoj"); - - CREATE_NEW_VALUE(rc, vnotif, current_num_of_values); - - sr_val_build_xpath(&vnotif[current_num_of_values - 1], "%s", "/o-ran-file-management:file-upload-notification/remote-file-path"); - sr_val_set_str_data(&vnotif[current_num_of_values - 1], SR_STRING_T, "jsdknvjnkfd"); - - CREATE_NEW_VALUE(rc, vnotif, current_num_of_values); - - sr_val_build_xpath(&vnotif[current_num_of_values - 1], "%s", "/o-ran-file-management:file-upload-notification/status"); - sr_val_set_str_data(&vnotif[current_num_of_values - 1], SR_ENUM_T, "SUCCESS"); - - rc = sr_event_notif_send(sess, "/o-ran-file-management:file-upload-notification", vnotif, current_num_of_values, SR_EV_NOTIF_DEFAULT); - if (rc != SR_ERR_OK) { - printf("Failed to send notification send_dummy_notif_file_mgmt\n"); - return SR_ERR_OPERATION_FAILED; - } - - printf("Successfully sent notification...\n"); - - sr_free_values(vnotif, current_num_of_values); - - return SR_ERR_OK; -} - static int send_dummy_notif(sr_session_ctx_t *sess) { int rc; @@ -290,6 +275,30 @@ static int send_dummy_notif(sr_session_ctx_t *sess) printf("Failed to send notification send_dummy_notif\n"); return SR_ERR_OPERATION_FAILED; } + if (oran_fault_alarms[ran].cleared[random_port]) + { + netconf_alarm_counter.normal++; + } + else + { + if (strcmp(oran_fault_alarms[ran].faultSeverity, "WARNING") == 0) + { + netconf_alarm_counter.warning++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MINOR") == 0) + { + netconf_alarm_counter.minor++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MAJOR") == 0) + { + netconf_alarm_counter.major++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "CRITICAL") == 0) + { + netconf_alarm_counter.critical++; + } + } + printf("Successfully sent notification with timestamp=\"%s\"\n", dateAndTime); } if (isVesAvailable) @@ -302,7 +311,36 @@ static int send_dummy_notif(sr_session_ctx_t *sess) { printf("Could not send Fault VES message\n"); } + if (oran_fault_alarms[ran].cleared[random_port]) + { + ves_alarm_counter.normal++; + } + else + { + if (strcmp(oran_fault_alarms[ran].faultSeverity, "WARNING") == 0) + { + ves_alarm_counter.warning++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MINOR") == 0) + { + ves_alarm_counter.minor++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "MAJOR") == 0) + { + ves_alarm_counter.major++; + } + else if (strcmp(oran_fault_alarms[ran].faultSeverity, "CRITICAL") == 0) + { + ves_alarm_counter.critical++; + } + } } + printf("Writing counters to file...\n"); + rc = writeStatusNotificationCounters(ves_alarm_counter, netconf_alarm_counter); + if (rc != SR_ERR_OK) + { + printf("Could not write status to file...\n"); + } sr_free_values(vnotif, current_num_of_values); @@ -358,13 +396,20 @@ main(int argc, char **argv) if (notification_delay_period > 0) { send_dummy_notif(session); -// send_dummy_notif_file_mgmt(session); sleep(notification_delay_period); } else { sleep(1); + // reset the counters when the notifciation delay period is switched back to 0 + netconf_alarm_counter.normal = netconf_alarm_counter.warning = \ + netconf_alarm_counter.minor = netconf_alarm_counter.major = \ + netconf_alarm_counter.critical = 0; + + ves_alarm_counter.normal = ves_alarm_counter.warning = \ + ves_alarm_counter.minor = ves_alarm_counter.major = \ + ves_alarm_counter.critical = 0; } }