Bugfix for SIM-63 95/5895/1
authorAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Thu, 15 Apr 2021 13:12:06 +0000 (16:12 +0300)
committerAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Thu, 15 Apr 2021 13:12:15 +0000 (16:12 +0300)
Allign autogenerated device name device creation by VES and for RestConf requests

Issue-ID: SIM-63
Change-Id: Ie39348008bcf077ab81e10b0101f1b314a7dd657
Signed-off-by: Alex Stancu <alexandru.stancu@highstreet-technologies.com>
17 files changed:
ntsimulator/.env
ntsimulator/deploy/nts-manager/container-tag.yaml
ntsimulator/deploy/o-ran-du/container-tag.yaml
ntsimulator/deploy/o-ran-ru-fh/container-tag.yaml
ntsimulator/deploy/o-ran/container-tag.yaml
ntsimulator/deploy/x-ran/container-tag.yaml
ntsimulator/ntsim-ng/core/app/manager_actions.c
ntsimulator/ntsim-ng/core/docker.c
ntsimulator/ntsim-ng/core/faults/faults_processing.c
ntsimulator/ntsim-ng/core/faults/faults_ves.c
ntsimulator/ntsim-ng/core/framework.c
ntsimulator/ntsim-ng/features/netconf_call_home/netconf_call_home.c
ntsimulator/ntsim-ng/features/ves_file_ready/ves_file_ready.c
ntsimulator/ntsim-ng/features/ves_heartbeat/ves_heartbeat.c
ntsimulator/ntsim-ng/features/ves_pnf_registration/ves_pnf_registration.c
ntsimulator/ntsim-ng/utils/nts_utils.c
ntsimulator/ntsim-ng/utils/nts_utils.h

index 4104951..3e1a682 100644 (file)
@@ -1,6 +1,6 @@
 DOCKER_REPO=o-ran-sc/
 NTS_MANAGER_PORT=8300
-NTS_BUILD_VERSION=1.2.0
+NTS_BUILD_VERSION=1.2.1
 
 IPv6_ENABLED=true
 SSH_CONNECTIONS=1
index ee93a5d..3375107 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.0
\ No newline at end of file
+tag: 1.2.1
\ No newline at end of file
index ee93a5d..3375107 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.0
\ No newline at end of file
+tag: 1.2.1
\ No newline at end of file
index ee93a5d..3375107 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.0
\ No newline at end of file
+tag: 1.2.1
\ No newline at end of file
index ee93a5d..3375107 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.0
\ No newline at end of file
+tag: 1.2.1
\ No newline at end of file
index ee93a5d..3375107 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.0
\ No newline at end of file
+tag: 1.2.1
\ No newline at end of file
index a681e0b..988e0db 100644 (file)
@@ -452,7 +452,7 @@ int manager_actions_mount(manager_context_t *ctx) {
             protocol = "SSH";
             protocol_data = "\
             \"network-topology:netconf-node-topology:username\": \"netconf\",\
-            \"network-topology:netconf-node-topology:password\": \"netconf\"";
+            \"network-topology:netconf-node-topology:password\": \"netconf!\"";
 
             if(instance->mount_point_addressing_method[0] == 'd') {
                 port = instance->container.docker_netconf_ssh_port + i;
@@ -496,7 +496,12 @@ int manager_actions_mount(manager_context_t *ctx) {
 
         char node_id[128];
         char json[4096];
-        sprintf(node_id, "%s-%d", instance->container.name, port);
+        if(framework_environment.settings.ssh_connections + framework_environment.settings.tls_connections > 1) {
+            sprintf(node_id, "%s-%d", instance->container.name, port);
+        }
+        else {
+            sprintf(node_id, "%s", instance->container.name);
+        }
         sprintf(json, json_template, node_id, ip, port, protocol, protocol_data);
 
         char url[512];
@@ -560,7 +565,12 @@ int manager_actions_unmount(manager_context_t *ctx) {
             }
         }
         char node_id[128];
-        sprintf(node_id, "%s-%d", instance->container.name, port);
+        if(framework_environment.settings.ssh_connections + framework_environment.settings.tls_connections > 1) {
+            sprintf(node_id, "%s-%d", instance->container.name, port);
+        }
+        else {
+            sprintf(node_id, "%s", instance->container.name);
+        }
 
         char url[512];
         sprintf(url, "%s/rests/data/network-topology:network-topology/topology=topology-netconf/node=%s", controller->base_url, node_id);
index 25a9a83..dcd8c50 100644 (file)
@@ -191,6 +191,12 @@ int docker_start(const char *container_name, const char *tag, const char *image,
     container->docker_ip = 0;
     container->docker_netconf_ssh_port = STANDARD_NETCONF_PORT;
     container->docker_netconf_tls_port = container->docker_netconf_ssh_port + framework_environment.settings.ssh_connections;
+    if(framework_environment.settings.ssh_connections == 0) {
+        container->docker_netconf_ssh_port = 0;
+    }
+    if(framework_environment.settings.tls_connections == 0) {
+        container->docker_netconf_tls_port = 0;
+    }
     container->docker_ftp_port= STANDARD_FTP_PORT;
     container->docker_sftp_port= STANDARD_SFTP_PORT;
 
index 2711f37..9258833 100644 (file)
@@ -20,6 +20,7 @@
 #include "faults.h"
 #include "utils/log_utils.h"
 #include "utils/sys_utils.h"
+#include "core/framework.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
@@ -457,6 +458,11 @@ static char *fault_process_function(const char *function) {
         uint32_counter++;
         return ret;
     }
+    else if(strcmp(function, "$$hostname$$") == 0) {
+        char *ret = 0;
+        asprintf(&ret, "%s", framework_environment.settings.hostname);
+        return ret;
+    }
 
     return 0;
 }
index 9340f87..5f6c17f 100644 (file)
@@ -78,17 +78,26 @@ int faults_ves_message_send(sr_session_ctx_t *session, const char *condition, co
         tls_base_port = framework_environment.host.tls_base_port;       
     }
 
-    for(int port = ssh_base_port; port < ssh_base_port + framework_environment.settings.ssh_connections; port++) {
-        uint32_t *seq_id = &fault_ves_sequence_number[sequence_index++];
-        int rc = ves_message_send_internal(session, condition, object, severity, date_time, specific_problem, port, seq_id);
-        if(rc != NTS_ERR_OK) {
-            log_error("ves_message_send_internal failed\n");
+    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++) {
+            uint32_t *seq_id = &fault_ves_sequence_number[sequence_index++];
+            int rc = ves_message_send_internal(session, condition, object, severity, date_time, specific_problem, port, seq_id);
+            if(rc != NTS_ERR_OK) {
+                log_error("ves_message_send_internal failed\n");
+            }
         }
-    }
 
-    for(int port = tls_base_port; port < tls_base_port + framework_environment.settings.tls_connections; port++) {
+        for(int port = tls_base_port; port < tls_base_port + framework_environment.settings.tls_connections; port++) {
+            uint32_t *seq_id = &fault_ves_sequence_number[sequence_index++];
+            int rc = ves_message_send_internal(session, condition, object, severity, date_time, specific_problem, port, seq_id);
+            if(rc != NTS_ERR_OK) {
+                log_error("ves_message_send_internal failed\n");
+            }
+        }
+    }
+    else {
         uint32_t *seq_id = &fault_ves_sequence_number[sequence_index++];
-        int rc = ves_message_send_internal(session, condition, object, severity, date_time, specific_problem, port, seq_id);
+        int rc = ves_message_send_internal(session, condition, object, severity, date_time, specific_problem, 0, seq_id);
         if(rc != NTS_ERR_OK) {
             log_error("ves_message_send_internal failed\n");
         }
@@ -209,17 +218,7 @@ static int ves_message_send_internal(sr_session_ctx_t *session, const char *cond
     }
     cJSON_AddItemToObject(post_data_json, "event", event);
 
-    char *source_name = 0;
-    if (framework_environment.settings.ssh_connections + framework_environment.settings.tls_connections == 1) {
-        // we don't want to append the port to the source name if we only expose one port
-        asprintf(&source_name, "%s", hostname_string);
-    }
-    else {
-        asprintf(&source_name, "%s_%d", hostname_string, port);
-    }
-    cJSON *common_event_header = ves_create_common_event_header("fault", "O_RAN_COMPONENT_Alarms", source_name, "Low", (*seq_id)++);
-    free(source_name);
-
+    cJSON *common_event_header = ves_create_common_event_header("fault", "O_RAN_COMPONENT_Alarms", hostname_string, port, "Low", (*seq_id)++);
     if(common_event_header == 0) {
         log_error("ves_create_common_event_header failed\n");
         cJSON_Delete(post_data_json);
index c916d96..23a958a 100644 (file)
@@ -287,6 +287,17 @@ static int framework_env_init(void) {
     }
     
     log_add_verbose(2, "[framework-env] host.ip = %s\n", framework_environment.host.ip);
+    if(framework_environment.settings.ip_v6_enabled) {
+        if(strstr(framework_environment.host.ip, ".")) {
+            log_error("[framework-env] host.ip is an invalid IP v6\n");
+        }
+    }
+    else {
+        if(strstr(framework_environment.host.ip, ":")) {
+            log_error("[framework-env] host.ip is an invalid IP v4\n");
+        }
+    }
+
     log_add_verbose(2, "[framework-env] host.base_port = %d\n", framework_environment.host.base_port);
     log_add_verbose(2, "[framework-env] host.ssh_base_port = %d\n", framework_environment.host.ssh_base_port);
     log_add_verbose(2, "[framework-env] host.tls_base_port = %d\n", framework_environment.host.tls_base_port);
index 8952cb7..0c59997 100644 (file)
@@ -57,7 +57,9 @@ int netconf_call_home_feature_start(sr_session_ctx_t *current_session) {
     }
     else {
         // if value is not set yet, feature enable means we want to start call-home
-        callhome_enabled = true;
+        if(strlen(framework_environment.nts.nf_standalone_start_features)) {
+            callhome_enabled = true;
+        }
     }
 
     if(callhome_enabled == false) {
index af79d0e..d973827 100644 (file)
@@ -34,7 +34,7 @@
 #define FILE_READY_RPC_SCHEMA_XPATH         "/nts-network-function:invoke-ves-pm-file-ready"
 
 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);
+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);
@@ -88,10 +88,52 @@ static void ves_file_ready_vsftp_daemon_deinit(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 rc;
+    int ssh_base_port = 0;
+    int tls_base_port = 0;
+    nts_mount_point_addressing_method_t mp = nts_mount_point_addressing_method_get(session);
+    if(mp == UNKNOWN_MAPPING) {
+        log_error("mount-point-addressing-method failed\n");
+        return NTS_ERR_FAILED;
+    }
+    else if(mp == DOCKER_MAPPING) {
+        ssh_base_port = STANDARD_NETCONF_PORT;
+        tls_base_port = ssh_base_port + framework_environment.settings.ssh_connections;
+    }
+    else {
+        ssh_base_port = framework_environment.host.ssh_base_port;
+        tls_base_port = framework_environment.host.tls_base_port;       
+    }
+
+    int failed = 0;
+
+    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);
+            if(rc != NTS_ERR_OK) {
+                log_error("ves_file_ready_send_message failed\n");
+                failed++;
+            }
+        }
+
+        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);
+            if(rc != NTS_ERR_OK) {
+                log_error("ves_file_ready_send_message failed\n");
+                failed++;
+            }
+        }
+    }
+    else {
+        int rc = ves_file_ready_send_message(session, input[0].data.string_val, 0);
+        if(rc != NTS_ERR_OK) {
+            log_error("ves_file_ready_send_message failed\n");
+            failed++;
+        }
+    }
+    
 
     *output_cnt = 1;
-    rc = sr_new_values(*output_cnt, output);
+    int rc = sr_new_values(*output_cnt, output);
     if(SR_ERR_OK != rc) {
         return rc;
     }
@@ -100,9 +142,8 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa
     if(SR_ERR_OK != rc) {
         return rc;
     }
-
-    rc = ves_file_ready_send_message(session, input[0].data.string_val);
-    if(rc != NTS_ERR_OK) {
+    
+    if(failed != 0) {
         rc = sr_val_build_str_data(output[0], SR_ENUM_T, "%s", "ERROR");
     }
     else {
@@ -112,7 +153,7 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa
     return rc;
 }
 
-static int ves_file_ready_send_message(sr_session_ctx_t *session, const char *file_location) {
+static int ves_file_ready_send_message(sr_session_ctx_t *session, const char *file_location, int port) {
     assert(session);
     assert(file_location);
 
@@ -138,8 +179,7 @@ static int ves_file_ready_send_message(sr_session_ctx_t *session, const char *fi
         return NTS_ERR_FAILED;
     }
 
-    char *hostname_string = framework_environment.settings.hostname;
-    cJSON *common_event_header = ves_create_common_event_header("notification", "Notification-gnb_Nokia-FileReady", hostname_string, "Normal", sequence_number++);
+    cJSON *common_event_header = ves_create_common_event_header("notification", "Notification-gnb_Nokia-FileReady", framework_environment.settings.hostname, port, "Normal", sequence_number++);
     if(common_event_header == 0) {
         log_error("could not create cJSON object\n");
         cJSON_Delete(post_data_json);
index 74f7f62..5e7db90 100644 (file)
@@ -46,7 +46,7 @@ static pthread_mutex_t ves_heartbeat_lock;
 static int ves_heartbeat_period_get(void);
 static void ves_heartbeat_period_set(int new_period);
 
-static int ves_heartbeat_send_ves_message(void);
+static int ves_heartbeat_send_ves_message(int port);
 static void *ves_heartbeat_thread_routine(void *arg);
 static cJSON* ves_create_heartbeat_fields(int heartbeat_period);
 static int heartbeat_change_cb(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data);
@@ -132,7 +132,7 @@ static void ves_heartbeat_period_set(int new_period) {
     pthread_mutex_unlock(&ves_heartbeat_lock);
 }
 
-static int ves_heartbeat_send_ves_message(void) {
+static int ves_heartbeat_send_ves_message(int port) {
     char *hostname_string = framework_environment.settings.hostname;
     cJSON *post_data_json = cJSON_CreateObject();
     if(post_data_json == 0) {
@@ -153,7 +153,7 @@ static int ves_heartbeat_send_ves_message(void) {
         return NTS_ERR_FAILED;
     }
 
-    cJSON *common_event_header = ves_create_common_event_header("heartbeat", "Controller", hostname_string, "Low", ves_sequence_number++);
+    cJSON *common_event_header = ves_create_common_event_header("heartbeat", "Controller", hostname_string, port, "Low", ves_sequence_number++);
     if(common_event_header == 0) {
         log_error("ves_create_common_event_header failed\n");
         cJSON_Delete(post_data_json);
@@ -206,9 +206,30 @@ static int ves_heartbeat_send_ves_message(void) {
 }
 
 static void *ves_heartbeat_thread_routine(void *arg) {
+    assert_session();
+
     int current_heartbeat_period = 0;
     unsigned int timer_counter = 0;
 
+    int ssh_base_port = 0;
+    int tls_base_port = 0;
+    nts_mount_point_addressing_method_t mp = nts_mount_point_addressing_method_get(0);
+    if(mp == UNKNOWN_MAPPING) {
+        log_error("mount-point-addressing-method failed, assuming DOCKER_MAPPING\n");
+        mp = DOCKER_MAPPING;
+        ssh_base_port = STANDARD_NETCONF_PORT;
+        tls_base_port = ssh_base_port + framework_environment.settings.ssh_connections;
+    }
+    else if(mp == DOCKER_MAPPING) {
+        ssh_base_port = STANDARD_NETCONF_PORT;
+        tls_base_port = ssh_base_port + framework_environment.settings.ssh_connections;
+    }
+    else {
+        ssh_base_port = framework_environment.host.ssh_base_port;
+        tls_base_port = framework_environment.host.tls_base_port;       
+    }
+
+
     while((!framework_sigint) && (!ves_heartbeat_stopsig)) {
         current_heartbeat_period = ves_heartbeat_period_get();
         timer_counter++;
@@ -216,10 +237,28 @@ static void *ves_heartbeat_thread_routine(void *arg) {
         if((timer_counter >= current_heartbeat_period) && (current_heartbeat_period > 0)) {
             timer_counter = 0;
 
-            int rc = ves_heartbeat_send_ves_message();
-            if(rc != NTS_ERR_FAILED) {
-                log_error("could not send VES heartbeat\n");
+            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_heartbeat_send_ves_message(port);
+                    if(rc != NTS_ERR_FAILED) {
+                        log_error("could not send VES heartbeat\n");
+                    }
+                }
+
+                for(int port = tls_base_port; port < tls_base_port + framework_environment.settings.tls_connections; port++) {
+                    int rc = ves_heartbeat_send_ves_message(port);
+                    if(rc != NTS_ERR_FAILED) {
+                        log_error("could not send VES heartbeat\n");
+                    }
+                }
+            }
+            else {
+                int rc = ves_heartbeat_send_ves_message(0);
+                if(rc != NTS_ERR_FAILED) {
+                    log_error("could not send VES heartbeat\n");
+                }
             }
+            
         }
 
         sleep(1);
index 69e459e..2d6e3a5 100644 (file)
@@ -33,7 +33,7 @@
 
 static int ves_pnf_sequence_number = 0;
 
-static int ves_pnf_registration_send(sr_session_ctx_t *current_session, const char *nf_ip_v4_address, const char *nf_ip_v6_address, int nf_port, bool is_tls);
+static int ves_pnf_registration_send(sr_session_ctx_t *current_session, const char *nf_ip_v4_address, const char *nf_ip_v6_address, int nf_port, nts_mount_point_addressing_method_t mp, bool is_tls);
 static cJSON* ves_create_pnf_registration_fields(const char *nf_ip_v4_address, const char *nf_ip_v6_address, int nf_port, bool is_tls);
 
 static int ves_pnf_registration_status = 0;
@@ -61,7 +61,9 @@ int ves_pnf_registration_feature_start(sr_session_ctx_t *current_session) {
     }
     else {
         // if value is not set yet, feature enable means we want to start pnf-registration
-        pnf_registration_enabled = true;
+        if(strlen(framework_environment.nts.nf_standalone_start_features)) {
+            pnf_registration_enabled = true;
+        }
     }
 
     if(pnf_registration_enabled == false) {
@@ -69,11 +71,14 @@ int ves_pnf_registration_feature_start(sr_session_ctx_t *current_session) {
         return NTS_ERR_OK;
     }
 
+    int ssh_base_port = 0;
+    int tls_base_port = 0;
     char nf_ip_v4_address[128];
     char nf_ip_v6_address[128];
-    int nf_ssh_port;
-    int nf_tls_port;
 
+    nf_ip_v4_address[0] = 0;
+    nf_ip_v6_address[0] = 0;
+    
     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");
@@ -86,33 +91,52 @@ int ves_pnf_registration_feature_start(sr_session_ctx_t *current_session) {
         if (framework_environment.settings.ip_v6) {
             strcpy(nf_ip_v6_address, framework_environment.settings.ip_v6);
         }
-        nf_ssh_port = STANDARD_NETCONF_PORT;
-        nf_tls_port = nf_ssh_port + framework_environment.settings.ssh_connections;
+
+        ssh_base_port = STANDARD_NETCONF_PORT;
+        tls_base_port = ssh_base_port + framework_environment.settings.ssh_connections;
     }
     else {
-        if (framework_environment.settings.ip_v6_enabled) {
+        if(framework_environment.settings.ip_v6_enabled) {
             strcpy(nf_ip_v6_address, framework_environment.host.ip);
         }
         else {
             strcpy(nf_ip_v4_address, framework_environment.host.ip);
         }
-        nf_ssh_port = framework_environment.host.ssh_base_port;
-        nf_tls_port = framework_environment.host.tls_base_port;
+
+        ssh_base_port = framework_environment.host.ssh_base_port;
+        tls_base_port = framework_environment.host.tls_base_port;
     }
 
-    for(int i = 0; i < framework_environment.settings.ssh_connections; i++) {
-        rc = ves_pnf_registration_send(current_session, nf_ip_v4_address, nf_ip_v6_address, nf_ssh_port + i, false);
-        if(rc != NTS_ERR_OK) {
-            log_error("could not send pnfRegistration message for IPv4=%s and IPv6=%s and port=%d and protocol SSH\n", nf_ip_v4_address, nf_ip_v6_address, nf_ssh_port + i);
-            continue;
+    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_pnf_registration_send(current_session, nf_ip_v4_address, nf_ip_v6_address, port, mp, false);
+            if(rc != NTS_ERR_OK) {
+                log_error("could not send pnfRegistration message for IPv4=%s and IPv6=%s and port=%d and protocol SSH\n", nf_ip_v4_address, nf_ip_v6_address, port);
+            }
+        }
+
+        for(int port = tls_base_port; port < tls_base_port + framework_environment.settings.tls_connections; port++) {
+            int rc = ves_pnf_registration_send(current_session, nf_ip_v4_address, nf_ip_v6_address, port, mp, true);
+            if(rc != NTS_ERR_OK) {
+                log_error("could not send pnfRegistration message for IPv4=%s and IPv6=%s and port=%d and protocol TLS\n", nf_ip_v4_address, nf_ip_v6_address, port);
+            }
         }
     }
+    else {
+        bool tls;
+        int port;
+        if(framework_environment.settings.tls_connections == 0) {
+            tls = false;
+            port = ssh_base_port;
+        }
+        else {
+            tls = true;
+            port = tls_base_port;
+        }
 
-    for(int i = 0; i < framework_environment.settings.tls_connections; i++) {
-        rc = ves_pnf_registration_send(current_session, nf_ip_v4_address, nf_ip_v6_address, nf_tls_port + i, true);
+        int rc = ves_pnf_registration_send(current_session, nf_ip_v4_address, nf_ip_v6_address, 0, mp, tls);
         if(rc != NTS_ERR_OK) {
-            log_error("could not send pnfRegistration message for IPv4=%s and IPv6=%s and port=%d and protocol TLS\n", nf_ip_v4_address, nf_ip_v6_address, nf_tls_port + i);
-            continue;
+            log_error("could not send pnfRegistration message for IPv4=%s and IPv6=%s\n", nf_ip_v4_address, nf_ip_v6_address, port);
         }
     }
 
@@ -122,8 +146,7 @@ int ves_pnf_registration_feature_start(sr_session_ctx_t *current_session) {
     return NTS_ERR_OK;
 }
 
-
-static int ves_pnf_registration_send(sr_session_ctx_t *current_session, const char *nf_ip_v4_address, const char *nf_ip_v6_address, int nf_port, bool is_tls) {
+static int ves_pnf_registration_send(sr_session_ctx_t *current_session, const char *nf_ip_v4_address, const char *nf_ip_v6_address, int nf_port, nts_mount_point_addressing_method_t mp, bool is_tls) {
     assert(current_session);
 
     cJSON *post_data_json = cJSON_CreateObject();
@@ -146,22 +169,26 @@ static int ves_pnf_registration_send(sr_session_ctx_t *current_session, const ch
     }
 
     char *hostname_string = framework_environment.settings.hostname;
-    char source_name[100];
-
-    if (framework_environment.settings.ssh_connections + framework_environment.settings.tls_connections == 1) {
-        // we don't want to append the port to the mountpoint name if we only expose one port
-        sprintf(source_name, "%s", hostname_string);
-    }
-    else {
-           sprintf(source_name, "%s_%d", hostname_string, nf_port);
-    }
-
-    cJSON *common_event_header = ves_create_common_event_header("pnfRegistration", "EventType5G", source_name, "Normal", ves_pnf_sequence_number++);
+    cJSON *common_event_header = ves_create_common_event_header("pnfRegistration", "EventType5G", hostname_string, nf_port, "Normal", ves_pnf_sequence_number++);
     if(common_event_header == 0) {
         log_error("could not create cJSON object\n");
         cJSON_Delete(post_data_json);
         return NTS_ERR_FAILED;
     }
+
+    if(nf_port == 0) {
+        if(mp == DOCKER_MAPPING) {
+            nf_port = STANDARD_NETCONF_PORT;
+        }
+        else {
+            if(is_tls) {
+                nf_port = framework_environment.host.tls_base_port;
+            }
+            else {
+                nf_port = framework_environment.host.ssh_base_port;
+            }
+        }
+    }
     
     if(cJSON_AddItemToObject(event, "commonEventHeader", common_event_header) == 0) {
         log_error("cJSON_AddItemToObject failed\n");
index 60fa015..f1a71ac 100644 (file)
 #define NTS_NETWORK_FUNCTION_VES_SCHEMA_XPATH               "/nts-network-function:simulation/network-function/ves"
 
 
-cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *source_name, const char *priority, int seq_id) {
+cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *hostname, int port, const char *priority, int seq_id) {
     assert(domain);
     assert(event_type);
-    assert(source_name);
+    assert(hostname);
     assert(priority);
 
     char *eventId = 0;
@@ -100,6 +100,14 @@ cJSON* ves_create_common_event_header(const char *domain, const char *event_type
         return 0;
     }
 
+    char source_name[512];
+    if(port) {
+        sprintf(source_name, "%s-%d", hostname, port);
+    }
+    else {
+        sprintf(source_name, "%s", hostname);
+    }
+
     if(cJSON_AddStringToObject(common_event_header, "reportingEntityName", source_name) == 0) {
         log_error("cJSON AddStringToObject error\n");
         cJSON_Delete(common_event_header);
index 01a43d7..e986884 100644 (file)
@@ -50,7 +50,7 @@ typedef struct {
     char *auth_method;
 } controller_details_t;
 
-cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *source_name, const char *priority, int seq_id);
+cJSON* ves_create_common_event_header(const char *domain, const char *event_type, const char *hostname, int port, const char *priority, int seq_id);
 
 nts_mount_point_addressing_method_t nts_mount_point_addressing_method_get(sr_session_ctx_t *current_session);