feature: sol004 and sol007 14/11314/2
authorbravof <fbravo@whitestack.com>
Mon, 8 Nov 2021 20:18:50 +0000 (17:18 -0300)
committerbravof <fbravo@whitestack.com>
Tue, 9 Nov 2021 12:25:59 +0000 (09:25 -0300)
Change-Id: Ic53b1b349f9306a0ce2ec01a61837b32cf0bcfb7
Signed-off-by: bravof <fbravo@whitestack.com>
osm_lcm/ns.py

index ab25be3..b13d466 100644 (file)
@@ -415,11 +415,17 @@ class NsLcm(LcmBase):
         try:
             if vdu.get("cloud-init-file"):
                 base_folder = vnfd["_admin"]["storage"]
-                cloud_init_file = "{}/{}/cloud_init/{}".format(
-                    base_folder["folder"],
-                    base_folder["pkg-dir"],
-                    vdu["cloud-init-file"],
-                )
+                if base_folder["pkg-dir"]:
+                    cloud_init_file = "{}/{}/cloud_init/{}".format(
+                        base_folder["folder"],
+                        base_folder["pkg-dir"],
+                        vdu["cloud-init-file"],
+                    )
+                else:
+                    cloud_init_file = "{}/Scripts/cloud_init/{}".format(
+                        base_folder["folder"],
+                        vdu["cloud-init-file"],
+                    )
                 with self.fs.file_open(cloud_init_file, "r") as ci_file:
                     cloud_init_content = ci_file.read()
             elif vdu.get("cloud-init"):
@@ -1063,11 +1069,17 @@ class NsLcm(LcmBase):
                     # read file and put content at target.cloul_init_content. Avoid ng_ro to use shared package system
                     if vdur["cloud-init"] not in target["cloud_init_content"]:
                         base_folder = vnfd["_admin"]["storage"]
-                        cloud_init_file = "{}/{}/cloud_init/{}".format(
-                            base_folder["folder"],
-                            base_folder["pkg-dir"],
-                            vdud.get("cloud-init-file"),
-                        )
+                        if base_folder["pkg-dir"]:
+                            cloud_init_file = "{}/{}/cloud_init/{}".format(
+                                base_folder["folder"],
+                                base_folder["pkg-dir"],
+                                vdud.get("cloud-init-file"),
+                            )
+                        else:
+                            cloud_init_file = "{}/Scripts/cloud_init/{}".format(
+                                base_folder["folder"],
+                                vdud.get("cloud-init-file"),
+                            )
                         with self.fs.file_open(cloud_init_file, "r") as ci_file:
                             target["cloud_init_content"][
                                 vdur["cloud-init"]
@@ -1649,14 +1661,23 @@ class NsLcm(LcmBase):
                     osm_config["osm"]["kdu_name"] = kdu_name
 
             # Get artifact path
-            artifact_path = "{}/{}/{}/{}".format(
-                base_folder["folder"],
-                base_folder["pkg-dir"],
-                "charms"
-                if vca_type in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm")
-                else "helm-charts",
-                vca_name,
-            )
+            if base_folder["pkg-dir"]:
+                artifact_path = "{}/{}/{}/{}".format(
+                    base_folder["folder"],
+                    base_folder["pkg-dir"],
+                    "charms"
+                    if vca_type in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm")
+                    else "helm-charts",
+                    vca_name,
+                )
+            else:
+                artifact_path = "{}/Scripts/{}/{}/".format(
+                    base_folder["folder"],
+                    "charms"
+                    if vca_type in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm")
+                    else "helm-charts",
+                    vca_name,
+                )
 
             self.logger.debug("Artifact path > {}".format(artifact_path))
 
@@ -3257,16 +3278,21 @@ class NsLcm(LcmBase):
                             db_vnfds, lambda vnfd: vnfd["_id"] == vnfd_id
                         )
                         storage = deep_get(vnfd_with_id, ("_admin", "storage"))
-                        if storage and storage.get(
-                            "pkg-dir"
-                        ):  # may be not present if vnfd has not artifacts
+                        if storage:  # may be not present if vnfd has not artifacts
                             # path format: /vnfdid/pkkdir/helm-charts|juju-bundles/kdumodel
-                            filename = "{}/{}/{}s/{}".format(
-                                storage["folder"],
-                                storage["pkg-dir"],
-                                k8sclustertype,
-                                kdumodel,
-                            )
+                            if storage["pkg-dir"]:
+                                filename = "{}/{}/{}s/{}".format(
+                                    storage["folder"],
+                                    storage["pkg-dir"],
+                                    k8sclustertype,
+                                    kdumodel,
+                                )
+                            else:
+                                filename = "{}/Scripts/{}s/{}".format(
+                                    storage["folder"],
+                                    k8sclustertype,
+                                    kdumodel,
+                                )
                             if self.fs.file_exists(
                                 filename, mode="file"
                             ) or self.fs.file_exists(filename, mode="dir"):