Add sub-modules to ietf-netconf-monitoring. 98/5498/2
authorAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Fri, 22 Jan 2021 16:54:40 +0000 (18:54 +0200)
committerAlex Stancu <alexandru.stancu@highstreet-technologies.com>
Fri, 22 Jan 2021 17:07:41 +0000 (17:07 +0000)
Manager commit.

Issue-ID: SIM-53
Change-Id: I8cc8a263b4586d7b6d65134320ab757df142ac42
Signed-off-by: Alex Stancu <alexandru.stancu@highstreet-technologies.com>
ntsimulator/ntsim-ng/core/app/manager.c
ntsimulator/ntsim-ng/core/app/manager_operations.c

index f20ea0e..4881661 100644 (file)
@@ -37,6 +37,8 @@
 #define NTS_SDN_CONTROLLER_CONFIG_XPATH             "/nts-manager:simulation/sdn-controller"
 #define NTS_VES_ENDPOINT_CONFIG_XPATH               "/nts-manager:simulation/ves-endpoint"
 
+#define NTS_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH     "/nts-network-function:simulation/network-function/function-type"
+
 static manager_network_function_type *manager_context = 0;
 static int manager_installed_function_types_count = 0;
 
@@ -324,6 +326,13 @@ static int manager_populate_sysrepo_network_function_list(void) {
         }
     }
 
+    rc = sr_set_item_str(session_running, NTS_NETWORK_FUNCTION_FTYPE_SCHEMA_XPATH, "NTS_FUNCTION_TYPE_MANAGER", 0, 0);
+    if(rc != SR_ERR_OK) {
+        log_error("sr_set_item_str failed");
+        return NTS_ERR_FAILED;
+    }
+
+
     //apply all changes
     rc = sr_apply_changes(session_running, 0, 0);
     if(rc != SR_ERR_OK) {
@@ -386,8 +395,6 @@ static int manager_process_change(int context_index, manager_network_function_ty
     assert(context_index < manager_installed_function_types_count);
     assert(new_context);
 
-    int ret_code = NTS_ERR_OK;
-
     manager_network_function_type *current_context = &manager_context[context_index];
     int rc = 0;
 
@@ -422,8 +429,7 @@ static int manager_process_change(int context_index, manager_network_function_ty
                 rc = manager_stop_instance(current_context);
                 if(rc != NTS_ERR_OK) {
                     log_error("manager_stop_instance failed");
-                    current_context->started_instances++;
-                    ret_code = NTS_ERR_FAILED;
+                    return NTS_ERR_FAILED;
                     break;
                 }
             }
@@ -435,8 +441,7 @@ static int manager_process_change(int context_index, manager_network_function_ty
                 rc = manager_start_instance(current_context);
                 if(rc != NTS_ERR_OK) {
                     log_error("manager_start_instance failed");
-                    current_context->started_instances--;
-                    ret_code = NTS_ERR_FAILED;
+                    return NTS_ERR_FAILED;
                     break;
                 }
             }
@@ -451,8 +456,6 @@ static int manager_process_change(int context_index, manager_network_function_ty
                 rc = manager_unmount_instance(current_context);
                 if(rc != NTS_ERR_OK) {
                     log_error("manager_unmount_instance failed");
-                    current_context->mounted_instances++;
-                    ret_code = NTS_ERR_FAILED;
                     break;
                 }
             }
@@ -464,15 +467,13 @@ static int manager_process_change(int context_index, manager_network_function_ty
                 rc = manager_mount_instance(current_context);
                 if(rc != NTS_ERR_OK) {
                     log_error("manager_mount_instance failed");
-                    current_context->mounted_instances--;
-                    ret_code = NTS_ERR_FAILED;
                     break;
                 }
             }
         }
     }
 
-    return ret_code;
+    return NTS_ERR_OK;
 }
 
 static int manager_change_cb(sr_session_ctx_t *session, const char *module_name, const char *xpath, sr_event_t event, uint32_t request_id, void *private_data) {
index 347c11d..e382b02 100644 (file)
@@ -78,6 +78,7 @@ int manager_start_instance(manager_network_function_type *function_type) {
         free(instance->name);
         free(instance->mount_point_addressing_method);
         free(instance->host_ip);
+        function_type->started_instances--;
         return NTS_ERR_FAILED;
     }
 
@@ -88,6 +89,7 @@ int manager_start_instance(manager_network_function_type *function_type) {
         free(instance->mount_point_addressing_method);
         free(instance->host_ip);
         manager_port[instance->host_port] = 0;
+        function_type->started_instances--;
         return NTS_ERR_FAILED;
     }
 
@@ -202,7 +204,6 @@ int manager_stop_instance(manager_network_function_type *function_type) {
     if(instance->is_mounted) {
         if(manager_unmount_instance(function_type) != NTS_ERR_OK) {
             log_error("failed to unmount instance");
-            return NTS_ERR_FAILED;
         }
     }
 
@@ -330,6 +331,7 @@ int manager_mount_instance(manager_network_function_type *function_type) {
 
 int manager_unmount_instance(manager_network_function_type *function_type) {
     assert(function_type);
+    int ret = NTS_ERR_OK;
 
     manager_network_function_instance_t *instance = &function_type->instance[function_type->mounted_instances - 1];
 
@@ -361,10 +363,7 @@ int manager_unmount_instance(manager_network_function_type *function_type) {
         int rc = http_request(url, controller->username, controller->password, "DELETE", "", 0, 0);
         if(rc != NTS_ERR_OK) {
             log_error("http_request failed");
-            free(url);
-            free(node_id);
-            controller_details_free(controller);
-            return NTS_ERR_FAILED;
+            ret = NTS_ERR_FAILED;
         }
 
         free(url);
@@ -376,5 +375,5 @@ int manager_unmount_instance(manager_network_function_type *function_type) {
     function_type->mounted_instances--;
     function_type->instance[function_type->mounted_instances].is_mounted = false;
 
-    return NTS_ERR_OK;
+    return ret;
 }