Add NF addressing method as ENV. 41/5941/2
authorAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Tue, 27 Apr 2021 11:40:02 +0000 (14:40 +0300)
committerAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Tue, 27 Apr 2021 11:55:37 +0000 (14:55 +0300)
Add NF addressing method when running in standalone mode, such that the user can pre-configure this value.

Issue-ID: SIM-65
Change-Id: Ie0294581565963400aab52af2501347f101ee8a8
Signed-off-by: Alex Stancu <alexandru.stancu@highstreet-technologies.com>
32 files changed:
docs/overview.rst
docs/release-notes.rst
ntsimulator/.env
ntsimulator/deploy/base/generate-ssh-keys.sh
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/docker-compose.yaml
ntsimulator/ntsim-ng/core/app/app_common.c
ntsimulator/ntsim-ng/core/app/manager.c
ntsimulator/ntsim-ng/core/app/manager.h
ntsimulator/ntsim-ng/core/app/manager_actions.c
ntsimulator/ntsim-ng/core/app/manager_context.c
ntsimulator/ntsim-ng/core/app/manager_operations.c
ntsimulator/ntsim-ng/core/app/manager_sysrepo.c
ntsimulator/ntsim-ng/core/app/network_function.c
ntsimulator/ntsim-ng/core/docker.c
ntsimulator/ntsim-ng/core/docker.h
ntsimulator/ntsim-ng/core/framework.c
ntsimulator/ntsim-ng/core/framework.h
ntsimulator/ntsim-ng/core/nc_config.c
ntsimulator/ntsim-ng/core/xpath.h [new file with mode: 0644]
ntsimulator/ntsim-ng/features/manual_notification/manual_notification.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/features/web_cut_through/web_cut_through.c
ntsimulator/ntsim-ng/utils/log_utils.c
ntsimulator/ntsim-ng/utils/nts_utils.c

index 4bc8ad7..c389809 100644 (file)
@@ -340,6 +340,8 @@ The network function can run in standalone mode when the **NTS_NF_STANDALONE_STA
 
 Other than this, the network-function will operate just as it would when started by the manager and it can be controller through the **nts-network-function.yang** interface.
 
+The default mount point addressing method is "docker-mapping". However this behaviour can be changed by setting the  **NTS_NF_MOUNT_POINT_ADDRESSING_METHOD** enviroment variable to "host-mapping". When "host-mapping" is chosen, all the host ports must be fowareded from Docker by the user when running the network function, and **NTS_HOST_IP** and **NTS_HOST_xxxx_PORT** enviroment variables should be set for the network function to know how to perform its tasks.
+
 Datastore random population
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -497,6 +499,7 @@ Below all the available enviroment variables are listed. Please note that if a v
 - **NTS_BUILD_VERSION** - defines build version, set by Dockerfile
 - **NTS_BUILD_DATE** - defines build date, set by Dockerfile
 - **NTS_NF_STANDALONE_START_FEATURES** - when value is not blank, it allows the network function to run in standalone mode; see "Network function standalone mode" sub-chapter for this
+- **NTS_NF_MOUNT_POINT_ADDRESSING_METHOD** - either "docker-mapping" or "host-mapping"; available only when running in network function STANDALONE MODE
 
 - **DOCKER_ENGINE_VERSION** - Docker engine version, defaults to 1.40 if not set
 - **HOSTNAME** - Container hostname
index b6cb4d3..0be9080 100644 (file)
@@ -21,6 +21,9 @@ Version history
 | **Date**           | **Ver.**           | **Author**         | **Comment**        |
 |                    |                    |                    |                    |
 +--------------------+--------------------+--------------------+--------------------+
+| 2021-04-27         | 1.2.3              |  Alex Stancu       | "D" release        |
+|                    |                    |                    |                    |
++--------------------+--------------------+--------------------+--------------------+
 | 2021-04-15         | 1.2.1              |  Alex Stancu       | "D" release        |
 |                    |                    |                    |                    |
 +--------------------+--------------------+--------------------+--------------------+
@@ -50,6 +53,17 @@ The O1 interface simulator is a framework that provides simulated network functi
 Release Data
 ------------
 
+version 1.2.3
+
+- [change] moved all NETCONF x-paths to xpath.h for easier management and cleaner codebase
+  
+- [feature-add] Manager now automatically tries to pull missing images (last version) when not found, if **DOCKER_REPOSITORY** env var is set to a certain Docker repository; note that repository authentication currently not supported
+  
+- [feature-add] log-rotation application; does not include supervisor redirected paths, not stderr; log is hard-coded at ~5000 lines per file
+  
+- [feature-add] host-mapping is now available when running NF is running in standalone mode via the **NTS_NF_MOUNT_POINT_ADDRESSING_METHOD** variable
+  
+
 version 1.2.1
 
 - [fix] VES commmon header made uniform across all VES-related messages
index c6de59b..d06eb28 100644 (file)
@@ -1,13 +1,22 @@
 DOCKER_REPO=nexus3.o-ran-sc.org:10004/o-ran-sc/
 NTS_MANAGER_PORT=8300
-NTS_BUILD_VERSION=1.2.1
+NTS_BUILD_VERSION=1.2.3
 
-IPv6_ENABLED=true
+IPv6_ENABLED=false
 SSH_CONNECTIONS=1
 TLS_CONNECTIONS=0
+NTS_HOST_IP=10.20.11.136
+NTS_HOST_BASE_PORT=50000
+NTS_HOST_NETCONF_SSH_BASE_PORT=0
+NTS_HOST_NETCONF_TLS_BASE_PORT=1000
+NTS_HOST_TRANSFER_FTP_BASE_PORT=2000
+NTS_HOST_TRANSFER_SFTP_BASE_PORT=2000
+
+NTS_NF_MOUNT_POINT_ADDRESSING_METHOD=host-mapping
+NTS_NF_STANDALONE_START_FEATURES="datastore-populate ves-heartbeat ves-file-ready ves-pnf-registration netconf-call-home web-cut-through"
 
 SDN_CONTROLLER_PROTOCOL=http
-SDN_CONTROLLER_IP=2001:db8:1:1::21
+SDN_CONTROLLER_IP=172.40.0.21
 SDN_CONTROLLER_PORT=8181
 SDN_CONTROLLER_CALLHOME_PORT=6666
 SDN_CONTROLLER_USERNAME=admin
@@ -15,7 +24,7 @@ SDN_CONTROLLER_PASSWORD=admin
 
 VES_COMMON_HEADER_VERSION=7.1
 VES_ENDPOINT_PROTOCOL=https
-VES_ENDPOINT_IP=2001:db8:1:1::90
+VES_ENDPOINT_IP=172.40.0.90
 VES_ENDPOINT_PORT=8443
 VES_ENDPOINT_AUTH_METHOD=no-auth
 VES_ENDPOINT_USERNAME=sample1
index a4a2bbf..c4ed734 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright 2020 highstreet technologies GmbH and others
+# Copyright 2021 highstreet technologies GmbH and others
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
index 3375107..ec29baf 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.1
\ No newline at end of file
+tag: 1.2.3
\ No newline at end of file
index 3375107..ec29baf 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.1
\ No newline at end of file
+tag: 1.2.3
\ No newline at end of file
index 3375107..ec29baf 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.1
\ No newline at end of file
+tag: 1.2.3
\ No newline at end of file
index 3375107..ec29baf 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.1
\ No newline at end of file
+tag: 1.2.3
\ No newline at end of file
index 3375107..ec29baf 100644 (file)
@@ -1,2 +1,2 @@
 ---
-tag: 1.2.1
\ No newline at end of file
+tag: 1.2.3
\ No newline at end of file
index 6d0804b..7de1e0b 100644 (file)
@@ -48,26 +48,33 @@ services:
     ports:
      - "::18300:830"
     environment:
-        IPv6_ENABLED: ${IPv6_ENABLED}
-        SSH_CONNECTIONS: ${SSH_CONNECTIONS}
-        TLS_CONNECTIONS: ${TLS_CONNECTIONS}
-        
-        NTS_NF_STANDALONE_START_FEATURES: "datastore-populate ves-heartbeat ves-file-ready ves-pnf-registration netconf-call-home web-cut-through"
-        
-        SDN_CONTROLLER_PROTOCOL: ${SDN_CONTROLLER_PROTOCOL}
-        SDN_CONTROLLER_IP: ${SDN_CONTROLLER_IP}
-        SDN_CONTROLLER_PORT: ${SDN_CONTROLLER_PORT}
-        SDN_CONTROLLER_CALLHOME_PORT: ${SDN_CONTROLLER_CALLHOME_PORT}
-        SDN_CONTROLLER_USERNAME: ${SDN_CONTROLLER_USERNAME}
-        SDN_CONTROLLER_PASSWORD: ${SDN_CONTROLLER_PASSWORD}
-  
-        VES_COMMON_HEADER_VERSION: ${VES_COMMON_HEADER_VERSION}
-        VES_ENDPOINT_PROTOCOL: ${VES_ENDPOINT_PROTOCOL}
-        VES_ENDPOINT_IP: ${VES_ENDPOINT_IP}
-        VES_ENDPOINT_PORT: ${VES_ENDPOINT_PORT}
-        VES_ENDPOINT_AUTH_METHOD: ${VES_ENDPOINT_AUTH_METHOD}
-        VES_ENDPOINT_USERNAME: ${VES_ENDPOINT_USERNAME}
-        VES_ENDPOINT_PASSWORD: ${VES_ENDPOINT_PASSWORD}
+      IPv6_ENABLED: ${IPv6_ENABLED}
+      SSH_CONNECTIONS: ${SSH_CONNECTIONS}
+      TLS_CONNECTIONS: ${TLS_CONNECTIONS}
+      NTS_NF_STANDALONE_START_FEATURES: ${NTS_NF_STANDALONE_START_FEATURES}
+      NTS_NF_MOUNT_POINT_ADDRESSING_METHOD: ${NTS_NF_MOUNT_POINT_ADDRESSING_METHOD}
+
+      NTS_HOST_IP: ${NTS_HOST_IP}
+      NTS_HOST_BASE_PORT: ${NTS_HOST_BASE_PORT}
+      NTS_HOST_NETCONF_SSH_BASE_PORT: ${NTS_HOST_NETCONF_SSH_BASE_PORT}
+      NTS_HOST_NETCONF_TLS_BASE_PORT: ${NTS_HOST_NETCONF_TLS_BASE_PORT}
+      NTS_HOST_TRANSFER_FTP_BASE_PORT: ${NTS_HOST_TRANSFER_FTP_BASE_PORT}
+      NTS_HOST_TRANSFER_SFTP_BASE_PORT: ${NTS_HOST_TRANSFER_SFTP_BASE_PORT}
+
+      SDN_CONTROLLER_PROTOCOL: ${SDN_CONTROLLER_PROTOCOL}
+      SDN_CONTROLLER_IP: ${SDN_CONTROLLER_IP}
+      SDN_CONTROLLER_PORT: ${SDN_CONTROLLER_PORT}
+      SDN_CONTROLLER_CALLHOME_PORT: ${SDN_CONTROLLER_CALLHOME_PORT}
+      SDN_CONTROLLER_USERNAME: ${SDN_CONTROLLER_USERNAME}
+      SDN_CONTROLLER_PASSWORD: ${SDN_CONTROLLER_PASSWORD}
+
+      VES_COMMON_HEADER_VERSION: ${VES_COMMON_HEADER_VERSION}
+      VES_ENDPOINT_PROTOCOL: ${VES_ENDPOINT_PROTOCOL}
+      VES_ENDPOINT_IP: ${VES_ENDPOINT_IP}
+      VES_ENDPOINT_PORT: ${VES_ENDPOINT_PORT}
+      VES_ENDPOINT_AUTH_METHOD: ${VES_ENDPOINT_AUTH_METHOD}
+      VES_ENDPOINT_USERNAME: ${VES_ENDPOINT_USERNAME}
+      VES_ENDPOINT_PASSWORD: ${VES_ENDPOINT_PASSWORD}
 
     networks:
       app_net:
@@ -84,8 +91,16 @@ services:
       IPv6_ENABLED: ${IPv6_ENABLED}
       SSH_CONNECTIONS: ${SSH_CONNECTIONS}
       TLS_CONNECTIONS: ${TLS_CONNECTIONS}
-      
-      NTS_NF_STANDALONE_START_FEATURES: "datastore-populate ves-heartbeat ves-file-ready ves-pnf-registration netconf-call-home web-cut-through"
+      NTS_NF_STANDALONE_START_FEATURES: ${NTS_NF_STANDALONE_START_FEATURES}
+      NTS_NF_MOUNT_POINT_ADDRESSING_METHOD: ${NTS_NF_MOUNT_POINT_ADDRESSING_METHOD}
+
+      NTS_HOST_IP: ${NTS_HOST_IP}
+      NTS_HOST_BASE_PORT: ${NTS_HOST_BASE_PORT}
+      NTS_HOST_NETCONF_SSH_BASE_PORT: ${NTS_HOST_NETCONF_SSH_BASE_PORT}
+      NTS_HOST_NETCONF_TLS_BASE_PORT: ${NTS_HOST_NETCONF_TLS_BASE_PORT}
+      NTS_HOST_TRANSFER_FTP_BASE_PORT: ${NTS_HOST_TRANSFER_FTP_BASE_PORT}
+      NTS_HOST_TRANSFER_SFTP_BASE_PORT: ${NTS_HOST_TRANSFER_SFTP_BASE_PORT}
+
       
       SDN_CONTROLLER_PROTOCOL: ${SDN_CONTROLLER_PROTOCOL}
       SDN_CONTROLLER_IP: ${SDN_CONTROLLER_IP}
index 35bcef5..74be703 100644 (file)
 #include <assert.h>
 
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/framework.h"
 
-#define SYSREPO_BUILD_TIME_XPATH    "/nts-network-function:info/build-time"
-#define SYSREPO_VERSION_XPATH       "/nts-network-function:info/version"
-
 static int app_common_populate_info(void);
 
 int app_common_init(void) {
@@ -46,14 +44,14 @@ int app_common_init(void) {
 static int app_common_populate_info(void) {
     int rc;
     if (framework_environment.nts.build_time && strlen(framework_environment.nts.build_time) > 0) {
-        rc  = sr_set_item_str(session_operational, SYSREPO_BUILD_TIME_XPATH, framework_environment.nts.build_time, 0, 0);
+        rc  = sr_set_item_str(session_operational, NTS_NF_INFO_BUILD_TIME_XPATH, framework_environment.nts.build_time, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
             return NTS_ERR_FAILED;
         }
     }
 
-    rc = sr_set_item_str(session_operational, SYSREPO_VERSION_XPATH, framework_environment.nts.version, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_NF_INFO_VERSION_XPATH, framework_environment.nts.version, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
index cc522dc..f7ec705 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "core/framework.h"
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/context.h"
 
 #include "app_common.h"
@@ -70,21 +71,21 @@ int manager_run(void) {
     }
     
     // subscribe to any changes on the list
-    rc = sr_module_change_subscribe(session_running, NTS_MANAGER_MODULE, NTS_SIMULATION_SCHEMA_XPATH, manager_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_UPDATE, &session_subscription);
+    rc = sr_module_change_subscribe(session_running, NTS_MANAGER_MODULE, NTS_MANAGER_SIMULATION_SCHEMA_XPATH, manager_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_UPDATE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to simulation changes\n");
         return NTS_ERR_FAILED;
     }
 
     //subscribe to stats
-    rc = sr_oper_get_items_subscribe(session_running, NTS_MANAGER_MODULE, NTS_SIMULATION_SCHEMA_XPATH, manager_sr_stats_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_OPER_MERGE, &session_subscription);
+    rc = sr_oper_get_items_subscribe(session_running, NTS_MANAGER_MODULE, NTS_MANAGER_SIMULATION_SCHEMA_XPATH, manager_sr_stats_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_OPER_MERGE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to oper faults\n");
         return NTS_ERR_FAILED;
     }
 
     //subscribe to instances oper change
-    rc = sr_oper_get_items_subscribe(session_running, NTS_MANAGER_MODULE, NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_instances_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_oper_get_items_subscribe(session_running, NTS_MANAGER_MODULE, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_instances_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to oper faults\n");
         return 0;
@@ -149,7 +150,7 @@ static int manager_change_cb(sr_session_ctx_t *session, const char *module_name,
     }
 
     if(event == SR_EV_UPDATE) {
-        rc = sr_get_changes_iter(session, NTS_FUNCTION_LIST_SCHEMA_XPATH"//.", &it);
+        rc = sr_get_changes_iter(session, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"//.", &it);
         if(rc != SR_ERR_OK) {
             log_error("sr_get_changes_iter failed\n");
             return SR_ERR_VALIDATION_FAILED;
@@ -270,7 +271,7 @@ static int manager_change_cb(sr_session_ctx_t *session, const char *module_name,
         bool global_change = false;
 
         // go throughout all the changes, not just NF list
-        rc = sr_get_changes_iter(session, NTS_SIMULATION_SCHEMA_XPATH"//.", &it);
+        rc = sr_get_changes_iter(session, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"//.", &it);
         if(rc != SR_ERR_OK) {
             log_error("sr_get_changes_iter failed\n");
             return SR_ERR_VALIDATION_FAILED;
@@ -278,7 +279,7 @@ static int manager_change_cb(sr_session_ctx_t *session, const char *module_name,
 
         while((rc = sr_get_change_next(session, it, &oper, &old_value, &new_value)) == SR_ERR_OK) {
             if(new_value) {
-                if(strstr(new_value->xpath, NTS_FUNCTION_LIST_SCHEMA_XPATH) != new_value->xpath) {
+                if(strstr(new_value->xpath, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH) != new_value->xpath) {
                     global_change = true;
                     sr_free_val(old_value);
                     sr_free_val(new_value);
@@ -309,7 +310,7 @@ static int manager_change_cb(sr_session_ctx_t *session, const char *module_name,
 
 static int manager_instances_get_items_cb(sr_session_ctx_t *session, const char *module_name, const char *xpath, const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data) {
 
-    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_FUNCTION_LIST_SCHEMA_XPATH, 0, 0, 0);
+    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, 0, 0, 0);
     if(*parent == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
@@ -317,7 +318,7 @@ static int manager_instances_get_items_cb(sr_session_ctx_t *session, const char
 
     for(int i = 0; i < docker_context_count; i++) {
         char ftype_path[512];
-        sprintf(ftype_path, "%s[function-type='%s']/instances/instance", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        sprintf(ftype_path, "%s[function-type='%s']/instances/instance", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         for(int j = 0; j < manager_context[i].started_instances; j++) {
             char instance_path[1024];
             sprintf(instance_path, "%s[name='%s']", ftype_path, manager_context[i].instance[j].container.name);
index 50ee1f3..e413f89 100644 (file)
@@ -24,9 +24,6 @@
 #include <sysrepo/values.h>
 #include "core/docker.h"
 
-#define NTS_MANAGER_MODULE                          "nts-manager"
-#define NTS_SIMULATION_SCHEMA_XPATH                 "/nts-manager:simulation"
-#define NTS_FUNCTION_LIST_SCHEMA_XPATH              "/nts-manager:simulation/network-functions/network-function"
 
 typedef struct {
     //meta-data
index 988e0db..21dd0a1 100644 (file)
@@ -28,6 +28,7 @@
 #include "core/framework.h"
 #include "core/docker.h"
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/nc_config.h"
 #include "utils/nc_client.h"
 #include "utils/http_client.h"
@@ -257,14 +258,14 @@ int manager_actions_config_instance(manager_context_t *ctx, manager_network_func
 
     //populate sdn-controller and ves-endpoint
     struct lyd_node *local_tree = 0;
-    int rc = lyd_utils_dup(session_running, "/nts-manager:simulation/sdn-controller", "/nts-network-function:simulation/sdn-controller", &local_tree);
+    int rc = lyd_utils_dup(session_running, NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH, NTS_NF_SDN_CONTROLLER_CONFIG_XPATH, &local_tree);
     if(rc != NTS_ERR_OK) {
         log_error("lyd_utils_dup failed\n");
         manager_sr_notif_send_instance_changed("config FAILED - libyang", ctx->function_type, instance->container.name, instance);
         return NTS_ERR_FAILED;
     }
 
-    rc = lyd_utils_dup(session_running, "/nts-manager:simulation/ves-endpoint", "/nts-network-function:simulation/ves-endpoint", &local_tree);
+    rc = lyd_utils_dup(session_running, NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH, NTS_NF_VES_ENDPOINT_CONFIG_XPATH, &local_tree);
     if(rc != NTS_ERR_OK) {
         log_error("lyd_utils_dup failed\n");
         manager_sr_notif_send_instance_changed("config FAILED - libyang", ctx->function_type, instance->container.name, instance);
@@ -273,8 +274,8 @@ int manager_actions_config_instance(manager_context_t *ctx, manager_network_func
     }
 
     char xpath_s[512];
-    sprintf(xpath_s, "/nts-manager:simulation/network-functions/network-function[function-type='%s']", ctx->function_type);
-    rc = lyd_utils_dup(session_running, xpath_s, "/nts-network-function:simulation/network-function", &local_tree);
+    sprintf(xpath_s, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"[function-type='%s']", ctx->function_type);
+    rc = lyd_utils_dup(session_running, xpath_s, NTS_NF_NETWORK_FUNCTION_SCHEMA_XPATH, &local_tree);
     if(rc != NTS_ERR_OK) {
         log_error("lyd_utils_dup failed\n");
         manager_sr_notif_send_instance_changed("config FAILED - libyang", ctx->function_type, instance->container.name, instance);
@@ -304,7 +305,7 @@ int manager_actions_config_instance(manager_context_t *ctx, manager_network_func
         //run datastore-populate rpc
         struct lyd_node *rpc_node = 0;
         struct lyd_node *rpcout = 0;
-        rpc_node = lyd_new_path(0, session_context, "/nts-network-function:datastore-populate", 0, 0, 0);
+        rpc_node = lyd_new_path(0, session_context, NTS_NF_RPC_POPULATE_SCHEMA_XPATH, 0, 0, 0);
         if(rpc_node == 0) {
             log_error("failed to create rpc node\n");
             manager_sr_notif_send_instance_changed("config FAILED - populate RPC", ctx->function_type, instance->container.name, instance);
@@ -326,7 +327,7 @@ int manager_actions_config_instance(manager_context_t *ctx, manager_network_func
         lyd_free_withsiblings(rpc_node);
 
         //run feature-control rpc
-        rpc_node = lyd_new_path(0, session_context, "/nts-network-function:feature-control/start-features", "ves-file-ready ves-heartbeat ves-pnf-registration manual-notification-generation netconf-call-home web-cut-through", 0, 0);
+        rpc_node = lyd_new_path(0, session_context, NTS_NF_RPC_FEATURE_CONTROL_SCHEMA_XPATH"/start-features", "ves-file-ready ves-heartbeat ves-pnf-registration manual-notification-generation netconf-call-home web-cut-through", 0, 0);
         if(rpc_node == 0) {
             log_error("failed to create rpc node\n");
             manager_sr_notif_send_instance_changed("config FAILED - feature-control RPC", ctx->function_type, instance->container.name, instance);
index d61cb96..3ee398a 100644 (file)
 
 #include "core/framework.h"
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/context.h"
 
-#define NTS_AVAILABLE_IMAGES_SCHEMA_XPATH           "/nts-manager:simulation/available-images"
-
-
 manager_context_t *manager_context = 0;
 docker_context_t *docker_context = 0;
 int docker_context_count = 0;
@@ -44,9 +42,9 @@ static int manager_populate_available_simulations(void);
 int manager_context_init(void) {
 
     //get installed function types
-    struct lys_node_leaf *elem = (struct lys_node_leaf *)ly_ctx_get_node(session_context, 0, NTS_FUNCTION_LIST_SCHEMA_XPATH"/function-type", 0);
+    struct lys_node_leaf *elem = (struct lys_node_leaf *)ly_ctx_get_node(session_context, 0, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"/function-type", 0);
     if(elem == 0) {
-        log_error("ly_ctx_get_node failed for xpath: %s\n", NTS_FUNCTION_LIST_SCHEMA_XPATH"/function-type");
+        log_error("ly_ctx_get_node failed for xpath: %s\n", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"/function-type");
         return NTS_ERR_FAILED;
     }
 
@@ -70,14 +68,57 @@ int manager_context_init(void) {
         docker_filter[i] = function_types[i]->ref;
     }
 
-    int rc = docker_init(docker_filter, docker_context_count, "1.2.0", &docker_context);
-    free(docker_filter);
+    int rc = docker_init(docker_filter, docker_context_count, NTS_VERSION_FALLBACK, &docker_context);
     if(rc != NTS_ERR_OK) {
         log_error("docker_init() failed\n");
+        free(docker_filter);
         free(function_types);
         return NTS_ERR_FAILED;
     }
 
+    //check if an image needs to be pulled
+    log_add_verbose(1, "Docker auto-pull is ");
+    if(strlen(framework_environment.settings.docker_repository)) {
+        log_add(1, LOG_COLOR_BOLD_GREEN"enabled"LOG_COLOR_RESET"\n");
+        int pull_count = 0;
+        for(int i = 0; i < docker_context_count; i++) {
+            bool pull = true;
+            for(int j = 0; j < docker_context[i].available_images_count; j++) {
+                if(strcmp(framework_environment.nts.version, docker_context[i].available_images[j].tag) == 0) {
+                    pull = false;
+                }
+            }
+            
+            if(pull) {
+                log_add_verbose(1, "pulling "LOG_COLOR_RED"%s/"LOG_COLOR_CYAN"%s"LOG_COLOR_RESET":"LOG_COLOR_YELLOW"%s"LOG_COLOR_RESET"... ", framework_environment.settings.docker_repository, docker_context[i].image, framework_environment.nts.version);
+                rc = docker_pull(framework_environment.settings.docker_repository, docker_context[i].image, framework_environment.nts.version);
+                if(rc != NTS_ERR_OK) {
+                    log_add(1, LOG_COLOR_BOLD_RED"failed"LOG_COLOR_RESET"\n");
+                }
+                else {
+                    log_add(1, LOG_COLOR_BOLD_GREEN"OK"LOG_COLOR_RESET"\n");
+                    pull_count++;
+                }
+            }
+        }
+
+        if(pull_count) {
+            //reinit docker
+            docker_free(docker_context, docker_context_count);
+            rc = docker_init(docker_filter, docker_context_count, NTS_VERSION_FALLBACK, &docker_context);
+            if(rc != NTS_ERR_OK) {
+                log_error("docker_init() failed\n");
+                free(docker_filter);
+                free(function_types);
+                return NTS_ERR_FAILED;
+            }
+        }
+    }
+    else {
+        log_add(1, LOG_COLOR_YELLOW"disabled"LOG_COLOR_RESET"\n");
+    }
+    free(docker_filter);
+
 
     //remove non-present network functions
     int new_context_count = 0;
@@ -174,7 +215,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
     //check whether everything is already populated, read and update (if previously ran)
     sr_val_t *values = 0;
     size_t value_count = 0;
-    int rc = sr_get_items(session_running, NTS_FUNCTION_LIST_SCHEMA_XPATH, 0, 0, &values, &value_count);
+    int rc = sr_get_items(session_running, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, 0, 0, &values, &value_count);
     if(rc != SR_ERR_OK) {
         log_error("get items failed\n");
         return NTS_ERR_FAILED;
@@ -202,7 +243,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
     for(int i = 0; i < docker_context_count; i++) {
         char *xpath = 0;
 
-        asprintf(&xpath, "%s[function-type='%s']/function-type", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/function-type", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, (const char *)manager_context[i].function_type, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -210,7 +251,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/started-instances", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/started-instances", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, "0", 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -218,7 +259,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/mounted-instances", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/mounted-instances", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, "0", 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -226,7 +267,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/docker-instance-name", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/docker-instance-name", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, (const char*)manager_context[i].docker_instance_name, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -234,7 +275,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/docker-version-tag", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/docker-version-tag", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, (const char*)manager_context[i].docker_version_tag, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -242,7 +283,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/docker-repository", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/docker-repository", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, (const char*)manager_context[i].docker_repository, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -250,7 +291,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/mount-point-addressing-method", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/mount-point-addressing-method", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, (const char *)manager_context[i].mount_point_addressing_method, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -259,7 +300,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         free(xpath);
 
         //presence containers
-        asprintf(&xpath, "%s[function-type='%s']/fault-generation", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/fault-generation", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -267,7 +308,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/netconf", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/netconf", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -275,7 +316,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
         free(xpath);
 
-        asprintf(&xpath, "%s[function-type='%s']/ves", NTS_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
+        asprintf(&xpath, "%s[function-type='%s']/ves", NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH, manager_context[i].function_type);
         rc = sr_set_item_str(session_running, xpath, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -297,7 +338,7 @@ static int manager_populate_sysrepo_network_function_list(void) {
 static int manager_populate_available_simulations(void) {
     assert_session();
 
-    struct lyd_node *container = lyd_new_path(0, session_context, NTS_AVAILABLE_IMAGES_SCHEMA_XPATH, 0, LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_NOPARENTRET);
+    struct lyd_node *container = lyd_new_path(0, session_context, NTS_MANAGER_AVAILABLE_IMAGES_SCHEMA_XPATH, 0, LYD_ANYDATA_CONSTSTRING, LYD_PATH_OPT_NOPARENTRET);
     if(container == 0) {
         log_error("lyd_new_path failed\n");
         return NTS_ERR_FAILED;
index c847a6c..b26352d 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "core/framework.h"
 #include "core/session.h"
+#include "core/xpath.h"
 
 static manager_operation_t *manager_operations;
 static pthread_mutex_t manager_operations_mutex;
index 46717df..d41ea56 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "core/framework.h"
 #include "core/session.h"
+#include "core/xpath.h"
 
 static int manager_context_sync = 0;
 
@@ -40,7 +41,7 @@ int manager_sr_update_context(manager_context_t *ctx) {
     char int_to_str[30];
 
     //setup sdn-controller defaults
-    sprintf(xpath, NTS_FUNCTION_LIST_SCHEMA_XPATH"[function-type='%s']/started-instances", ctx->function_type);
+    sprintf(xpath, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"[function-type='%s']/started-instances", ctx->function_type);
     sprintf(int_to_str, "%d", ctx->started_instances);
     int rc = sr_set_item_str(session_running, xpath, (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
@@ -48,7 +49,7 @@ int manager_sr_update_context(manager_context_t *ctx) {
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, NTS_FUNCTION_LIST_SCHEMA_XPATH"[function-type='%s']/mounted-instances", ctx->function_type);
+    sprintf(xpath, NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH"[function-type='%s']/mounted-instances", ctx->function_type);
     sprintf(int_to_str, "%d", ctx->mounted_instances);
     rc = sr_set_item_str(session_running, xpath, (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
@@ -73,7 +74,7 @@ int manager_sr_update_context(manager_context_t *ctx) {
 int manager_sr_on_last_operation_status(const char *status, const char *errmsg) {
     assert(status);
 
-    int rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/last-operation-status", status, 0, 0);
+    int rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/last-operation-status", status, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
@@ -169,42 +170,42 @@ int manager_sr_update_static_stats(void) {
     int rc;
 
     sprintf(int_to_str, "%d", framework_environment.host.ssh_base_port);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/ports/netconf-ssh-port", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/ports/netconf-ssh-port", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     sprintf(int_to_str, "%d", framework_environment.host.tls_base_port);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/ports/netconf-tls-port", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/ports/netconf-tls-port", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     sprintf(int_to_str, "%d", framework_environment.host.ftp_base_port);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/ports/transport-ftp-port", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/ports/transport-ftp-port", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     sprintf(int_to_str, "%d", framework_environment.host.sftp_base_port);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/ports/transport-sftp-port", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/ports/transport-sftp-port", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     sprintf(int_to_str, "%d", framework_environment.settings.ssh_connections);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/ssh-connections", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/ssh-connections", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     sprintf(int_to_str, "%d", framework_environment.settings.tls_connections);
-    rc = sr_set_item_str(session_operational, NTS_SIMULATION_SCHEMA_XPATH"/tls-connections", (const char*)int_to_str, 0, 0);
+    rc = sr_set_item_str(session_operational, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/tls-connections", (const char*)int_to_str, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
@@ -223,7 +224,7 @@ int manager_sr_update_static_stats(void) {
 int manager_sr_stats_get_items_cb(sr_session_ctx_t *session, const char *module_name, const char *xpath, const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data) {
     char value[128];
 
-    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_SIMULATION_SCHEMA_XPATH, 0, 0, 0);
+    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_MANAGER_SIMULATION_SCHEMA_XPATH, 0, 0, 0);
     if(*parent == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
@@ -257,13 +258,13 @@ int manager_sr_stats_get_items_cb(sr_session_ctx_t *session, const char *module_
     }
 
     sprintf(value, "%.2f", usage.cpu);
-    if(lyd_new_path(*parent, NULL, NTS_SIMULATION_SCHEMA_XPATH"/cpu-usage", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/cpu-usage", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%.0f", usage.mem);
-    if(lyd_new_path(*parent, NULL, NTS_SIMULATION_SCHEMA_XPATH"/mem-usage", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_MANAGER_SIMULATION_SCHEMA_XPATH"/mem-usage", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
index 85d0409..1d2147a 100644 (file)
@@ -32,6 +32,7 @@
 #include "core/framework.h"
 #include "core/context.h"
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/datastore/populate.h"
 
 #include "core/faults/faults.h"
 
 #define NF_FUNCTION_CONTROL_BUFFER_LENGTH                       32
 
-#define IETF_NETCONF_MONITORING_MODULE                          "ietf-netconf-monitoring"
-#define IETF_NETCONF_MONITORING_STATE_SCHEMAS_SCHEMA_XPATH      "/ietf-netconf-monitoring:netconf-state/schemas"
-
-#define NC_NOTIFICATIONS_MODULE                                 "nc-notifications"
-#define NC_NOTIFICATIONS_STREAMS_SCHEMA_XPATH                   "/nc-notifications:netconf/streams"
-
-#define NTS_NETWORK_FUNCTION_MODULE                             "nts-network-function"
-#define NTS_NETWORK_FUNCTION_SCHEMA_XPATH                       "/nts-network-function:simulation/network-function"
-
-#define POPULATE_RPC_SCHEMA_XPATH                               "/nts-network-function:datastore-populate"
-#define FEATURE_CONTROL_SCHEMA_XPATH                            "/nts-network-function:feature-control"
-#define FAULTS_CLEAR_SCHEMA_XPATH                               "/nts-network-function:clear-fault-counters"
-#define FAULTS_LIST_SCHEMA_XPATH                                "/nts-network-function:simulation/network-function/fault-generation"
-#define FAULTS_COUNT_LIST_SCHEMA_XPATH                          "/nts-network-function:simulation/network-function/fault-generation/fault-count"
-#define FAULTS_NC_ENABLED_SCHEMA_XPATH                          "/nts-network-function:simulation/network-function/netconf/faults-enabled"
-#define FAULTS_VES_ENABLED_SCHEMA_XPATH                         "/nts-network-function:simulation/network-function/ves/faults-enabled"
-
-#define STARTED_FEATURES_LIST_SCHEMA_XPATH                      "/nts-network-function:info/started-features"
-
 static int netconf_monitoring_state_schemas_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
 static int notifications_streams_cb(sr_session_ctx_t *session, const char *module_name, const char *path, const char *request_xpath, uint32_t request_id, struct lyd_node **parent, void *private_data);
 
@@ -132,39 +114,39 @@ int network_function_run(void) {
     }
 
     //populate
-    rc = sr_rpc_subscribe(session_running, POPULATE_RPC_SCHEMA_XPATH, network_function_populate_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_rpc_subscribe(session_running, NTS_NF_RPC_POPULATE_SCHEMA_XPATH, network_function_populate_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("error from sr_rpc_subscribe: %s\n", sr_strerror(rc));
         return NTS_ERR_FAILED;
     }
 
     //feature control
-    rc = sr_rpc_subscribe(session_running, FEATURE_CONTROL_SCHEMA_XPATH, network_function_feature_control_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_rpc_subscribe(session_running, NTS_NF_RPC_FEATURE_CONTROL_SCHEMA_XPATH, network_function_feature_control_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("error from sr_rpc_subscribe: %s\n", sr_strerror(rc));
         return NTS_ERR_FAILED;
     }
 
     //faults
-    rc = sr_module_change_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, FAULTS_LIST_SCHEMA_XPATH, network_function_faults_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_module_change_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, NTS_NF_FAULT_GENERATION_SCHEMA_XPATH, network_function_faults_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to faults");
         return 0;
     }
 
-    rc = sr_oper_get_items_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, FAULTS_COUNT_LIST_SCHEMA_XPATH, network_function_faults_count_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_oper_get_items_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH, network_function_faults_count_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to oper faults: %s\n", sr_strerror(rc));
         return 0;
     }
 
-    rc = sr_rpc_subscribe(session_running, FAULTS_CLEAR_SCHEMA_XPATH, network_function_faults_clear_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_rpc_subscribe(session_running, NTS_NF_RPC_FAULTS_CLEAR_SCHEMA_XPATH, network_function_faults_clear_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("error from sr_rpc_subscribe: %s\n", sr_strerror(rc));
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_oper_get_items_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, STARTED_FEATURES_LIST_SCHEMA_XPATH, network_function_started_features_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
+    rc = sr_oper_get_items_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, NTS_NF_INFO_STARTED_FEATURES_SCHEMA_XPATH, network_function_started_features_get_items_cb, NULL, SR_SUBSCR_CTX_REUSE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to oper started-features: %s\n", sr_strerror(rc));
         return 0;
@@ -172,7 +154,7 @@ int network_function_run(void) {
     
 
     //subscribe to any changes on the main
-    rc = sr_module_change_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, NTS_NETWORK_FUNCTION_SCHEMA_XPATH, network_function_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_UPDATE, &session_subscription);
+    rc = sr_module_change_subscribe(session_running, NTS_NETWORK_FUNCTION_MODULE, NTS_NF_NETWORK_FUNCTION_SCHEMA_XPATH, network_function_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE | SR_SUBSCR_UPDATE, &session_subscription);
     if(rc != SR_ERR_OK) {
         log_error("could not subscribe to simulation changes\n");
         return NTS_ERR_FAILED;
@@ -397,7 +379,7 @@ static int notifications_streams_cb(sr_session_ctx_t *session, const char *modul
     struct lyd_node *root = lyd_new_path(0, session_context, NC_NOTIFICATIONS_STREAMS_SCHEMA_XPATH, 0, 0, 0);
 
     /* generic stream */
-    struct lyd_node *stream = lyd_new_path(root, 0, "/nc-notifications:netconf/streams/stream[name='NETCONF']", NULL, 0, 0);
+    struct lyd_node *stream = lyd_new_path(root, 0, NC_NOTIFICATIONS_STREAMS_SCHEMA_XPATH"/stream[name='NETCONF']", NULL, 0, 0);
     lyd_new_leaf(stream, stream->schema->module, "description", "Default NETCONF stream containing notifications from all the modules. Replays only notifications for modules that support replay.");
     lyd_new_leaf(stream, stream->schema->module, "replaySupport", "true");
     
@@ -460,7 +442,7 @@ static int network_function_populate_cb(sr_session_ctx_t *session, const char *p
         return rc;
     }
 
-    rc = sr_val_set_xpath(output[0], POPULATE_RPC_SCHEMA_XPATH"/status");
+    rc = sr_val_set_xpath(output[0], NTS_NF_RPC_POPULATE_SCHEMA_XPATH"/status");
     if(SR_ERR_OK != rc) {
         return rc;
     }
@@ -536,7 +518,7 @@ static int network_function_feature_control_cb(sr_session_ctx_t *session, const
         return rc;
     }
 
-    rc = sr_val_set_xpath(output[0], FEATURE_CONTROL_SCHEMA_XPATH"/status");
+    rc = sr_val_set_xpath(output[0], NTS_NF_RPC_FEATURE_CONTROL_SCHEMA_XPATH"/status");
     if(SR_ERR_OK != rc) {
         return rc;
     }
@@ -580,7 +562,7 @@ static int network_function_faults_clear_cb(sr_session_ctx_t *session, const cha
         return rc;
     }
 
-    rc = sr_val_set_xpath(output[0], FAULTS_CLEAR_SCHEMA_XPATH"/status");
+    rc = sr_val_set_xpath(output[0], NTS_NF_RPC_FAULTS_CLEAR_SCHEMA_XPATH"/status");
     if(SR_ERR_OK != rc) {
         return rc;
     }
@@ -615,38 +597,38 @@ static int network_function_faults_count_get_items_cb(sr_session_ctx_t *session,
     pthread_mutex_unlock(&faults_lock);
     char value[20];
 
-    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), FAULTS_COUNT_LIST_SCHEMA_XPATH, 0, 0, 0);
+    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH, 0, 0, 0);
     if(*parent == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%d", counters.normal);
-    if(lyd_new_path(*parent, NULL, FAULTS_COUNT_LIST_SCHEMA_XPATH"/normal", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH"/normal", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%d", counters.warning);
-    if(lyd_new_path(*parent, NULL, FAULTS_COUNT_LIST_SCHEMA_XPATH"/warning", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH"/warning", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%d", counters.minor);
-    if(lyd_new_path(*parent, NULL, FAULTS_COUNT_LIST_SCHEMA_XPATH"/minor", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH"/minor", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%d", counters.major);
-    if(lyd_new_path(*parent, NULL, FAULTS_COUNT_LIST_SCHEMA_XPATH"/major", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH"/major", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
 
     sprintf(value, "%d", counters.critical);
-    if(lyd_new_path(*parent, NULL, FAULTS_COUNT_LIST_SCHEMA_XPATH"/critical", value, 0, 0) == 0) {
+    if(lyd_new_path(*parent, NULL, NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH"/critical", value, 0, 0) == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
     }
@@ -686,7 +668,7 @@ static int network_function_started_features_get_items_cb(sr_session_ctx_t *sess
         value[strlen(value) - 1] = 0;
     }
 
-    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), STARTED_FEATURES_LIST_SCHEMA_XPATH, value, 0, 0);
+    *parent = lyd_new_path(NULL, sr_get_context(sr_session_get_connection(session)), NTS_NF_INFO_STARTED_FEATURES_SCHEMA_XPATH, value, 0, 0);
     if(*parent == 0) {
         log_error("lyd_new_path failed\n");
         return SR_ERR_OPERATION_FAILED;
@@ -703,7 +685,7 @@ static int faults_update_config(sr_session_ctx_t *session) {
     
     int rc;
     struct lyd_node *data;
-    rc = sr_get_subtree(session, FAULTS_LIST_SCHEMA_XPATH, 0, &data);
+    rc = sr_get_subtree(session, NTS_NF_FAULT_GENERATION_SCHEMA_XPATH, 0, &data);
     if(rc != SR_ERR_OK) {
         log_error("sr_get_subtree failed\n");
         return NTS_ERR_FAILED;
@@ -791,13 +773,13 @@ static void *faults_thread_routine(void *arg) {
             bool nc_fault_enabled = false;
             bool ves_fault_enabled = false;
 
-            rc = sr_get_item(current_session_running, FAULTS_NC_ENABLED_SCHEMA_XPATH, 0, &val);
+            rc = sr_get_item(current_session_running, NTS_NF_NETCONF_FAULTS_ENABLED_SCHEMA_PATH, 0, &val);
             if(rc == SR_ERR_OK) {
                 nc_fault_enabled = val->data.bool_val;
                 sr_free_val(val);
             }
 
-            rc = sr_get_item(current_session_running, FAULTS_VES_ENABLED_SCHEMA_XPATH, 0, &val);
+            rc = sr_get_item(current_session_running, NTS_NF_VES_FAULTS_ENABLED_SCHEMA_XPATH, 0, &val);
             if(rc == SR_ERR_OK) {
                 ves_fault_enabled = val->data.bool_val;
                 sr_free_val(val);
@@ -850,7 +832,7 @@ static int network_function_change_cb(sr_session_ctx_t *session, const char *mod
     sr_val_t *new_value = 0;
 
     if(event == SR_EV_UPDATE) {
-        rc = sr_get_changes_iter(session, NTS_NETWORK_FUNCTION_SCHEMA_XPATH"//.", &it);
+        rc = sr_get_changes_iter(session, NTS_NF_NETWORK_FUNCTION_SCHEMA_XPATH"//.", &it);
         if(rc != SR_ERR_OK) {
             log_error("sr_get_changes_iter failed\n");
             return SR_ERR_VALIDATION_FAILED;
@@ -858,7 +840,7 @@ static int network_function_change_cb(sr_session_ctx_t *session, const char *mod
 
         while((rc = sr_get_change_next(session, it, &oper, &old_value, &new_value)) == SR_ERR_OK) {
             
-            if(new_value->xpath && (strcmp(new_value->xpath, NTS_NETWORK_FUNCTION_SCHEMA_XPATH"/function-type") == 0)) {
+            if(new_value->xpath && (strcmp(new_value->xpath, NTS_NF_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH) == 0)) {
                 if(old_value && !old_value->dflt) {
                     rc = sr_set_item(session, old_value->xpath, old_value, 0);
                     if(rc != SR_ERR_OK) {
@@ -868,7 +850,7 @@ static int network_function_change_cb(sr_session_ctx_t *session, const char *mod
                 }
             }
 
-            if(new_value->xpath && (strcmp(new_value->xpath, NTS_NETWORK_FUNCTION_SCHEMA_XPATH"/mount-point-addressing-method") == 0)) {
+            if(new_value->xpath && (strcmp(new_value->xpath, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH) == 0)) {
                 if(old_value && !old_value->dflt) {
                     rc = sr_set_item(session, old_value->xpath, old_value, 0);
                     if(rc != SR_ERR_OK) {
index dcd8c50..92edc79 100644 (file)
@@ -358,6 +358,42 @@ int docker_usage_get(const char **instances_id, int count, docker_usage_t *usage
     return NTS_ERR_OK;
 }
 
+int docker_pull(const char *repo, const char *image, const char *tag) {
+    assert(repo);
+    assert(image);
+    assert(tag);
+
+    char image_full[256];
+    if(tag && (tag[0] != 0)) {
+        sprintf(image_full, "%s/%s:%s", repo, image, tag);
+    }
+    else {
+        sprintf(image_full, "%s/%s:latest", repo, image);    
+    }
+
+    char url[512];
+    sprintf(url, "http:/v%s/images/create?fromImage=%s", framework_environment.settings.docker_engine_version, image_full);
+
+    char *response = 0;
+    int response_code = 0;
+    int rc = http_socket_request(url, DOCKER_SOCK_FNAME, "POST", 0, &response_code, &response);
+
+    if(rc != NTS_ERR_OK) {
+        log_error("http_socket_request failed\n");
+        return NTS_ERR_FAILED;
+    }
+
+    if(response_code != 200) {
+        char *message = docker_parse_json_message(response);
+        log_error("docker_pull failed (%d): %s\n", response_code, message);
+        free(message);
+        free(response);
+        return NTS_ERR_FAILED;
+    }
+    
+    return NTS_ERR_OK;
+}
+
 static char *docker_parse_json_message(const char *json_string) {
     assert(json_string);
 
index a44cab6..55a400d 100644 (file)
@@ -61,3 +61,4 @@ int docker_start(const char *container_name, const char *tag, const char *image,
 int docker_stop(docker_container_t *container);
 
 int docker_usage_get(const char **instances_id, int count, docker_usage_t *usage);
+int docker_pull(const char *repo, const char *image, const char *tag);
index 23a958a..39f152f 100644 (file)
@@ -68,8 +68,8 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state);
 
 int framework_init(int argc, char **argv) {
     //environment vars
-    framework_environment.nts.version = getenv(ENV_VAR_NTS_BUILD_VERSION) ? strdup(getenv(ENV_VAR_NTS_BUILD_VERSION)) : strdup("N/A");
-    framework_environment.nts.build_time = getenv(ENV_VAR_NTS_BUILD_TIME) ? strdup(getenv(ENV_VAR_NTS_BUILD_TIME)) : strdup("N/A");
+    framework_environment.nts.version = (getenv(ENV_VAR_NTS_BUILD_VERSION) && strlen(getenv(ENV_VAR_NTS_BUILD_VERSION))) ? strdup(getenv(ENV_VAR_NTS_BUILD_VERSION)) : strdup(NTS_VERSION_FALLBACK"!");
+    framework_environment.nts.build_time = (getenv(ENV_VAR_NTS_BUILD_TIME) && strlen(getenv(ENV_VAR_NTS_BUILD_TIME))) ? strdup(getenv(ENV_VAR_NTS_BUILD_TIME)) : strdup("N/A");
 
     //set argp_version
     char *version = 0;
@@ -179,7 +179,14 @@ static int framework_env_init(void) {
     framework_environment.nts.manual = getenv(ENV_VAR_NTS_MANUAL) ? true : false;
     framework_environment.nts.function_type = getenv(ENV_VAR_NTS_FUNCTION_TYPE) ? strdup(getenv(ENV_VAR_NTS_FUNCTION_TYPE)) : strdup("");
     framework_environment.nts.nf_standalone_start_features = getenv(ENV_VAR_NTS_NF_STANDALONE_START_FEATURES) ? strdup(getenv(ENV_VAR_NTS_NF_STANDALONE_START_FEATURES)) : strdup("");
+    framework_environment.nts.nf_mount_point_addressing_method = getenv(ENV_VAR_NTS_NF_MOUNT_POINT_ADDRESSING_METHOD) ? strdup(getenv(ENV_VAR_NTS_NF_MOUNT_POINT_ADDRESSING_METHOD)) : strdup("docker-mapping");
 
+    framework_environment.settings.docker_repository = getenv(ENV_VAR_DOCKER_REPOSITORY) ? strdup(getenv(ENV_VAR_DOCKER_REPOSITORY)) : strdup("");
+    if(strlen(framework_environment.settings.docker_repository)) {
+        if(framework_environment.settings.docker_repository[strlen(framework_environment.settings.docker_repository) - 1] == '/') {
+            framework_environment.settings.docker_repository[strlen(framework_environment.settings.docker_repository) - 1] = 0;
+        }
+    }
     framework_environment.settings.docker_engine_version = getenv(ENV_VAR_DOCKER_ENGINE_VERSION) ? strdup(getenv(ENV_VAR_DOCKER_ENGINE_VERSION)) : strdup("1.40");
     framework_environment.settings.hostname = getenv(ENV_VAR_HOSTNAME) ? strdup(getenv(ENV_VAR_HOSTNAME)) : strdup("localhost");
 
@@ -227,8 +234,10 @@ static int framework_env_init(void) {
     log_add_verbose(2, "[framework-env] nts.build_time = %s\n", framework_environment.nts.build_time);
     log_add_verbose(2, "[framework-env] nts.function_type = %s\n", framework_environment.nts.function_type);
     log_add_verbose(2, "[framework-env] nts.nf_standalone_start_features = %s\n", framework_environment.nts.nf_standalone_start_features);
+    log_add_verbose(2, "[framework-env] nts.nf_mount_point_addressing_method = %s\n", framework_environment.nts.nf_mount_point_addressing_method);
 
     log_add_verbose(2, "[framework-env] settings.docker_engine_version = %s\n", framework_environment.settings.docker_engine_version);
+    log_add_verbose(2, "[framework-env] settings.docker_repository = %s\n", framework_environment.settings.docker_repository);
     log_add_verbose(2, "[framework-env] settings.hostname = %s\n", framework_environment.settings.hostname);
     log_add_verbose(2, "[framework-env] settings.ip_v4 = %s\n", framework_environment.settings.ip_v4);
     log_add_verbose(2, "[framework-env] settings.ip_v6 = %s\n", framework_environment.settings.ip_v6);
@@ -290,11 +299,13 @@ static int framework_env_init(void) {
     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");
+            return NTS_ERR_FAILED;
         }
     }
     else {
         if(strstr(framework_environment.host.ip, ":")) {
             log_error("[framework-env] host.ip is an invalid IP v4\n");
+            return NTS_ERR_FAILED;
         }
     }
 
@@ -693,9 +704,11 @@ void framework_free(void) {
     free(framework_environment.nts.build_time);
     free(framework_environment.nts.function_type);
     free(framework_environment.nts.nf_standalone_start_features);
+    free(framework_environment.nts.nf_mount_point_addressing_method);
     free(framework_environment.settings.ip_v4);
     free(framework_environment.settings.ip_v6);
     free(framework_environment.settings.docker_engine_version);
+    free(framework_environment.settings.docker_repository);
     free(framework_environment.settings.hostname);
     free(framework_environment.host.ip);
     free(framework_environment.sdn_controller.protocol);
index 2f169f0..1c8a266 100644 (file)
 #include <unistd.h>
 #include <signal.h>
 
-#define ENV_VAR_NTS_MANUAL                          "NTS_MANUAL"
-#define ENV_VAR_NTS_BUILD_VERSION                   "NTS_BUILD_VERSION"
-#define ENV_VAR_NTS_BUILD_TIME                      "NTS_BUILD_DATE"
-#define ENV_VAR_NTS_FUNCTION_TYPE                   "NTS_FUNCTION_TYPE"
-#define ENV_VAR_NTS_NF_STANDALONE_START_FEATURES    "NTS_NF_STANDALONE_START_FEATURES"
-
-#define ENV_VAR_DOCKER_ENGINE_VERSION               "DOCKER_ENGINE_VERSION"
-#define ENV_VAR_HOSTNAME                            "HOSTNAME"
-#define ENV_VAR_IPV6ENABLED                         "IPv6_ENABLED"
-#define ENV_VAR_SSH_CONNECTIONS                     "SSH_CONNECTIONS"
-#define ENV_VAR_TLS_CONNECTIONS                     "TLS_CONNECTIONS"
-
-#define ENV_VAR_HOST_IP                             "NTS_HOST_IP"
-#define ENV_VAR_HOST_BASE_PORT                      "NTS_HOST_BASE_PORT"
-#define ENV_VAR_HOST_NETCONF_SSH_BASE_PORT          "NTS_HOST_NETCONF_SSH_BASE_PORT"
-#define ENV_VAR_HOST_NETCONF_TLS_BASE_PORT          "NTS_HOST_NETCONF_TLS_BASE_PORT"
-#define ENV_VAR_HOST_TRANSFER_FTP_BASE_PORT         "NTS_HOST_TRANSFER_FTP_BASE_PORT"
-#define ENV_VAR_HOST_TRANSFER_SFTP_BASE_PORT        "NTS_HOST_TRANSFER_SFTP_BASE_PORT"
-
-#define ENV_VAR_SDN_CONTROLLER_PROTOCOL             "SDN_CONTROLLER_PROTOCOL"
-#define ENV_VAR_SDN_CONTROLLER_IP                   "SDN_CONTROLLER_IP"
-#define ENV_VAR_SDN_CONTROLLER_PORT                 "SDN_CONTROLLER_PORT"
-#define ENV_VAR_SDN_CONTROLLER_CALLHOME_PORT        "SDN_CONTROLLER_CALLHOME_PORT"
-#define ENV_VAR_SDN_CONTROLLER_USERNAME             "SDN_CONTROLLER_USERNAME"
-#define ENV_VAR_SDN_CONTROLLER_PASSWORD             "SDN_CONTROLLER_PASSWORD"
-
-#define ENV_VAR_VES_COMMON_HEADER_VERSION           "VES_COMMON_HEADER_VERSION"
-#define ENV_VAR_VES_ENDPOINT_PROTOCOL               "VES_ENDPOINT_PROTOCOL"
-#define ENV_VAR_VES_ENDPOINT_IP                     "VES_ENDPOINT_IP"
-#define ENV_VAR_VES_ENDPOINT_PORT                   "VES_ENDPOINT_PORT"
-#define ENV_VAR_VES_ENDPOINT_AUTH_METHOD            "VES_ENDPOINT_AUTH_METHOD"
-#define ENV_VAR_VES_ENDPOINT_USERNAME               "VES_ENDPOINT_USERNAME"
-#define ENV_VAR_VES_ENDPOINT_PASSWORD               "VES_ENDPOINT_PASSWORD"
-#define ENV_VAR_VES_ENDPOINT_CERTIFICATE            "VES_ENDPOINT_CERTIFICATE"
+#define NTS_VERSION_FALLBACK                            "1.2.0"
+
+#define ENV_VAR_NTS_MANUAL                              "NTS_MANUAL"
+#define ENV_VAR_NTS_BUILD_VERSION                       "NTS_BUILD_VERSION"
+#define ENV_VAR_NTS_BUILD_TIME                          "NTS_BUILD_DATE"
+#define ENV_VAR_NTS_FUNCTION_TYPE                       "NTS_FUNCTION_TYPE"
+#define ENV_VAR_NTS_NF_STANDALONE_START_FEATURES        "NTS_NF_STANDALONE_START_FEATURES"
+#define ENV_VAR_NTS_NF_MOUNT_POINT_ADDRESSING_METHOD    "NTS_NF_MOUNT_POINT_ADDRESSING_METHOD"
+
+#define ENV_VAR_DOCKER_REPOSITORY                       "DOCKER_REPOSITORY"
+#define ENV_VAR_DOCKER_ENGINE_VERSION                   "DOCKER_ENGINE_VERSION"
+#define ENV_VAR_HOSTNAME                                "HOSTNAME"
+#define ENV_VAR_IPV6ENABLED                             "IPv6_ENABLED"
+#define ENV_VAR_SSH_CONNECTIONS                         "SSH_CONNECTIONS"
+#define ENV_VAR_TLS_CONNECTIONS                         "TLS_CONNECTIONS"
+
+#define ENV_VAR_HOST_IP                                 "NTS_HOST_IP"
+#define ENV_VAR_HOST_BASE_PORT                          "NTS_HOST_BASE_PORT"
+#define ENV_VAR_HOST_NETCONF_SSH_BASE_PORT              "NTS_HOST_NETCONF_SSH_BASE_PORT"
+#define ENV_VAR_HOST_NETCONF_TLS_BASE_PORT              "NTS_HOST_NETCONF_TLS_BASE_PORT"
+#define ENV_VAR_HOST_TRANSFER_FTP_BASE_PORT             "NTS_HOST_TRANSFER_FTP_BASE_PORT"
+#define ENV_VAR_HOST_TRANSFER_SFTP_BASE_PORT            "NTS_HOST_TRANSFER_SFTP_BASE_PORT"
+
+#define ENV_VAR_SDN_CONTROLLER_PROTOCOL                 "SDN_CONTROLLER_PROTOCOL"
+#define ENV_VAR_SDN_CONTROLLER_IP                       "SDN_CONTROLLER_IP"
+#define ENV_VAR_SDN_CONTROLLER_PORT                     "SDN_CONTROLLER_PORT"
+#define ENV_VAR_SDN_CONTROLLER_CALLHOME_PORT            "SDN_CONTROLLER_CALLHOME_PORT"
+#define ENV_VAR_SDN_CONTROLLER_USERNAME                 "SDN_CONTROLLER_USERNAME"
+#define ENV_VAR_SDN_CONTROLLER_PASSWORD                 "SDN_CONTROLLER_PASSWORD"
+
+#define ENV_VAR_VES_COMMON_HEADER_VERSION               "VES_COMMON_HEADER_VERSION"
+#define ENV_VAR_VES_ENDPOINT_PROTOCOL                   "VES_ENDPOINT_PROTOCOL"
+#define ENV_VAR_VES_ENDPOINT_IP                         "VES_ENDPOINT_IP"
+#define ENV_VAR_VES_ENDPOINT_PORT                       "VES_ENDPOINT_PORT"
+#define ENV_VAR_VES_ENDPOINT_AUTH_METHOD                "VES_ENDPOINT_AUTH_METHOD"
+#define ENV_VAR_VES_ENDPOINT_USERNAME                   "VES_ENDPOINT_USERNAME"
+#define ENV_VAR_VES_ENDPOINT_PASSWORD                   "VES_ENDPOINT_PASSWORD"
+#define ENV_VAR_VES_ENDPOINT_CERTIFICATE                "VES_ENDPOINT_CERTIFICATE"
 
 typedef enum {
     NTS_MODE_DEFAULT = 0,
@@ -89,9 +93,11 @@ typedef struct {
         char *build_time;
         char *function_type;
         char *nf_standalone_start_features;
+        char *nf_mount_point_addressing_method;
     } nts;
 
     struct {
+        char *docker_repository;
         char *docker_engine_version;
 
         char *hostname;
index 789f1e7..fdd1bd9 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <libyang/libyang.h>
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/framework.h"
 
 #define GEN_KEY_SCRIPT                              "/home/netconf/.ssh/generate-ssh-keys.sh"
@@ -54,7 +55,7 @@ int netconf_configure(void) {
 
     //check if was already ran
     sr_val_t *val = 0;
-    rc = sr_get_item(session_running, "/ietf-keystore:keystore", 0, &val);
+    rc = sr_get_item(session_running, IETF_KEYSTORE_SCHEMA_XPATH, 0, &val);
     if(rc != SR_ERR_OK) {
         log_error("sr_get_item failed\n");
         return NTS_ERR_FAILED;
@@ -99,7 +100,7 @@ int netconf_configure(void) {
     log_add_verbose(1, "Configuring connection endpoints...");
     rc = configure_endpoints_connections(session_running);
     if(rc != 0) {
-        log_error("could not configure endpoint connections forNETCONF Server\n");
+        log_error("could not configure endpoint connections for NETCONF Server\n");
         return NTS_ERR_FAILED;
     }
     log_add(1, LOG_COLOR_BOLD_GREEN"done\n"LOG_COLOR_RESET);
@@ -121,9 +122,9 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
     }
 
     struct lys_module *module;
-    module = (struct lys_module *)ly_ctx_get_module(session_context, "ietf-keystore", 0, 0);
+    module = (struct lys_module *)ly_ctx_get_module(session_context, IETF_KEYSTORE_MODULE, 0, 0);
     if(module == 0) {
-        log_error("could not get module %s from context\n", "ietf-keystore");
+        log_error("could not get module %s from context\n", IETF_KEYSTORE_MODULE);
         return NTS_ERR_FAILED;
     }
     
@@ -134,7 +135,7 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']/algorithm", KS_KEY_NAME);
+    sprintf(xpath, IETF_KEYSTORE_ASYMETRIC_KEY_SCHEMA_XPATH"/algorithm", KS_KEY_NAME);
     rcl = lyd_new_path(keystore_node, 0, xpath, "rsa2048", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
@@ -148,7 +149,7 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
     }
     log_add_verbose(2, "Private Key that was built: \n%s\n", private_key);
 
-    sprintf(xpath, "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']/private-key", KS_KEY_NAME);
+    sprintf(xpath, IETF_KEYSTORE_ASYMETRIC_KEY_SCHEMA_XPATH"/private-key", KS_KEY_NAME);
     rcl = lyd_new_path(keystore_node, 0, xpath, private_key, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
@@ -164,7 +165,7 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
     }
     log_add_verbose(2, "Public Key that was built: \n%s\n", public_key);
 
-    sprintf(xpath, "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']/public-key", KS_KEY_NAME);
+    sprintf(xpath, IETF_KEYSTORE_ASYMETRIC_KEY_SCHEMA_XPATH"/public-key", KS_KEY_NAME);
     rcl = lyd_new_path(keystore_node, 0, xpath, public_key, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
@@ -180,7 +181,7 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
     }
     log_add_verbose(2, "Certificate that was built: \n%s\n", certificate);
 
-    sprintf(xpath, "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']/certificates/certificate[name='%s']/cert", KS_KEY_NAME, KS_CERT_NAME);
+    sprintf(xpath, IETF_KEYSTORE_ASYMETRIC_KEY_SCHEMA_XPATH"/certificates/certificate[name='%s']/cert", KS_KEY_NAME, KS_CERT_NAME);
     rcl = lyd_new_path(keystore_node, 0, xpath, certificate, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
@@ -195,7 +196,7 @@ static int load_ssh_keys(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_validate(session, "ietf-keystore", 0);
+    rc = sr_validate(session, IETF_KEYSTORE_MODULE, 0);
     if(rc != SR_ERR_OK) {
         struct ly_err_item *err = ly_err_first(session_context);
         log_error("sr_validate issues on STARTUP: %s\n", err->msg);
@@ -219,9 +220,9 @@ static int load_trusted_certificates(sr_session_ctx_t *session) {
 
     struct lyd_node *trusted_certificate_node = 0;
     struct lys_module *module;
-    module = (struct lys_module *)ly_ctx_get_module(session_context, "ietf-truststore", 0, 0);
+    module = (struct lys_module *)ly_ctx_get_module(session_context, IETF_TRUSTSTORE_MODULE, 0, 0);
     if(module == 0) {
-        log_error("could not get module %s from context\n", "ietf-truststore");
+        log_error("could not get module %s from context\n", IETF_TRUSTSTORE_MODULE);
         return NTS_ERR_FAILED;
     }
 
@@ -231,20 +232,16 @@ static int load_trusted_certificates(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    char xpath[500];
-
-    sprintf(xpath, "/ietf-truststore:truststore/certificates[name='clientcerts']/certificate[name='clientcert']/cert");
     char *client_cert = read_key(CLIENT_CERT_PATH);
-    rcl = lyd_new_path(trusted_certificate_node, 0, xpath, client_cert, 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(trusted_certificate_node, 0, IETF_TRUSTSTORE_CERT_PATH_SCHEMA_XPATH, client_cert, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
     free(client_cert);
 
-    sprintf(xpath, "/ietf-truststore:truststore/certificates[name='cacerts']/certificate[name='cacert']/cert");
     char *ca_cert = read_key(CA_CERT_PATH);
-    rcl = lyd_new_path(trusted_certificate_node, 0, xpath, ca_cert, 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(trusted_certificate_node, 0, IETF_TRUSTSTORE_CA_CERT_PATH_SCHEMA_XPATH, ca_cert, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
@@ -257,10 +254,10 @@ static int load_trusted_certificates(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_validate(session, "ietf-truststore", 0);
+    rc = sr_validate(session, IETF_TRUSTSTORE_MODULE, 0);
     if(rc != SR_ERR_OK) {
         struct ly_err_item *err = ly_err_first(session_context);
-        log_error("sr_validate issues on STARTUP: %s\n", err->msg);
+        log_error("sr_validate issues: %s\n", err->msg);
         return NTS_ERR_FAILED;
     }
 
@@ -278,12 +275,11 @@ static int configure_nacm(sr_session_ctx_t *session) {
 
     int rc = NTS_ERR_OK;
     struct lyd_node *rcl = 0;
-    char xpath[100];
 
     struct lys_module *module = 0;
-    module = (struct lys_module *) ly_ctx_get_module(session_context, "ietf-netconf-acm", 0, 0);
+    module = (struct lys_module *) ly_ctx_get_module(session_context, IETF_NETCONF_ACM_MODULE, 0, 0);
     if(module == 0) {
-        log_error("could not get module %s from context\n", "ietf-netconf-acm");
+        log_error("could not get module %s from context\n", IETF_NETCONF_ACM_MODULE);
         return NTS_ERR_FAILED;
     }
 
@@ -294,58 +290,50 @@ static int configure_nacm(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/enable-nacm");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "true", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_ENABLE_NACM_SCHEMA_XPATH, "true", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/groups/group[name='sudo']/user-name");
     // we hardcoded here the username to be used
-    rcl = lyd_new_path(nacm_node, 0, xpath, "netconf", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_GROUPS_SCHEMA_XPATH"/group[name='sudo']/user-name", "netconf", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/group");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "sudo", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/group", "sudo", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/rule[name='allow-all-sudo']/module-name");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "*", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/rule[name='allow-all-sudo']/module-name", "*", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/rule[name='allow-all-sudo']/path");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "/", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/rule[name='allow-all-sudo']/path", "/", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/rule[name='allow-all-sudo']/access-operations");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "*", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/rule[name='allow-all-sudo']/access-operations", "*", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/rule[name='allow-all-sudo']/action");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "permit", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/rule[name='allow-all-sudo']/action", "permit", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-acm:nacm/rule-list[name='sudo-rules']/rule[name='allow-all-sudo']/comment");
-    rcl = lyd_new_path(nacm_node, 0, xpath, "Corresponds all the rules under the sudo group as defined in O-RAN.WG4.MP.0-v05.00", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(nacm_node, 0, IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH"[name='sudo-rules']/rule[name='allow-all-sudo']/comment", "Corresponds all the rules under the sudo group as defined in O-RAN.WG4.MP.0-v05.00", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not create yang path\n");
         return NTS_ERR_FAILED;
@@ -357,10 +345,10 @@ static int configure_nacm(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_validate(session, "ietf-netconf-acm", 0);
+    rc = sr_validate(session, IETF_NETCONF_ACM_MODULE, 0);
     if(rc != SR_ERR_OK) {
         struct ly_err_item *err = ly_err_first(session_context);
-        log_error("sr_validate issues on STARTUP: %s\n", err->msg);
+        log_error("sr_validate issues: %s\n", err->msg);
         return NTS_ERR_FAILED;
     }
 
@@ -403,7 +391,7 @@ static int create_ssh_listen_endpoints(struct lyd_node *netconf_node, int ssh_co
         char endpoint_name[100];
         sprintf(endpoint_name, "mng-ssh-%d", i);
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters/local-address", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH"/local-address", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, local_ip, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
@@ -412,70 +400,70 @@ static int create_ssh_listen_endpoints(struct lyd_node *netconf_node, int ssh_co
 
         char local_port[10];
         sprintf(local_port, "%d", nc_config_netconf_port++);
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters/local-port", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH"/local-port", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, local_port, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters/keepalives/idle-time", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/idle-time", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "1", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters/keepalives/max-probes", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/max-probes", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "10", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters/keepalives/probe-interval", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/probe-interval", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "5", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/server-identity/host-key[name='default-key']/public-key/keystore-reference", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/server-identity/host-key[name='default-key']/public-key/keystore-reference", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, KS_KEY_NAME, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/publickey", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/supported-authentication-methods/publickey", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/passsword", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/supported-authentication-methods/passsword", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/other", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/supported-authentication-methods/other", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "interactive", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users/user[name='netconf']/authorized-key[name='%s']/algorithm", endpoint_name, KS_KEY_NAME);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/users/user[name='netconf']/authorized-key[name='%s']/algorithm", endpoint_name, KS_KEY_NAME);
         rcl = lyd_new_path(netconf_node, 0, xpath, "ssh-rsa", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters/client-authentication/users/user[name='netconf']/authorized-key[name='%s']/key-data", endpoint_name, KS_KEY_NAME);
+        sprintf(xpath, IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/users/user[name='netconf']/authorized-key[name='%s']/key-data", endpoint_name, KS_KEY_NAME);
         rcl = lyd_new_path(netconf_node, 0, xpath, ssh_key_string, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
@@ -518,91 +506,91 @@ static int create_tls_listen_endpoints(struct lyd_node *netconf_node, int tls_co
             sprintf(local_port, "%d", nc_config_netconf_port++);
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters/local-address", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH"/local-address", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, local_ip, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters/local-port", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH"/local-port", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, local_port, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters/keepalives/idle-time", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/idle-time", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "1", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters/keepalives/max-probes", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/max-probes", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "10", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters/keepalives/probe-interval", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH"/keepalives/probe-interval", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "5", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/server-identity/keystore-reference/asymmetric-key", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/server-identity/keystore-reference/asymmetric-key", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, KS_KEY_NAME, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/server-identity/keystore-reference/certificate", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/server-identity/keystore-reference/certificate", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, KS_CERT_NAME, 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/required", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/required", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/ca-certs", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/ca-certs", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "cacerts", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/client-certs", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/client-certs", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "clientcerts", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/cert-maps/cert-to-name[id='1']/fingerprint", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/cert-maps/cert-to-name[id='1']/fingerprint", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "02:E9:38:1F:F6:8B:62:DE:0A:0B:C5:03:81:A8:03:49:A0:00:7F:8B:F3", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/cert-maps/cert-to-name[id='1']/map-type", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/cert-maps/cert-to-name[id='1']/map-type", endpoint_name);
         rcl = lyd_new_path(netconf_node, session_context, xpath, "ietf-x509-cert-to-name:specified", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
             return NTS_ERR_FAILED;
         }
 
-        sprintf(xpath, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters/client-authentication/cert-maps/cert-to-name[id='1']/name", endpoint_name);
+        sprintf(xpath, IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH"/client-authentication/cert-maps/cert-to-name[id='1']/name", endpoint_name);
         rcl = lyd_new_path(netconf_node, 0, xpath, "netconf", 0, LYD_PATH_OPT_NOPARENTRET);
         if(rcl == 0) {
             log_error("could not created yang path\n");
@@ -619,15 +607,15 @@ static int configure_endpoints_connections(sr_session_ctx_t *session) {
     int rc = NTS_ERR_OK;
 
     struct lys_module *module = 0;
-    module = (struct lys_module *)ly_ctx_get_module(session_context, "ietf-netconf-server", 0, 0);
+    module = (struct lys_module *)ly_ctx_get_module(session_context, IETF_NETCONF_SERVER_MODULE, 0, 0);
     if(module == 0) {
-        log_error("could not get module %s from context\n", "ietf-netconf-server");
+        log_error("could not get module %s from context\n", IETF_NETCONF_SERVER_MODULE);
         return NTS_ERR_FAILED;
     }
 
 
     struct lyd_node *netconf_node = 0;
-    netconf_node = lyd_new_path(NULL, session_context, "/ietf-netconf-server:netconf-server", 0, 0, 0);
+    netconf_node = lyd_new_path(NULL, session_context, IETF_NETCONF_SERVER_SCHEMA_XPATH, 0, 0, 0);
     if(netconf_node == 0) {
         log_error("could not create a new lyd_node\n");
         return NTS_ERR_FAILED;
@@ -668,7 +656,7 @@ static int configure_endpoints_connections(sr_session_ctx_t *session) {
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_validate(session, "ietf-netconf-server", 0);
+    rc = sr_validate(session, IETF_NETCONF_SERVER_MODULE, 0);
     if(rc != SR_ERR_OK) {
         struct ly_err_item *err = ly_err_first(session_context);
         log_error("sr_validate issues on STARTUP: %s\n", err->msg);
diff --git a/ntsimulator/ntsim-ng/core/xpath.h b/ntsimulator/ntsim-ng/core/xpath.h
new file mode 100644 (file)
index 0000000..b0514ff
--- /dev/null
@@ -0,0 +1,88 @@
+/*************************************************************************
+*
+* Copyright 2020 highstreet technologies GmbH and others
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+***************************************************************************/
+
+#pragma once
+
+
+#define NTS_MANAGER_MODULE                                      "nts-manager"
+#define NTS_MANAGER_SIMULATION_SCHEMA_XPATH                     "/nts-manager:simulation"
+#define NTS_MANAGER_AVAILABLE_IMAGES_SCHEMA_XPATH               "/nts-manager:simulation/available-images"
+#define NTS_MANAGER_FUNCTION_LIST_SCHEMA_XPATH                  "/nts-manager:simulation/network-functions/network-function"
+#define NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH                 "/nts-manager:simulation/sdn-controller"
+#define NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH                   "/nts-manager:simulation/ves-endpoint"
+
+#define NTS_NETWORK_FUNCTION_MODULE                             "nts-network-function"
+#define NTS_NF_INFO_BUILD_TIME_XPATH                            "/nts-network-function:info/build-time"
+#define NTS_NF_INFO_STARTED_FEATURES_SCHEMA_XPATH               "/nts-network-function:info/started-features"
+#define NTS_NF_INFO_VERSION_XPATH                               "/nts-network-function:info/version"
+#define NTS_NF_NETWORK_FUNCTION_SCHEMA_XPATH                    "/nts-network-function:simulation/network-function"
+#define NTS_NF_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH              "/nts-network-function:simulation/network-function/function-type"
+#define NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH               "/nts-network-function:simulation/network-function/mount-point-addressing-method"
+#define NTS_NF_FAULT_GENERATION_SCHEMA_XPATH                    "/nts-network-function:simulation/network-function/fault-generation"
+#define NTS_NF_FAULT_COUNT_LIST_SCHEMA_XPATH                    "/nts-network-function:simulation/network-function/fault-generation/fault-count"
+#define NTS_NF_NETCONF_SCHEMA_XPATH                             "/nts-network-function:simulation/network-function/netconf"
+#define NTS_NF_NETCONF_CALLHOME_ENABLED_SCHEMA_PATH             "/nts-network-function:simulation/network-function/netconf/call-home"
+#define NTS_NF_NETCONF_FAULTS_ENABLED_SCHEMA_PATH               "/nts-network-function:simulation/network-function/netconf/faults-enabled"
+#define NTS_NF_VES_SCHEMA_XPATH                                 "/nts-network-function:simulation/network-function/ves"
+#define NTS_NF_VES_FAULTS_ENABLED_SCHEMA_XPATH                  "/nts-network-function:simulation/network-function/ves/faults-enabled"
+#define NTS_NF_VES_HEARTBEAT_SCHEMA_XPATH                       "/nts-network-function:simulation/network-function/ves/heartbeat-period"
+#define NTS_NF_VES_PNF_REGISTRATION_SCHEMA_XPATH                "/nts-network-function:simulation/network-function/ves/pnf-registration"
+#define NTS_NF_VES_ENDPOINT_CONFIG_XPATH                        "/nts-network-function:simulation/ves-endpoint"
+#define NTS_NF_SDN_CONTROLLER_CONFIG_XPATH                      "/nts-network-function:simulation/sdn-controller"
+
+#define NTS_NF_RPC_POPULATE_SCHEMA_XPATH                        "/nts-network-function:datastore-populate"
+#define NTS_NF_RPC_FEATURE_CONTROL_SCHEMA_XPATH                 "/nts-network-function:feature-control"
+#define NTS_NF_RPC_FAULTS_CLEAR_SCHEMA_XPATH                    "/nts-network-function:clear-fault-counters"
+#define NTS_NF_RPC_MANUAL_NOTIF_SCHEMA_XPATH                    "/nts-network-function:invoke-notification"
+#define NTS_NF_RPC_FILE_READY_SCHEMA_XPATH                      "/nts-network-function:invoke-ves-pm-file-ready"
+
+#define IETF_KEYSTORE_MODULE                                    "ietf-keystore"
+#define IETF_KEYSTORE_SCHEMA_XPATH                              "/ietf-keystore:keystore"
+#define IETF_KEYSTORE_ASYMETRIC_KEY_SCHEMA_XPATH                "/ietf-keystore:keystore/asymmetric-keys/asymmetric-key[name='%s']"
+
+#define IETF_TRUSTSTORE_MODULE                                  "ietf-truststore"
+#define IETF_TRUSTSTORE_CERT_PATH_SCHEMA_XPATH                  "/ietf-truststore:truststore/certificates[name='clientcerts']/certificate[name='clientcert']/cert"
+#define IETF_TRUSTSTORE_CA_CERT_PATH_SCHEMA_XPATH               "/ietf-truststore:truststore/certificates[name='cacerts']/certificate[name='cacert']/cert"
+
+#define IETF_NETCONF_ACM_MODULE                                 "ietf-netconf-acm"
+#define IETF_NETCONF_ACM_ENABLE_NACM_SCHEMA_XPATH               "/ietf-netconf-acm:nacm/enable-nacm"
+#define IETF_NETCONF_ACM_GROUPS_SCHEMA_XPATH                    "/ietf-netconf-acm:nacm/groups"
+#define IETF_NETCONF_ACM_RULE_LIST_SCHEMA_XPATH                 "/ietf-netconf-acm:nacm/rule-list"
+
+#define IETF_NETCONF_MONITORING_MODULE                          "ietf-netconf-monitoring"
+#define IETF_NETCONF_MONITORING_STATE_SCHEMAS_SCHEMA_XPATH      "/ietf-netconf-monitoring:netconf-state/schemas"
+
+#define IETF_NETCONF_SERVER_MODULE                              "ietf-netconf-server"
+#define IETF_NETCONF_SERVER_SCHEMA_XPATH                        "/ietf-netconf-server:netconf-server"
+#define IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH      "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters"
+#define IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH   "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters"
+#define IETF_NETCONF_SERVER_CH_CONN_PERSISTENT_SCHEMA_XPATH     "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/connection-type/persistent"
+#define IETF_NETCONF_SERVER_SSH_TCP_SERVER_PARAM_SCHEMA_XPATH   "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/tcp-server-parameters"
+#define IETF_NETCONF_SERVER_SSH_SERVER_PARAM_SCHEMA_XPATH       "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/ssh/ssh-server-parameters"
+#define IETF_NETCONF_SERVER_TLS_TCP_SERVER_PARAM_SCHEMA_XPATH   "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tcp-server-parameters"
+#define IETF_NETCONF_SERVER_TLS_SERVER_PARAM_SCHEMA_XPATH       "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/tls/tls-server-parameters"
+
+#define IETF_SYSTEM_NAME_SCHEMA_XPATH                           "/ietf-system:system/onap-system:name"
+#define IETF_SYSTEM_WEB_UI_SCHEMA_XPATH                         "/ietf-system:system/onap-system:web-ui"
+#define IETF_SYSTEM_CONTACT_SCHEMA_XPATH                        "/ietf-system:system/contact"
+#define IETF_SYSTEM_HOSTNAME_SCHEMA_XPATH                       "/ietf-system:system/hostname"
+#define IETF_SYSTEM_LOCATION_SCHEMA_XPATH                       "/ietf-system:system/location"
+#define IETF_SYSTEM_TIMEZONE_NAME_SCHEMA_XPATH                  "/ietf-system:system/clock/timezone-name"
+#define IETF_SYSTEM_NTP_ENABLED_SCHEMA_XPATH                    "/ietf-system:system/ntp/enabled"
+
+#define NC_NOTIFICATIONS_MODULE                                 "nc-notifications"
+#define NC_NOTIFICATIONS_STREAMS_SCHEMA_XPATH                   "/nc-notifications:netconf/streams"
index e768c73..a8f0de8 100644 (file)
 #include <sysrepo/values.h>
 
 #include "core/session.h"
+#include "core/xpath.h"
 #include "core/framework.h"
 
-#define MANUAL_NOTIFICATION_RPC_SCHEMA_XPATH         "/nts-network-function:invoke-notification"
-
 static int manual_notification_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 sr_subscription_ctx_t *manual_notification_subscription = 0;
 
@@ -46,7 +45,7 @@ int manual_notification_feature_start(sr_session_ctx_t *current_session) {
     assert(current_session);
 
     if(manual_notification_subscription == 0) {
-        int rc = sr_rpc_subscribe(current_session, MANUAL_NOTIFICATION_RPC_SCHEMA_XPATH, manual_notification_pm_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &manual_notification_subscription);
+        int rc = sr_rpc_subscribe(current_session, NTS_NF_RPC_MANUAL_NOTIF_SCHEMA_XPATH, manual_notification_pm_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &manual_notification_subscription);
         if(rc != SR_ERR_OK) {
             log_error("error from sr_rpc_subscribe: %s\n", sr_strerror(rc));
             return NTS_ERR_FAILED;
@@ -82,7 +81,7 @@ static int manual_notification_pm_cb(sr_session_ctx_t *session, const char *path
         return rc;
     }
 
-    rc = sr_val_set_xpath(output[0], MANUAL_NOTIFICATION_RPC_SCHEMA_XPATH"/status");
+    rc = sr_val_set_xpath(output[0], NTS_NF_RPC_MANUAL_NOTIF_SCHEMA_XPATH"/status");
     if(SR_ERR_OK != rc) {
         return rc;
     }
index 0c59997..a56e45b 100644 (file)
 
 #include "core/session.h"
 #include "core/framework.h"
+#include "core/xpath.h"
 
-#define NETCONF_CALLHOME_ENABLED_SCHEMA_PATH        "/nts-network-function:simulation/network-function/netconf/call-home"
 #define NETCONF_CALLHOME_CURL_SEND_PAYLOAD_FORMAT   "{\"odl-netconf-callhome-server:device\":[{\"odl-netconf-callhome-server:unique-id\":\"%s\",\"odl-netconf-callhome-server:ssh-host-key\":\"%s\",\"odl-netconf-callhome-server:credentials\":{\"odl-netconf-callhome-server:username\":\"netconf\",\"odl-netconf-callhome-server:passwords\":[\"netconf!\"]}}]}"
-#define SDN_CONTROLLER_DETAILS_SCHEMA_PATH          "/nts-network-function:simulation/sdn-controller"
 
 static int create_ssh_callhome_endpoint(sr_session_ctx_t *current_session, struct lyd_node *netconf_node);
 static int create_tls_callhome_endpoint(sr_session_ctx_t *current_session, struct lyd_node *netconf_node);
@@ -50,7 +49,7 @@ int netconf_call_home_feature_start(sr_session_ctx_t *current_session) {
     sr_val_t *value = 0;
 
     bool callhome_enabled = false;
-    int rc = sr_get_item(current_session, NETCONF_CALLHOME_ENABLED_SCHEMA_PATH, 0, &value);
+    int rc = sr_get_item(current_session, NTS_NF_NETCONF_CALLHOME_ENABLED_SCHEMA_PATH, 0, &value);
     if(rc == SR_ERR_OK) {
         callhome_enabled = value->data.bool_val;
         sr_free_val(value);
@@ -68,7 +67,7 @@ int netconf_call_home_feature_start(sr_session_ctx_t *current_session) {
     }
 
     struct lyd_node *netconf_node = 0;
-    netconf_node = lyd_new_path(NULL, session_context, "/ietf-netconf-server:netconf-server", 0, 0, 0);
+    netconf_node = lyd_new_path(NULL, session_context, IETF_NETCONF_SERVER_SCHEMA_XPATH, 0, 0, 0);
     if(netconf_node == 0) {
         log_error("could not create a new lyd_node\n");
         return NTS_ERR_FAILED;
@@ -92,7 +91,7 @@ int netconf_call_home_feature_start(sr_session_ctx_t *current_session) {
         return NTS_ERR_FAILED;
     }
 
-    rc = sr_validate(current_session, "ietf-netconf-server", 0);
+    rc = sr_validate(current_session, IETF_NETCONF_SERVER_MODULE, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_validate issues on STARTUP\n");
         return NTS_ERR_FAILED;
@@ -130,33 +129,29 @@ static int create_ssh_callhome_endpoint(sr_session_ctx_t *current_session, struc
         return NTS_ERR_FAILED;
     }
 
-    char xpath[500];
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters/keepalives/idle-time");
-    struct lyd_node *rcl = lyd_new_path(netconf_node, 0, xpath, "1", 0, LYD_PATH_OPT_NOPARENTRET);
+    
+    struct lyd_node *rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH"/keepalives/idle-time", "1", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         free(controller_ip);
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters/keepalives/max-probes");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "10", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH"/keepalives/max-probes", "10", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         free(controller_ip);
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters/keepalives/probe-interval");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "5", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH"/keepalives/probe-interval", "5", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         free(controller_ip);
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters/remote-address");
-    rcl = lyd_new_path(netconf_node, 0, xpath, controller_ip, 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH"/remote-address", controller_ip, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         free(controller_ip);
@@ -164,52 +159,44 @@ static int create_ssh_callhome_endpoint(sr_session_ctx_t *current_session, struc
     }
     free(controller_ip);
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/tcp-client-parameters/remote-port");
     char port[20];
     sprintf(port, "%d", controller_callhome_port);
-    rcl = lyd_new_path(netconf_node, 0, xpath, port, 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_TCP_CLIENT_SCHEMA_XPATH"/remote-port", port, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters/server-identity/host-key[name='default-key']/public-key/keystore-reference");
-    rcl = lyd_new_path(netconf_node, 0, xpath, KS_KEY_NAME, 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH"/server-identity/host-key[name='default-key']/public-key/keystore-reference", KS_KEY_NAME, 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/publickey");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH"/client-authentication/supported-authentication-methods/publickey", "", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/passsword");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH"/client-authentication/supported-authentication-methods/passsword", "", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters/client-authentication/supported-authentication-methods/other");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "interactive", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH"/client-authentication/supported-authentication-methods/other", "interactive", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
 
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/endpoints/endpoint[name='callhome-ssh']/ssh/ssh-server-parameters/client-authentication/users");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_SSH_SERVER_PARAMS_SCEHMA_XPATH"/client-authentication/users", "", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
     }
-
-    sprintf(xpath, "/ietf-netconf-server:netconf-server/call-home/netconf-client[name='default-client']/connection-type/persistent");
-    rcl = lyd_new_path(netconf_node, 0, xpath, "", 0, LYD_PATH_OPT_NOPARENTRET);
+    rcl = lyd_new_path(netconf_node, 0, IETF_NETCONF_SERVER_CH_CONN_PERSISTENT_SCHEMA_XPATH, "", 0, LYD_PATH_OPT_NOPARENTRET);
     if(rcl == 0) {
         log_error("could not created yang path\n");
         return NTS_ERR_FAILED;
index d973827..1531126 100644 (file)
@@ -30,8 +30,7 @@
 
 #include "core/framework.h"
 #include "core/session.h"
-
-#define FILE_READY_RPC_SCHEMA_XPATH         "/nts-network-function:invoke-ves-pm-file-ready"
+#include "core/xpath.h"
 
 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);
@@ -50,7 +49,7 @@ int ves_file_ready_feature_start(sr_session_ctx_t *current_session) {
     assert_session();
 
     if(ves_file_ready_subscription == 0) {
-        int rc = sr_rpc_subscribe(current_session, FILE_READY_RPC_SCHEMA_XPATH, ves_file_ready_invoke_pm_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &ves_file_ready_subscription);
+        int rc = sr_rpc_subscribe(current_session, NTS_NF_RPC_FILE_READY_SCHEMA_XPATH, ves_file_ready_invoke_pm_cb, 0, 0, SR_SUBSCR_CTX_REUSE, &ves_file_ready_subscription);
         if(rc != SR_ERR_OK) {
             log_error("error from sr_rpc_subscribe: %s\n", sr_strerror(rc));
             return NTS_ERR_FAILED;
@@ -138,7 +137,7 @@ static int ves_file_ready_invoke_pm_cb(sr_session_ctx_t *session, const char *pa
         return rc;
     }
 
-    rc = sr_val_set_xpath(output[0], FILE_READY_RPC_SCHEMA_XPATH"/status");
+    rc = sr_val_set_xpath(output[0], NTS_NF_RPC_FILE_READY_SCHEMA_XPATH"/status");
     if(SR_ERR_OK != rc) {
         return rc;
     }
index 5e7db90..4d9b3a6 100644 (file)
@@ -32,8 +32,7 @@
 
 #include "core/session.h"
 #include "core/framework.h"
-
-#define HEARTBEAT_SCHEMA_XPATH      "/nts-network-function:simulation/network-function/ves/heartbeat-period" 
+#include "core/xpath.h"
 
 static volatile int ves_heartbeat_period;
 static int ves_sequence_number;
@@ -73,7 +72,7 @@ int ves_heartbeat_feature_start(sr_session_ctx_t *current_session) {
         ves_heartbeat_period = 0;
         ves_sequence_number = 0;
 
-        int rc = sr_get_item(current_session, HEARTBEAT_SCHEMA_XPATH, 0, &value);
+        int rc = sr_get_item(current_session, NTS_NF_VES_HEARTBEAT_SCHEMA_XPATH, 0, &value);
         if(rc == SR_ERR_OK) {
             ves_heartbeat_period_set(value->data.uint16_val);
             sr_free_val(value);
@@ -82,7 +81,7 @@ int ves_heartbeat_feature_start(sr_session_ctx_t *current_session) {
             log_error("sr_get_item failed\n");
         }
 
-        rc = sr_module_change_subscribe(current_session, "nts-network-function", HEARTBEAT_SCHEMA_XPATH, heartbeat_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE, &ves_heartbeat_subscription);
+        rc = sr_module_change_subscribe(current_session, NTS_NETWORK_FUNCTION_MODULE, NTS_NF_VES_HEARTBEAT_SCHEMA_XPATH, heartbeat_change_cb, NULL, 0, SR_SUBSCR_CTX_REUSE, &ves_heartbeat_subscription);
         if(rc != SR_ERR_OK) {
             log_error("could not subscribe to heartbeat\n");
             return NTS_ERR_FAILED;
@@ -326,7 +325,7 @@ static int heartbeat_change_cb(sr_session_ctx_t *session, const char *module_nam
     sr_val_t *new_value = 0;
 
     if(event == SR_EV_DONE) {
-        rc = sr_get_changes_iter(session, HEARTBEAT_SCHEMA_XPATH, &it);
+        rc = sr_get_changes_iter(session, NTS_NF_VES_HEARTBEAT_SCHEMA_XPATH, &it);
         if(rc != SR_ERR_OK) {
             log_error("sr_get_changes_iter failed\n");
             return SR_ERR_VALIDATION_FAILED;
index 2d6e3a5..d525475 100644 (file)
@@ -28,8 +28,7 @@
 
 #include "core/session.h"
 #include "core/framework.h"
-
-#define PNF_REGISTRATION_SCHEMA_XPATH               "/nts-network-function:simulation/network-function/ves/pnf-registration"
+#include "core/xpath.h"
 
 static int ves_pnf_sequence_number = 0;
 
@@ -50,7 +49,7 @@ int ves_pnf_registration_feature_start(sr_session_ctx_t *current_session) {
     sr_val_t *value = 0;
     int rc = NTS_ERR_OK;
     bool pnf_registration_enabled = false;
-    rc = sr_get_item(current_session, PNF_REGISTRATION_SCHEMA_XPATH, 0, &value);
+    rc = sr_get_item(current_session, NTS_NF_VES_PNF_REGISTRATION_SCHEMA_XPATH, 0, &value);
     if(rc == SR_ERR_OK) {
         pnf_registration_enabled = value->data.bool_val;
         sr_free_val(value);
index 0ae406a..69a5314 100644 (file)
 
 #include "core/session.h"
 #include "core/framework.h"
-
-#define SYSTEM_NAME_SCHEMA_XPATH                "/ietf-system:system/onap-system:name"
-#define SYSTEM_WEB_UI_SCHEMA_XPATH              "/ietf-system:system/onap-system:web-ui"
-#define IETF_SYSTEM_CONTACT_SCHEMA_XPATH        "/ietf-system:system/contact"
-#define IETF_SYSTEM_HOSTNAME_SCHEMA_XPATH       "/ietf-system:system/hostname"
-#define IETF_SYSTEM_LOCATION_SCHEMA_XPATH       "/ietf-system:system/location"
-#define IETF_SYSTEM_TIMEZONE_NAME_SCHEMA_XPATH  "/ietf-system:system/clock/timezone-name"
-#define IETF_SYSTEM_NTP_ENABLED_SCHEMA_XPATH    "/ietf-system:system/ntp/enabled"
+#include "core/xpath.h"
 
 static int web_cut_through_status = 0;
 
@@ -49,7 +42,7 @@ int web_cut_through_feature_start(sr_session_ctx_t *current_session) {
 
     if(web_cut_through_status == 0) {
         //update ietf-system details
-        int rc = sr_set_item_str(current_session, SYSTEM_NAME_SCHEMA_XPATH, framework_environment.settings.hostname, 0, 0);
+        int rc = sr_set_item_str(current_session, IETF_SYSTEM_NAME_SCHEMA_XPATH, framework_environment.settings.hostname, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
             return NTS_ERR_FAILED;
@@ -70,7 +63,7 @@ int web_cut_through_feature_start(sr_session_ctx_t *current_session) {
             return NTS_ERR_FAILED;
         }
 
-        rc = sr_set_item_str(current_session, SYSTEM_WEB_UI_SCHEMA_XPATH, web_ui, 0, 0);
+        rc = sr_set_item_str(current_session, IETF_SYSTEM_WEB_UI_SCHEMA_XPATH, web_ui, 0, 0);
         free(web_ui);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
@@ -125,13 +118,13 @@ int web_cut_through_feature_stop(sr_session_ctx_t *current_session) {
 
     if(web_cut_through_status) {
         //update ietf-system details
-        int rc = sr_delete_item(current_session, SYSTEM_NAME_SCHEMA_XPATH, 0);
+        int rc = sr_delete_item(current_session, IETF_SYSTEM_NAME_SCHEMA_XPATH, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_delete_item failed\n");
             return NTS_ERR_FAILED;
         }
 
-        rc = sr_delete_item(current_session, SYSTEM_WEB_UI_SCHEMA_XPATH, 0);
+        rc = sr_delete_item(current_session, IETF_SYSTEM_WEB_UI_SCHEMA_XPATH, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_delete_item failed\n");
             return NTS_ERR_FAILED;
index b0e26af..006ee46 100644 (file)
 static int instances = 0;
 static FILE* logfile = 0;
 
+static int file_no = 0;
+static int line_no = 0;
+static const char *filename;
+
 static char *extract_format(const char *format);
 
 void log_init(const char *logfilename) {
@@ -46,9 +50,24 @@ void log_init(const char *logfilename) {
     logfile = fopen(logfilename, "w");
 
     assert(logfile);
+    file_no = 0;
+    line_no = 0;
+    filename = logfilename;
 }
 
 void log__message(char const * const fname, uint32_t location, int verbose_level, const char *format, ...) {
+    if(verbose_level >= 0) {
+        line_no++;
+        if(line_no >= 5000) {
+            fclose(logfile);
+
+            file_no++;
+            char logfilename[512];
+            sprintf(logfilename, "%s.%d", filename, file_no);
+            logfile = fopen(logfilename, "w");
+            line_no = 0;
+        }
+    }
 
     va_list arg;
 
index f1a71ac..14f2c34 100644 (file)
 #include "utils/sys_utils.h"
 #include "core/framework.h"
 #include "core/session.h"
+#include "core/xpath.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
 
-#define NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH             "/nts-manager:simulation/sdn-controller"
-#define NTS_NF_SDN_CONTROLLER_CONFIG_XPATH                  "/nts-network-function:simulation/sdn-controller"
-#define NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH               "/nts-manager:simulation/ves-endpoint"
-#define NTS_NF_VES_ENDPOINT_CONFIG_XPATH                    "/nts-network-function:simulation/ves-endpoint"
-
-#define NTS_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH             "/nts-network-function:simulation/network-function/function-type"
-#define NTS_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH              "/nts-network-function:simulation/network-function/mount-point-addressing-method"
-#define NTS_NETWORK_FUNCTION_FAULT_GENERATION_SCHEMA_XPATH  "/nts-network-function:simulation/network-function/fault-generation"
-#define NTS_NETWORK_FUNCTION_NETCONF_SCHEMA_XPATH           "/nts-network-function:simulation/network-function/netconf"
-#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 *hostname, int port, const char *priority, int seq_id) {
     assert(domain);
@@ -188,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_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, 0, &value);
+    rc = sr_get_item(session_running, 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;
@@ -229,10 +219,10 @@ ves_details_t *ves_endpoint_details_get(sr_session_ctx_t *current_session) {
     char *xpath_to_get;
 
     if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
-        xpath_to_get = "/nts-manager:simulation/ves-endpoint";
+        xpath_to_get = NTS_MANAGER_VES_ENDPOINT_CONFIG_XPATH;
     }
     else {
-        xpath_to_get = "/nts-network-function:simulation/ves-endpoint";
+        xpath_to_get = NTS_NF_VES_ENDPOINT_CONFIG_XPATH;
     }
 
     rc = sr_get_subtree(current_session, xpath_to_get, 0, &data);
@@ -352,10 +342,10 @@ controller_details_t *controller_details_get(sr_session_ctx_t *current_session)
     char *xpath_to_get;
 
     if(framework_arguments.nts_mode == NTS_MODE_MANAGER) {
-        xpath_to_get = "/nts-manager:simulation/sdn-controller";
+        xpath_to_get = NTS_MANAGER_SDN_CONTROLLER_CONFIG_XPATH;
     }
     else {
-        xpath_to_get = "/nts-network-function:simulation/sdn-controller";
+        xpath_to_get = NTS_NF_SDN_CONTROLLER_CONFIG_XPATH;
     }
 
     rc = sr_get_subtree(current_session, xpath_to_get, 0, &data);
@@ -717,19 +707,19 @@ int nts_utils_populate_info(sr_session_ctx_t *current_session, const char *funct
 
     if(manager == false) {
         //presence containers
-        rc = sr_set_item_str(current_session, NTS_NETWORK_FUNCTION_FAULT_GENERATION_SCHEMA_XPATH, 0, 0, 0);
+        rc = sr_set_item_str(current_session, NTS_NF_FAULT_GENERATION_SCHEMA_XPATH, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
             return NTS_ERR_FAILED;
         }
 
-        rc = sr_set_item_str(current_session, NTS_NETWORK_FUNCTION_NETCONF_SCHEMA_XPATH, 0, 0, 0);
+        rc = sr_set_item_str(current_session, NTS_NF_NETCONF_SCHEMA_XPATH, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
             return NTS_ERR_FAILED;
         }
 
-        rc = sr_set_item_str(current_session, NTS_NETWORK_FUNCTION_VES_SCHEMA_XPATH, 0, 0, 0);
+        rc = sr_set_item_str(current_session, NTS_NF_VES_SCHEMA_XPATH, 0, 0, 0);
         if(rc != SR_ERR_OK) {
             log_error("sr_set_item_str failed\n");
             return NTS_ERR_FAILED;
@@ -737,14 +727,14 @@ int nts_utils_populate_info(sr_session_ctx_t *current_session, const char *funct
     }
 
     //also set the network-function module for easy identifying the function type
-    rc = sr_set_item_str(current_session, NTS_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH, function_type, 0, 0);
+    rc = sr_set_item_str(current_session, NTS_NF_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH, function_type, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;
     }
 
     //mount-point-addressing-method
-    rc = sr_set_item_str(current_session, NTS_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, "docker-mapping", 0, 0);
+    rc = sr_set_item_str(current_session, NTS_NF_NETWORK_FUNCTION_MPAM_SCHEMA_XPATH, framework_environment.nts.nf_mount_point_addressing_method, 0, 0);
     if(rc != SR_ERR_OK) {
         log_error("sr_set_item_str failed\n");
         return NTS_ERR_FAILED;