From 223f6b0c729f17d03f41fdbe69c4a8097ea79c03 Mon Sep 17 00:00:00 2001 From: Alex Stancu Date: Thu, 25 Jun 2020 16:58:34 +0300 Subject: [PATCH] Bug fix. Fix bug where pnfRegistration messages for TLS connections are not sent. Issue-ID: SIM-31 Change-Id: I7dbeeaf68e6f8c5b817f07805dbbc9ddb087f194 Signed-off-by: Alex Stancu --- ntsimulator/README.md | 6 ++++ ntsimulator/deploy/nts-manager/container-tag.yaml | 2 +- .../deploy/o-ran-sc/o-ran-ru/container-tag.yaml | 2 +- ntsimulator/deploy/o-ran/ru-fh/container-tag.yaml | 2 +- ntsimulator/deploy/x-ran/container-tag.yaml | 2 +- .../generic-notifications/generic-notifications.c | 36 +++++++++++++++++----- .../src/ntsimulator-manager/ntsimulator-manager.c | 33 +++++++++++--------- .../src/ntsimulator-manager/simulator-operations.c | 13 +++++--- ntsimulator/src/ves-messages/heartbeat.c | 2 +- 9 files changed, 66 insertions(+), 32 deletions(-) diff --git a/ntsimulator/README.md b/ntsimulator/README.md index f2f101e..acee38f 100644 --- a/ntsimulator/README.md +++ b/ntsimulator/README.md @@ -365,6 +365,12 @@ This means that `MODELS_IMAGE: "ntsim_oran_light:latest"` can be used as an envi ## Release notes +### **version 0.6.4** + +Bug fixes and improvements: +* Fixed bug where pnfRegistration messages for TLS connections were not sent. +* Fixed bug for manual notification generation failed when notification object was too long. + ### **version 0.6.1** Added features: diff --git a/ntsimulator/deploy/nts-manager/container-tag.yaml b/ntsimulator/deploy/nts-manager/container-tag.yaml index 0bdde94..a0e8b14 100644 --- a/ntsimulator/deploy/nts-manager/container-tag.yaml +++ b/ntsimulator/deploy/nts-manager/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.6.1 +tag: 0.6.4 diff --git a/ntsimulator/deploy/o-ran-sc/o-ran-ru/container-tag.yaml b/ntsimulator/deploy/o-ran-sc/o-ran-ru/container-tag.yaml index 0bdde94..a0e8b14 100644 --- a/ntsimulator/deploy/o-ran-sc/o-ran-ru/container-tag.yaml +++ b/ntsimulator/deploy/o-ran-sc/o-ran-ru/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.6.1 +tag: 0.6.4 diff --git a/ntsimulator/deploy/o-ran/ru-fh/container-tag.yaml b/ntsimulator/deploy/o-ran/ru-fh/container-tag.yaml index 0bdde94..a0e8b14 100644 --- a/ntsimulator/deploy/o-ran/ru-fh/container-tag.yaml +++ b/ntsimulator/deploy/o-ran/ru-fh/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.6.1 +tag: 0.6.4 diff --git a/ntsimulator/deploy/x-ran/container-tag.yaml b/ntsimulator/deploy/x-ran/container-tag.yaml index 0bdde94..a0e8b14 100644 --- a/ntsimulator/deploy/x-ran/container-tag.yaml +++ b/ntsimulator/deploy/x-ran/container-tag.yaml @@ -1,2 +1,2 @@ --- -tag: 0.6.1 +tag: 0.6.4 diff --git a/ntsimulator/src/generic-notifications/generic-notifications.c b/ntsimulator/src/generic-notifications/generic-notifications.c index b6b5459..174b0a2 100644 --- a/ntsimulator/src/generic-notifications/generic-notifications.c +++ b/ntsimulator/src/generic-notifications/generic-notifications.c @@ -218,6 +218,22 @@ static int op_add_srval(sr_val_t **values, size_t *values_cnt, struct lyd_node * return ret; } +static void add_attrtibutes(sr_val_t **values_list, size_t *values_cnt, struct lyd_node *node) +{ + struct lyd_node *iter = NULL; + + LY_TREE_FOR(node->child, iter) { + if (op_add_srval(values_list, values_cnt, iter)) { + printf("Could not transform libyang into sysrepo values...\n"); + return; + } + if (iter->schema->nodetype == LYS_CONTAINER || iter->schema->nodetype == LYS_LIST) + { + add_attrtibutes(values_list, values_cnt, iter); + } + } +} + static int send_dummy_notif(sr_session_ctx_t *sess, const char *module_name, const char *notif_object) { @@ -263,19 +279,18 @@ static int send_dummy_notif(sr_session_ctx_t *sess, const char *module_name, con } } - data = lyd_parse_mem(ctx, notif_object, LYD_JSON, LYD_OPT_NOTIF); + printf("Successfully loaded schemas, trying now to parse the JSON...\n"); + + data = lyd_parse_mem(ctx, notif_object, LYD_JSON, LYD_OPT_NOTIF, NULL); if (data == NULL) { printf("Could not create JSON object, not valid!\n"); return SR_ERR_VALIDATION_FAILED; } - LY_TREE_FOR(data->child, iter) { - if (op_add_srval(&vnotif, &num_values, iter)) { - printf("Could not transform libyang into sysrepo values...\n"); - return SR_ERR_OPERATION_FAILED; - } - } + printf("Successfully parsed the JSON notification object...\n"); + + add_attrtibutes(&vnotif, &num_values, data); if (num_values == 0) { @@ -290,6 +305,13 @@ static int send_dummy_notif(sr_session_ctx_t *sess, const char *module_name, con return SR_ERR_OPERATION_FAILED; } + lyd_free(data); + ly_ctx_destroy(ctx, NULL); + + sr_free_values(vnotif, num_values); + + printf("Successfully sent notification from module=%s with %d number of atttributes\n", module_name, num_values); + return rc; } diff --git a/ntsimulator/src/ntsimulator-manager/ntsimulator-manager.c b/ntsimulator/src/ntsimulator-manager/ntsimulator-manager.c index 4d8c2fb..7674824 100644 --- a/ntsimulator/src/ntsimulator-manager/ntsimulator-manager.c +++ b/ntsimulator/src/ntsimulator-manager/ntsimulator-manager.c @@ -494,11 +494,14 @@ simulator_status_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, if (rc != SR_ERR_OK) { printf("Could not get Notification Counters for device with uuid=\"%s\"", current_device->device_id); - } + } + + char device_name[200]; + sprintf(device_name, "%s-%d", getenv("CONTAINER_NAME"), current_device->device_number); CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, current_device->device_id, "device-ip"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, device_name, "device-ip"); v[current_num_of_values - 1].type = SR_STRING_T; v[current_num_of_values - 1].data.string_val = getenv("NTS_IP"); @@ -506,14 +509,14 @@ simulator_status_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, { CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, current_device->device_id, "device-port"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, device_name, "device-port"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = current_device->netconf_port + i; } CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, current_device->device_id, "is-mounted"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, device_name, "is-mounted"); v[current_num_of_values - 1].type = SR_BOOL_T; v[current_num_of_values - 1].data.bool_val = current_device->is_mounted; @@ -521,66 +524,66 @@ simulator_status_cb(const char *xpath, sr_val_t **values, size_t *values_cnt, CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, current_device->device_id, "operational-state"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/%s", xpath, device_name, "operational-state"); sr_val_build_str_data(&v[current_num_of_values - 1], SR_ENUM_T, "%s", operational_state); CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, current_device->device_id, "normal"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, device_name, "normal"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = vesCount.normal; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, current_device->device_id, "warning"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, device_name, "warning"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = vesCount.warning; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, current_device->device_id, "minor"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, device_name, "minor"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = vesCount.minor; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, current_device->device_id, "major"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, device_name, "major"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = vesCount.major; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, current_device->device_id, "critical"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/ves-notifications/%s", xpath, device_name, "critical"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = vesCount.critical; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, current_device->device_id, "normal"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, device_name, "normal"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = netconfCount.normal; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, current_device->device_id, "warning"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, device_name, "warning"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = netconfCount.warning; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, current_device->device_id, "minor"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, device_name, "minor"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = netconfCount.minor; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, current_device->device_id, "major"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, device_name, "major"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = netconfCount.major; CREATE_NEW_VALUE(rc, v, current_num_of_values); - sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, current_device->device_id, "critical"); + sr_val_build_xpath(&v[current_num_of_values - 1], "%s[uuid='%s']/notification-count/netconf-notifications/%s", xpath, device_name, "critical"); v[current_num_of_values - 1].type = SR_UINT32_T; v[current_num_of_values - 1].data.uint32_val = netconfCount.critical; diff --git a/ntsimulator/src/ntsimulator-manager/simulator-operations.c b/ntsimulator/src/ntsimulator-manager/simulator-operations.c index 6d02c01..11bd9ff 100644 --- a/ntsimulator/src/ntsimulator-manager/simulator-operations.c +++ b/ntsimulator/src/ntsimulator-manager/simulator-operations.c @@ -755,7 +755,7 @@ static int send_mount_device(device_t *current_device, controller_t controller_d bool is_mounted = true; int port = 0; - char device_name[100]; + char device_name[200]; sprintf(device_name, "%s-%d", getenv("CONTAINER_NAME"), current_device->device_number); //This is where we hardcoded: 7 devices will have SSH connections and 3 devices will have TLS connections @@ -2511,7 +2511,7 @@ static int start_device_notification(char *exec_id) curl_easy_reset(curl); set_curl_common_info(); - char url[100]; + char url[500]; sprintf(url, "http:/v%s/exec/%s/start", getenv("DOCKER_ENGINE_VERSION"), exec_id); curl_easy_setopt(curl, CURLOPT_URL, url); @@ -2590,7 +2590,7 @@ static int inspect_device_notification_execution(char *exec_id) curl_easy_reset(curl); set_curl_common_info(); - char url[100]; + char url[500]; sprintf(url, "http:/v%s/exec/%s/json", getenv("DOCKER_ENGINE_VERSION"), exec_id); curl_easy_setopt(curl, CURLOPT_URL, url); @@ -2645,7 +2645,7 @@ int invoke_device_notification(char *device_id, char *module_name, char *notific curl_easy_reset(curl); set_curl_common_info(); - char url[100]; + char url[300]; sprintf(url, "http:/v%s/containers/%s/exec", getenv("DOCKER_ENGINE_VERSION"), device_id); curl_easy_setopt(curl, CURLOPT_URL, url); @@ -2703,7 +2703,8 @@ int invoke_device_notification(char *device_id, char *module_name, char *notific cJSON *cmd_string_2 = cJSON_CreateString("-c"); cJSON_AddItemToArray(cmd_array, cmd_string_2); - char string_command[500]; + //some notifications require a really long notification object + char string_command[1000000]; sprintf(string_command, "/usr/local/bin/generic-notifications %s '%s'", module_name, notification_string); cJSON *cmd_string_3 = cJSON_CreateString(string_command); @@ -2799,6 +2800,8 @@ int pull_docker_image_of_simulated_device() curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&curl_response_mem); + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 300L); + res = curl_easy_perform(curl); if (res != CURLE_OK) diff --git a/ntsimulator/src/ves-messages/heartbeat.c b/ntsimulator/src/ves-messages/heartbeat.c index 09d7e02..be0093e 100644 --- a/ntsimulator/src/ves-messages/heartbeat.c +++ b/ntsimulator/src/ves-messages/heartbeat.c @@ -273,7 +273,7 @@ static void *pnf_registration(void *arg) } pthread_mutex_unlock(&lock); } - for (int i = 0; port < TLS_CONNECTIONS_PER_DEVICE; ++port, ++i) + for (int i = 0; i < TLS_CONNECTIONS_PER_DEVICE; ++port, ++i) { pthread_mutex_lock(&lock); rc = send_pnf_registration_instance(hostname_string, netconf_port_base + port, TRUE); -- 2.16.6