X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=9800f9e5f934ddeb64995d1ac30d101c784ba095;hb=305b5c4df29e2fe284957ae5f160896b35d34bc9;hp=e530b8cef7eeccdb254a0998c5c609e380a19f28;hpb=48aee4c70ca4dfed6dd9af32cbf7f2bf542bb4c4;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index e530b8c..9800f9e 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -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" @@ -2784,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 ) @@ -2836,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 ) @@ -5737,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) @@ -5750,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"] @@ -5873,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) @@ -5961,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 @@ -6387,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)