Fixing Basic 12 Ns Primitives
[osm/LCM.git] / osm_lcm / lcm_utils.py
index 6d20318..7af63a8 100644 (file)
@@ -290,7 +290,7 @@ class LcmBase:
                 + "/"
                 + nsd_package_name
                 + "/charms/"
-                + charm_folder_name.split(".")[0]
+                + charm_folder_name.replace(".charm", "")
             )
             # Extract .charm to extract path
             with ZipFile(charm_path, "r") as zipfile:
@@ -315,10 +315,22 @@ class LcmBase:
 
             # Find nsd_package details: path, name
             revision = db_nsr.get("revision", "")
-            nsd_package_path = (
-                db_nsr["nsd-id"] + ":" + str(revision) if revision else db_nsr["nsd-id"]
-            )
-            nsd_package_name = os.listdir(self.fs.path + nsd_package_path)[0]
+
+            # Get the NSD package path
+            if revision:
+
+                nsd_package_path = (
+                    db_nsr["nsd-id"] + ":" + str(revision)
+                )
+                db_nsd = self.db.get_one("nsds_revisions", {"_id": nsd_package_path})
+
+            else:
+                nsd_package_path = db_nsr["nsd-id"]
+
+                db_nsd = self.db.get_one("nsds", {"_id": nsd_package_path})
+
+            # Get the NSD package name
+            nsd_package_name = db_nsd["_admin"]["storage"]["pkg-dir"]
 
             # Remove the existing nsd package and sync from FsMongo
             shutil.rmtree(self.fs.path + nsd_package_path, ignore_errors=True)