fix/feat(relations): external connection point ref now works with multiple KDU
[osm/LCM.git] / osm_lcm / ns.py
index 0f5c6ab..443a09e 100644 (file)
@@ -2110,8 +2110,11 @@ class NsLcm(LcmBase):
             db_vnfd_list = db_nsr.get('vnfd-id')
             if db_vnfd_list:
                 for vnfd in db_vnfd_list:
+                    db_vnf_relations = None
                     db_vnfd = self.db.get_one("vnfds", {"_id": vnfd})
-                    db_vnf_relations = get_configuration(db_vnfd, db_vnfd["id"]).get("relation", [])
+                    db_vnf_configuration = get_configuration(db_vnfd, db_vnfd["id"])
+                    if db_vnf_configuration:
+                        db_vnf_relations = db_vnf_configuration.get("relation", [])
                     if db_vnf_relations:
                         for r in db_vnf_relations:
                             # check if this VCA is in the relation
@@ -2284,6 +2287,12 @@ class NsLcm(LcmBase):
 
             # Obtain management service info (if exists)
             vnfr_update_dict = {}
+            kdu_config = get_configuration(vnfd, kdud["name"])
+            if kdu_config:
+                target_ee_list = kdu_config.get("execution-environment-list", [])
+            else:
+                target_ee_list = []
+
             if services:
                 vnfr_update_dict["kdur.{}.services".format(kdu_index)] = services
                 mgmt_services = [service for service in kdud.get("service", []) if service.get("mgmt-service")]
@@ -2303,6 +2312,11 @@ class NsLcm(LcmBase):
                                 if deep_get(vnfd, ("mgmt-interface", "cp")) == service_external_cp:
                                     vnfr_update_dict["ip-address"] = ip
 
+                                if find_in_list(
+                                    target_ee_list,
+                                    lambda ee: ee.get("external-connection-point-ref", "") == service_external_cp
+                                ):
+                                    vnfr_update_dict["kdur.{}.ip-address".format(kdu_index)] = ip
                             break
                     else:
                         self.logger.warn("Mgmt service name: {} not found".format(mgmt_service["name"]))
@@ -4126,8 +4140,6 @@ class NsLcm(LcmBase):
                                         timeout=self.timeout_charm_delete
                                     )
                                 )
-                                # wait before next removal
-                                await asyncio.sleep(30)
                                 tasks_dict_info[task] = "Terminating VCA {}".format(vca.get("ee_id"))
                                 del vca_update[vca_index]
                                 del config_update[vca_index]
@@ -4240,37 +4252,6 @@ class NsLcm(LcmBase):
                                 task_instantiation_info=tasks_dict_info,
                                 stage=stage
                             )
-                        # TODO: scaling for kdu is not implemented yet.
-                        kdu_name = vdu_info["osm_vdu_id"]
-                        descriptor_config = get_configuration(db_vnfd, kdu_name)
-                        if descriptor_config:
-                            vdu_id = None
-                            vdu_index = vdu_index
-                            vdu_name = None
-                            kdur = next(x for x in db_vnfr["kdur"] if x["kdu-name"] == kdu_name)
-                            deploy_params_kdu = {"OSM": get_osm_params(db_vnfr)}
-                            if kdur.get("additionalParams"):
-                                deploy_params_kdu = parse_yaml_strings(kdur["additionalParams"])
-
-                            self._deploy_n2vc(
-                                logging_text=logging_text,
-                                db_nsr=db_nsr,
-                                db_vnfr=db_vnfr,
-                                nslcmop_id=nslcmop_id,
-                                nsr_id=nsr_id,
-                                nsi_id=nsi_id,
-                                vnfd_id=vnfd_id,
-                                vdu_id=vdu_id,
-                                kdu_name=kdu_name,
-                                member_vnf_index=member_vnf_index,
-                                vdu_index=vdu_index,
-                                vdu_name=vdu_name,
-                                deploy_params=deploy_params_kdu,
-                                descriptor_config=descriptor_config,
-                                base_folder=base_folder,
-                                task_instantiation_info=tasks_dict_info,
-                                stage=stage
-                            )
             # SCALE-UP VCA - END
             scale_process = None