X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=9800f9e5f934ddeb64995d1ac30d101c784ba095;hb=305b5c4df29e2fe284957ae5f160896b35d34bc9;hp=41926253dd454ded658de18045cfabf5b696bf7b;hpb=c41fe83a651559f7e85e959beaeff5ea0a1ceaaa;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 4192625..9800f9e 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -539,7 +539,7 @@ class NsLcm(LcmBase): vdur_copy = deepcopy(vdur) vdur_copy["status"] = "BUILD" vdur_copy["status-detailed"] = None - vdur_copy["ip-address"]: None + vdur_copy["ip-address"] = None vdur_copy["_id"] = str(uuid4()) vdur_copy["count-index"] += count + 1 vdur_copy["id"] = "{}-{}".format( @@ -822,6 +822,37 @@ class NsLcm(LcmBase): if vld_params.get("common_id"): target_vld["common_id"] = vld_params.get("common_id") + # modify target["ns"]["vld"] with instantiation parameters to override vnf vim-account + def update_ns_vld_target(target, ns_params): + for vnf_params in ns_params.get("vnf", ()): + if vnf_params.get("vimAccountId"): + target_vnf = next( + ( + vnfr + for vnfr in db_vnfrs.values() + if vnf_params["member-vnf-index"] + == vnfr["member-vnf-index-ref"] + ), + None, + ) + vdur = next((vdur for vdur in target_vnf.get("vdur", ())), None) + for a_index, a_vld in enumerate(target["ns"]["vld"]): + target_vld = find_in_list( + get_iterable(vdur, "interfaces"), + lambda iface: iface.get("ns-vld-id") == a_vld["name"], + ) + if target_vld: + if vnf_params.get("vimAccountId") not in a_vld.get( + "vim_info", {} + ): + target["ns"]["vld"][a_index].get("vim_info").update( + { + "vim:{}".format(vnf_params["vimAccountId"]): { + "vim_network_name": "" + } + } + ) + nslcmop_id = db_nslcmop["_id"] target = { "name": db_nsr["name"], @@ -836,6 +867,10 @@ class NsLcm(LcmBase): image["vim_info"] = {} for flavor in target["flavor"]: flavor["vim_info"] = {} + if db_nsr.get("affinity-or-anti-affinity-group"): + target["affinity-or-anti-affinity-group"] = deepcopy(db_nsr["affinity-or-anti-affinity-group"]) + for affinity_or_anti_affinity_group in target["affinity-or-anti-affinity-group"]: + affinity_or_anti_affinity_group["vim_info"] = {} if db_nslcmop.get("lcmOperationType") != "instantiate": # get parameters of instantiation: @@ -937,6 +972,8 @@ class NsLcm(LcmBase): vld_params.update(vld_instantiation_params) parse_vld_instantiation_params(target_vim, target_vld, vld_params, None) target["ns"]["vld"].append(target_vld) + # Update the target ns_vld if vnf vim_account is overriden by instantiation params + update_ns_vld_target(target, ns_params) for vnfr in db_vnfrs.values(): vnfd = find_in_list( @@ -1126,6 +1163,13 @@ class NsLcm(LcmBase): if target_vim not in ns_image["vim_info"]: ns_image["vim_info"][target_vim] = {} + # Affinity groups + if vdur.get("affinity-or-anti-affinity-group-id"): + for ags_id in vdur["affinity-or-anti-affinity-group-id"]: + ns_ags = target["affinity-or-anti-affinity-group"][int(ags_id)] + if target_vim not in ns_ags["vim_info"]: + ns_ags["vim_info"][target_vim] = {} + vdur["vim_info"] = {target_vim: {}} # instantiation parameters # if vnf_params: @@ -1665,7 +1709,8 @@ class NsLcm(LcmBase): base_folder["folder"], base_folder["pkg-dir"], "charms" - if vca_type in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm") + if vca_type + in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm") else "helm-charts", vca_name, ) @@ -1673,7 +1718,8 @@ class NsLcm(LcmBase): artifact_path = "{}/Scripts/{}/{}/".format( base_folder["folder"], "charms" - if vca_type in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm") + if vca_type + in ("native_charm", "lxc_proxy_charm", "k8s_proxy_charm") else "helm-charts", vca_name, ) @@ -2004,12 +2050,10 @@ class NsLcm(LcmBase): for job in prometheus_jobs: self.db.set_one( "prometheus_jobs", - { - "job_name": job["job_name"] - }, + {"job_name": job["job_name"]}, job, upsert=True, - fail_on_empty=False + fail_on_empty=False, ) step = "instantiated at VCA" @@ -2276,6 +2320,10 @@ class NsLcm(LcmBase): # read from db: operation stage[1] = "Getting nslcmop={} from db.".format(nslcmop_id) db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id}) + if db_nslcmop["operationParams"].get("additionalParamsForVnf"): + db_nslcmop["operationParams"]["additionalParamsForVnf"] = json.loads( + db_nslcmop["operationParams"]["additionalParamsForVnf"] + ) ns_params = db_nslcmop.get("operationParams") if ns_params and ns_params.get("timeout_ns_deploy"): timeout_ns_deploy = ns_params["timeout_ns_deploy"] @@ -2305,6 +2353,14 @@ class NsLcm(LcmBase): # for each vnf in ns, read vnfd for vnfr in db_vnfrs_list: + if vnfr.get("kdur"): + kdur_list = [] + for kdur in vnfr["kdur"]: + if kdur.get("additionalParams"): + kdur["additionalParams"] = json.loads(kdur["additionalParams"]) + kdur_list.append(kdur) + vnfr["kdur"] = kdur_list + db_vnfrs[vnfr["member-vnf-index-ref"]] = vnfr vnfd_id = vnfr["vnfd-id"] vnfd_ref = vnfr["vnfd-ref"] @@ -2772,7 +2828,9 @@ class NsLcm(LcmBase): if requirer_id != nsd["id"]: requirer_dict["vnf-profile-id"] = requirer_id else: - raise Exception("provider/requirer or entities must be included in the relation.") + raise Exception( + "provider/requirer or entities must be included in the relation." + ) relation_provider = self._update_ee_relation_data_with_implicit_data( nsr_id, nsd, provider_dict, cached_vnfds ) @@ -2824,7 +2882,9 @@ class NsLcm(LcmBase): if requirer_id != vnfd_id: requirer_dict["vdu-profile-id"] = requirer_id else: - raise Exception("provider/requirer or entities must be included in the relation.") + raise Exception( + "provider/requirer or entities must be included in the relation." + ) relation_provider = self._update_ee_relation_data_with_implicit_data( nsr_id, nsd, provider_dict, cached_vnfds, vnf_profile_id=vnf_profile_id ) @@ -4827,6 +4887,10 @@ class NsLcm(LcmBase): step = "Getting information from database" db_nslcmop = self.db.get_one("nslcmops", {"_id": nslcmop_id}) db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) + if db_nslcmop["operationParams"].get("primitive_params"): + db_nslcmop["operationParams"]["primitive_params"] = json.loads( + db_nslcmop["operationParams"]["primitive_params"] + ) nsr_deployed = db_nsr["_admin"].get("deployed") vnf_index = db_nslcmop["operationParams"].get("member_vnf_index") @@ -4844,6 +4908,13 @@ class NsLcm(LcmBase): db_vnfr = self.db.get_one( "vnfrs", {"member-vnf-index-ref": vnf_index, "nsr-id-ref": nsr_id} ) + if db_vnfr.get("kdur"): + kdur_list = [] + for kdur in db_vnfr["kdur"]: + if kdur.get("additionalParams"): + kdur["additionalParams"] = json.loads(kdur["additionalParams"]) + kdur_list.append(kdur) + db_vnfr["kdur"] = kdur_list step = "Getting vnfd from database" db_vnfd = self.db.get_one("vnfds", {"_id": db_vnfr["vnfd-id"]}) @@ -5714,7 +5785,7 @@ class NsLcm(LcmBase): ] = "Deleting the execution environments" scale_process = "VCA" for vca_info in vca_scaling_info: - if vca_info["type"] == "delete": + if vca_info["type"] == "delete" and not vca_info.get("osm_kdu_id"): member_vnf_index = str(vca_info["member-vnf-index"]) self.logger.debug( logging_text + "vdu info: {}".format(vca_info) @@ -5727,14 +5798,6 @@ class NsLcm(LcmBase): ] = "Scaling member_vnf_index={}, vdu_id={}, vdu_index={} ".format( member_vnf_index, vdu_id, vdu_index ) - else: - vdu_index = 0 - kdu_id = vca_info["osm_kdu_id"] - stage[ - 1 - ] = "Scaling member_vnf_index={}, kdu_id={}, vdu_index={} ".format( - member_vnf_index, kdu_id, vdu_index - ) stage[2] = step = "Scaling in VCA" self._write_op_status(op_id=nslcmop_id, stage=stage) vca_update = db_nsr["_admin"]["deployed"]["VCA"] @@ -5850,7 +5913,7 @@ class NsLcm(LcmBase): ] = "Creating new execution environments" scale_process = "VCA" for vca_info in vca_scaling_info: - if vca_info["type"] == "create": + if vca_info["type"] == "create" and not vca_info.get("osm_kdu_id"): member_vnf_index = str(vca_info["member-vnf-index"]) self.logger.debug( logging_text + "vdu info: {}".format(vca_info) @@ -5938,43 +6001,6 @@ class NsLcm(LcmBase): task_instantiation_info=tasks_dict_info, stage=stage, ) - else: - kdu_name = vca_info["osm_kdu_id"] - descriptor_config = get_configuration(db_vnfd, kdu_name) - if descriptor_config: - vdu_id = None - kdu_index = int(vca_info["kdu_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=kdu_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 @@ -6364,13 +6390,7 @@ class NsLcm(LcmBase): ) async def extract_prometheus_scrape_jobs( - self, - ee_id, - artifact_path, - ee_config_descriptor, - vnfr_id, - nsr_id, - target_ip + self, ee_id, artifact_path, ee_config_descriptor, vnfr_id, nsr_id, target_ip ): # look if exist a file called 'prometheus*.j2' and artifact_content = self.fs.dir_ls(artifact_path)