target_dict[key_list[-1]] = value
+def get_ee_id_parts(ee_id):
+ """
+ Parses ee_id stored at database that can be either 'version:namespace.helm_id' or only
+ namespace.helm_id for backward compatibility
+ If exists helm version can be helm-v3 or helm (helm-v2 old version)
+ """
+ version, _, part_id = ee_id.rpartition(":")
+ namespace, _, helm_id = part_id.rpartition(".")
+ return version, namespace, helm_id
+
+
class LcmBase:
def __init__(self, msg, logger):
"""
+ "/"
+ 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:
# 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)