Bug fix for O1 Simulator 41/5041/2
authoralex.stancu <alexandru.stancu@highstreet-technologies.com>
Wed, 11 Nov 2020 16:41:17 +0000 (18:41 +0200)
committeralex.stancu <alexandru.stancu@highstreet-technologies.com>
Wed, 11 Nov 2020 16:56:56 +0000 (18:56 +0200)
Fix for loading data in JSON format on install time of a YANG model.

Issue-ID: SIM-48
Signed-off-by: alex.stancu <alexandru.stancu@highstreet-technologies.com>
Change-Id: I21a62afb6de85391f33ba0ffad6ee2a19d4035e4

ntsimulator/ntsim-ng/core/context.c

index 9bc57f2..8019662 100644 (file)
@@ -260,6 +260,18 @@ bool context_module_install(const char *name, const char *path) {
     }
     free(data_path);
 
+    data_path = str_replace(path, ".yang", ".json");
+    if(file_exists(data_path)) {
+        rc = sr_install_module_data(session_connection, name, 0, data_path, LYD_JSON);
+        if(rc != SR_ERR_OK) {
+            log_message(1, " json error    ");
+            sr_remove_module(session_connection, name);
+            context_apply_changes();
+            return false;
+        }
+    }
+    free(data_path);
+
     //apply changes
     if(!context_apply_changes()) {
         sr_remove_module(session_connection, name);