X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=ntsimulator%2Fntsim-ng%2Ffeatures%2Fves_file_ready%2Fves_file_ready.c;h=76c8cfcf869cd7fa3218307f507ea6ffb3746d7f;hb=caec2fcb18e829420672509fe5e356b48d0c3840;hp=1531126742956f9927043a88efaca124d2697eda;hpb=c7e43513c1c4c3569d5079db0a9a31c124274e6c;p=sim%2Fo1-interface.git 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 1531126..76c8cfc 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 @@ -35,8 +35,6 @@ 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); static int ves_file_ready_send_message(sr_session_ctx_t *session, const char *file_location, int port); static cJSON* ves_create_file_ready_fields(const char* file_location); -static void ves_file_ready_vsftp_daemon_init(void); -static void ves_file_ready_vsftp_daemon_deinit(void); static sr_subscription_ctx_t *ves_file_ready_subscription = 0; @@ -55,7 +53,8 @@ int ves_file_ready_feature_start(sr_session_ctx_t *current_session) { return NTS_ERR_FAILED; } - ves_file_ready_vsftp_daemon_init(); + sftp_daemon_init(); + vsftp_daemon_init(); } return NTS_ERR_OK; @@ -71,27 +70,29 @@ int ves_file_ready_feature_stop(void) { return NTS_ERR_FAILED; } - ves_file_ready_vsftp_daemon_deinit(); + vsftp_daemon_deinit(); + sftp_daemon_deinit(); ves_file_ready_subscription = 0; } return NTS_ERR_OK; } -static void ves_file_ready_vsftp_daemon_init(void) { - system("/usr/sbin/vsftpd &"); -} - -static void ves_file_ready_vsftp_daemon_deinit(void) { - system("killall -9 vsftpd"); -} - 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) { @@ -107,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++; @@ -115,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++; @@ -123,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; } @@ -212,7 +218,7 @@ static int ves_file_ready_send_message(sr_session_ctx_t *session, const char *fi } - ves_details_t *ves_details = ves_endpoint_details_get(session); + ves_details_t *ves_details = ves_endpoint_details_get(session, 0); if(!ves_details) { log_error("ves_endpoint_details_get failed\n"); free(post_data);