Bug 2236 - Upgrade of Helm Charts is failing when the Helm Chart is embeded in the...
[osm/LCM.git] / osm_lcm / ns.py
index 73bea40..63a9b67 100644 (file)
@@ -61,6 +61,7 @@ from osm_lcm.lcm_utils import (
     check_juju_bundle_existence,
     get_charm_artifact_path,
     get_ee_id_parts,
+    vld_to_ro_ip_profile,
 )
 from osm_lcm.data_utils.nsd import (
     get_ns_configuration_relation_list,
@@ -245,7 +246,6 @@ class NsLcm(LcmBase):
         return None
 
     def _on_update_ro_db(self, nsrs_id, ro_descriptor):
-
         # self.logger.debug('_on_update_ro_db(nsrs_id={}'.format(nsrs_id))
 
         try:
@@ -263,7 +263,6 @@ class NsLcm(LcmBase):
             )
 
     async def _on_update_n2vc_db(self, table, filter, path, updated_data, vca_id=None):
-
         # remove last dot from path (if exists)
         if path.endswith("."):
             path = path[:-1]
@@ -271,7 +270,6 @@ class NsLcm(LcmBase):
         # self.logger.debug('_on_update_n2vc_db(table={}, filter={}, path={}, updated_data={}'
         #                   .format(table, filter, path, updated_data))
         try:
-
             nsr_id = filter.get("_id")
 
             # read ns record from database
@@ -532,7 +530,6 @@ class NsLcm(LcmBase):
             return wim_account
 
     def scale_vnfr(self, db_vnfr, vdu_create=None, vdu_delete=None, mark_delete=False):
-
         db_vdu_push_list = []
         template_vdur = []
         db_update = {"_admin.modified": time()}
@@ -820,7 +817,6 @@ class NsLcm(LcmBase):
         start_deploy,
         timeout_ns_deploy,
     ):
-
         db_vims = {}
 
         def get_vim_account(vim_account_id):
@@ -836,9 +832,9 @@ class NsLcm(LcmBase):
             target_vim, target_vld, vld_params, target_sdn
         ):
             if vld_params.get("ip-profile"):
-                target_vld["vim_info"][target_vim]["ip_profile"] = vld_params[
-                    "ip-profile"
-                ]
+                target_vld["vim_info"][target_vim]["ip_profile"] = vld_to_ro_ip_profile(
+                    vld_params["ip-profile"]
+                )
             if vld_params.get("provider-network"):
                 target_vld["vim_info"][target_vim]["provider_network"] = vld_params[
                     "provider-network"
@@ -915,7 +911,6 @@ class NsLcm(LcmBase):
                             lambda v_vld: v_vld["name"] in (a_vld["name"], a_vld["id"]),
                         )
                         if target_vld:
-
                             if vnf_params.get("vimAccountId") not in a_vld.get(
                                 "vim_info", {}
                             ):
@@ -1050,27 +1045,9 @@ class NsLcm(LcmBase):
                 and nsd_vlp.get("virtual-link-protocol-data")
                 and nsd_vlp["virtual-link-protocol-data"].get("l3-protocol-data")
             ):
-                ip_profile_source_data = nsd_vlp["virtual-link-protocol-data"][
+                vld_params["ip-profile"] = nsd_vlp["virtual-link-protocol-data"][
                     "l3-protocol-data"
                 ]
-                ip_profile_dest_data = {}
-                if "ip-version" in ip_profile_source_data:
-                    ip_profile_dest_data["ip-version"] = ip_profile_source_data[
-                        "ip-version"
-                    ]
-                if "cidr" in ip_profile_source_data:
-                    ip_profile_dest_data["subnet-address"] = ip_profile_source_data[
-                        "cidr"
-                    ]
-                if "gateway-ip" in ip_profile_source_data:
-                    ip_profile_dest_data["gateway-address"] = ip_profile_source_data[
-                        "gateway-ip"
-                    ]
-                if "dhcp-enabled" in ip_profile_source_data:
-                    ip_profile_dest_data["dhcp-params"] = {
-                        "enabled": ip_profile_source_data["dhcp-enabled"]
-                    }
-                vld_params["ip-profile"] = ip_profile_dest_data
 
             # update vld_params with instantiation params
             vld_instantiation_params = find_in_list(
@@ -1136,28 +1113,9 @@ class NsLcm(LcmBase):
                     and vnfd_vlp.get("virtual-link-protocol-data")
                     and vnfd_vlp["virtual-link-protocol-data"].get("l3-protocol-data")
                 ):
-                    ip_profile_source_data = vnfd_vlp["virtual-link-protocol-data"][
+                    vld_params["ip-profile"] = vnfd_vlp["virtual-link-protocol-data"][
                         "l3-protocol-data"
                     ]
-                    ip_profile_dest_data = {}
-                    if "ip-version" in ip_profile_source_data:
-                        ip_profile_dest_data["ip-version"] = ip_profile_source_data[
-                            "ip-version"
-                        ]
-                    if "cidr" in ip_profile_source_data:
-                        ip_profile_dest_data["subnet-address"] = ip_profile_source_data[
-                            "cidr"
-                        ]
-                    if "gateway-ip" in ip_profile_source_data:
-                        ip_profile_dest_data[
-                            "gateway-address"
-                        ] = ip_profile_source_data["gateway-ip"]
-                    if "dhcp-enabled" in ip_profile_source_data:
-                        ip_profile_dest_data["dhcp-params"] = {
-                            "enabled": ip_profile_source_data["dhcp-enabled"]
-                        }
-
-                    vld_params["ip-profile"] = ip_profile_dest_data
                 # update vld_params with instantiation params
                 if vnf_params:
                     vld_instantiation_params = find_in_list(
@@ -1568,7 +1526,6 @@ class NsLcm(LcmBase):
         ro_retries = 0
 
         while True:
-
             ro_retries += 1
             if ro_retries >= 360:  # 1 hour
                 raise LcmException(
@@ -1753,7 +1710,6 @@ class NsLcm(LcmBase):
         }
         step = ""
         try:
-
             element_type = "NS"
             element_under_configuration = nsr_id
 
@@ -1837,7 +1793,6 @@ class NsLcm(LcmBase):
             vca_id = self.get_vca_id(db_vnfr, db_nsr)
             # create or register execution environment in VCA
             if vca_type in ("lxc_proxy_charm", "k8s_proxy_charm", "helm", "helm-v3"):
-
                 self._write_configuration_status(
                     nsr_id=nsr_id,
                     vca_index=vca_index,
@@ -2298,7 +2253,6 @@ class NsLcm(LcmBase):
         element_type: str = None,
         other_update: dict = None,
     ):
-
         # self.logger.debug('_write_configuration_status(): vca_index={}, status={}'
         #                   .format(vca_index, status))
 
@@ -3188,7 +3142,6 @@ class NsLcm(LcmBase):
         vca_index: int,
         timeout: int = 3600,
     ) -> bool:
-
         # steps:
         # 1. find all relations for this VCA
         # 2. wait for other peers related
@@ -3266,7 +3219,6 @@ class NsLcm(LcmBase):
         timeout: int = 600,
         vca_id: str = None,
     ):
-
         try:
             k8sclustertype = k8s_instance_info["k8scluster-type"]
             # Instantiate kdu
@@ -5058,9 +5010,10 @@ class NsLcm(LcmBase):
                         del desc_params["kdu_model"]
                     else:
                         kdu_model = kdu.get("kdu-model")
-                        parts = kdu_model.split(sep=":")
-                        if len(parts) == 2:
-                            kdu_model = parts[0]
+                        if kdu_model.count("/") < 2:  # helm chart is not embedded
+                            parts = kdu_model.split(sep=":")
+                            if len(parts) == 2:
+                                kdu_model = parts[0]
                     if desc_params.get("kdu_atomic_upgrade"):
                         atomic_upgrade = desc_params.get(
                             "kdu_atomic_upgrade"
@@ -5521,7 +5474,6 @@ class NsLcm(LcmBase):
             raise
 
         except Exception as e:
-
             self.logger.debug("Error upgrading charm {}".format(path))
 
             return "FAILED", "Error upgrading charm {}: {}".format(path, e)
@@ -5585,7 +5537,6 @@ class NsLcm(LcmBase):
             nsr_deployed = db_nsr["_admin"].get("deployed")
 
             if update_type == "CHANGE_VNFPKG":
-
                 # Get the input parameters given through update request
                 vnf_instance_id = db_nslcmop["operationParams"][
                     "changeVnfPackageData"
@@ -5625,7 +5576,6 @@ class NsLcm(LcmBase):
 
                 step = "Checking if revision has changed in VNFD"
                 if current_vnf_revision != latest_vnfd_revision:
-
                     change_type = "policy_updated"
 
                     # There is new revision of VNFD, update operation is required
@@ -5662,7 +5612,6 @@ class NsLcm(LcmBase):
 
                             step = "Getting descriptor config"
                             if current_vnfd.get("kdu"):
-
                                 search_key = "kdu_name"
                             else:
                                 search_key = "vnfd_id"
@@ -5683,7 +5632,6 @@ class NsLcm(LcmBase):
                             # There could be several charm used in the same VNF
                             for ee_item in ee_list:
                                 if ee_item.get("juju"):
-
                                     step = "Getting charm name"
                                     charm_name = ee_item["juju"].get("charm")
 
@@ -5745,7 +5693,6 @@ class NsLcm(LcmBase):
                     if find_software_version(current_vnfd) != find_software_version(
                         latest_vnfd
                     ):
-
                         step = "Checking if existing VNF has charm"
                         for current_charm_path, target_charm_path in list(
                             charm_artifact_paths
@@ -5787,10 +5734,8 @@ class NsLcm(LcmBase):
                                     current_charm_path, target_charm_path
                                 )
                             ):
-
                                 step = "Checking whether VNF uses juju bundle"
                                 if check_juju_bundle_existence(current_vnfd):
-
                                     raise LcmException(
                                         "Charm upgrade is not supported for the instance which"
                                         " uses juju-bundle: {}".format(
@@ -8177,7 +8122,6 @@ class NsLcm(LcmBase):
         }
         step = ""
         try:
-
             element_type = "NS"
             element_under_configuration = nsr_id