From 5ef280448456cd6962faa4028da63ea9f14ff84b Mon Sep 17 00:00:00 2001 From: Alex Stancu Date: Thu, 13 May 2021 16:02:41 +0300 Subject: [PATCH] Bug fix. Fix for ves-file-ready event not being sent. Issue-ID: SIM-70 Change-Id: I39c4c4fdb4f571638455373ee1db3365c412c6ed Signed-off-by: Alex Stancu --- ntsimulator/.env | 2 +- ntsimulator/nts_build.sh | 2 +- ntsimulator/ntsim-ng/core/docker.c | 6 ------ .../features/ves_file_ready/ves_file_ready.c | 24 +++++++++++++++++----- ntsimulator/ntsim-ng/utils/http_client.c | 4 ++-- ntsimulator/ntsim-ng/utils/nts_utils.c | 2 +- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ntsimulator/.env b/ntsimulator/.env index 40a1525..38339da 100644 --- a/ntsimulator/.env +++ b/ntsimulator/.env @@ -1,6 +1,6 @@ DOCKER_REPO=o-ran-sc/ NTS_MANAGER_PORT=8300 -NTS_BUILD_VERSION=1.3.0 +NTS_BUILD_VERSION=1.3.1 IPv6_ENABLED=false SSH_CONNECTIONS=1 diff --git a/ntsimulator/nts_build.sh b/ntsimulator/nts_build.sh index 62619e1..33f5e5b 100755 --- a/ntsimulator/nts_build.sh +++ b/ntsimulator/nts_build.sh @@ -1,4 +1,4 @@ #!/bin/bash source .env -docker-compose -f nts-ng-docker-image-build-ubuntu.yaml build --build-arg NTS_BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg NTS_BUILD_VERSION=$NTS_BUILD_VERSION +docker-compose -f nts-ng-docker-image-build-ubuntu.yaml build --build-arg NTS_BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg NTS_BUILD_VERSION=$NTS_BUILD_VERSION --build-arg BUILD_WITH_DEBUG=1 diff --git a/ntsimulator/ntsim-ng/core/docker.c b/ntsimulator/ntsim-ng/core/docker.c index 92edc79..3d5faa2 100644 --- a/ntsimulator/ntsim-ng/core/docker.c +++ b/ntsimulator/ntsim-ng/core/docker.c @@ -446,12 +446,6 @@ static int docker_add_port(cJSON *portBindings, uint16_t docker_port, uint16_t h return NTS_ERR_FAILED; } - if(cJSON_AddStringToObject(hostPort, "HostIp", "0.0.0.0") == 0) { //or, future, bind to container->host_ip - log_error("could not create JSON object: HostIpString\n"); - cJSON_Delete(hostPort); - return NTS_ERR_FAILED; - } - if(cJSON_AddItemToArray(port, hostPort) == 0) { log_error("cJSON_AddItemToArray failed\n"); cJSON_Delete(hostPort); diff --git a/ntsimulator/ntsim-ng/features/ves_file_ready/ves_file_ready.c b/ntsimulator/ntsim-ng/features/ves_file_ready/ves_file_ready.c index d7f340e..f344f9a 100644 --- a/ntsimulator/ntsim-ng/features/ves_file_ready/ves_file_ready.c +++ b/ntsimulator/ntsim-ng/features/ves_file_ready/ves_file_ready.c @@ -81,9 +81,18 @@ int ves_file_ready_feature_stop(void) { static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *path, const sr_val_t *input, const size_t input_cnt, sr_event_t event, uint32_t request_id, sr_val_t **output, size_t *output_cnt, void *private_data) { int ssh_base_port = 0; int tls_base_port = 0; - nts_mount_point_addressing_method_t mp = nts_mount_point_addressing_method_get(session); + sr_session_ctx_t *current_session = 0; + + int rc = sr_session_start(session_connection, SR_DS_RUNNING, ¤t_session); + if(rc != SR_ERR_OK) { + log_error("could not start sysrepo session\n"); + return NTS_ERR_FAILED; + } + + nts_mount_point_addressing_method_t mp = nts_mount_point_addressing_method_get(current_session); if(mp == UNKNOWN_MAPPING) { log_error("mount-point-addressing-method failed\n"); + sr_session_stop(current_session); return NTS_ERR_FAILED; } else if(mp == DOCKER_MAPPING) { @@ -99,7 +108,7 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa if((framework_environment.settings.ssh_connections + framework_environment.settings.tls_connections) > 1) { for(int port = ssh_base_port; port < ssh_base_port + framework_environment.settings.ssh_connections; port++) { - int rc = ves_file_ready_send_message(session, input[0].data.string_val, port); + int rc = ves_file_ready_send_message(current_session, input[0].data.string_val, port); if(rc != NTS_ERR_OK) { log_error("ves_file_ready_send_message failed\n"); failed++; @@ -107,7 +116,7 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa } for(int port = tls_base_port; port < tls_base_port + framework_environment.settings.tls_connections; port++) { - int rc = ves_file_ready_send_message(session, input[0].data.string_val, port); + int rc = ves_file_ready_send_message(current_session, input[0].data.string_val, port); if(rc != NTS_ERR_OK) { log_error("ves_file_ready_send_message failed\n"); failed++; @@ -115,16 +124,21 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa } } else { - int rc = ves_file_ready_send_message(session, input[0].data.string_val, 0); + int rc = ves_file_ready_send_message(current_session, input[0].data.string_val, 0); if(rc != NTS_ERR_OK) { log_error("ves_file_ready_send_message failed\n"); failed++; } } + rc = sr_session_stop(current_session); + if(rc != SR_ERR_OK) { + log_error("could not stop sysrepo session\n"); + return NTS_ERR_FAILED; + } *output_cnt = 1; - int rc = sr_new_values(*output_cnt, output); + rc = sr_new_values(*output_cnt, output); if(SR_ERR_OK != rc) { return rc; } diff --git a/ntsimulator/ntsim-ng/utils/http_client.c b/ntsimulator/ntsim-ng/utils/http_client.c index d0d9827..4578dd4 100644 --- a/ntsimulator/ntsim-ng/utils/http_client.c +++ b/ntsimulator/ntsim-ng/utils/http_client.c @@ -160,8 +160,8 @@ int http_socket_request(const char *url, const char *sock_fname, const char *met } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 15L); //seconds timeout for a connection - curl_easy_setopt(curl, CURLOPT_TIMEOUT, 15L); //seconds timeout for an operation + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 30); //seconds timeout for a connection + curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L); //seconds timeout for an operation curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1L); curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); diff --git a/ntsimulator/ntsim-ng/utils/nts_utils.c b/ntsimulator/ntsim-ng/utils/nts_utils.c index 14f2c34..07d0b31 100644 --- a/ntsimulator/ntsim-ng/utils/nts_utils.c +++ b/ntsimulator/ntsim-ng/utils/nts_utils.c @@ -178,7 +178,7 @@ nts_mount_point_addressing_method_t nts_mount_point_addressing_method_get(sr_ses } sr_val_t *value = 0; - rc = sr_get_item(session_running, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, 0, &value); + rc = sr_get_item(current_session, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, 0, &value); if(rc == SR_ERR_OK) { if(strcmp(value->data.enum_val, "host-mapping") == 0) { ret = HOST_MAPPING; -- 2.16.6