X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_lcm%2Fns.py;h=63a9b6721b9d64a814b85f6a88590be25bb2bf20;hb=0ceae9a95032d5d101c3eb19354733ab40c53200;hp=8f2b192a74cb1ef1c441a2ce00f1654e43e66de2;hpb=ceb0386270a13ab6b68c3549c01813eb41c178a5;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 8f2b192..63a9b67 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -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, @@ -2157,6 +2112,7 @@ class NsLcm(LcmBase): vnfr_id=vnfr_id, nsr_id=nsr_id, target_ip=rw_mgmt_ip, + element_type=element_type, vnf_member_index=db_vnfr.get("member-vnf-index-ref", ""), vdu_id=vdu_id, vdu_index=vdu_index, @@ -2297,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)) @@ -3187,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 @@ -3265,7 +3219,6 @@ class NsLcm(LcmBase): timeout: int = 600, vca_id: str = None, ): - try: k8sclustertype = k8s_instance_info["k8scluster-type"] # Instantiate kdu @@ -5057,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" @@ -5520,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) @@ -5584,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" @@ -5624,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 @@ -5661,7 +5612,6 @@ class NsLcm(LcmBase): step = "Getting descriptor config" if current_vnfd.get("kdu"): - search_key = "kdu_name" else: search_key = "vnfd_id" @@ -5682,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") @@ -5744,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 @@ -5786,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( @@ -7273,6 +7219,7 @@ class NsLcm(LcmBase): vnfr_id: str, nsr_id: str, target_ip: str, + element_type: str, vnf_member_index: str = "", vdu_id: str = "", vdu_index: int = None, @@ -7289,6 +7236,7 @@ class NsLcm(LcmBase): vnfr_id (str): VNFR ID where this EE applies nsr_id (str): NSR ID where this EE applies target_ip (str): VDU/KDU instance IP address + element_type (str): NS or VNF or VDU or KDU vnf_member_index (str, optional): VNF index where this EE applies. Defaults to "". vdu_id (str, optional): VDU ID where this EE applies. Defaults to "". vdu_index (int, optional): VDU index where this EE applies. Defaults to None. @@ -7301,7 +7249,11 @@ class NsLcm(LcmBase): Returns: _type_: Prometheus jobs """ - self.logger.debug(f"KDU: {kdu_name}; KDU INDEX: {kdu_index}") + # default the vdur and kdur names to an empty string, to avoid any later + # problem with Prometheus when the element type is not VDU or KDU + vdur_name = "" + kdur_name = "" + # look if exist a file called 'prometheus*.j2' and artifact_content = self.fs.dir_ls(artifact_path) job_file = next( @@ -7317,51 +7269,51 @@ class NsLcm(LcmBase): with self.fs.file_open((artifact_path, job_file), "r") as f: job_data = f.read() - vdur_name = "" - kdur_name = "" - for r in range(360): - db_vnfr = self.db.get_one("vnfrs", {"_id": vnfr_id}) - if vdu_id and vdu_index is not None: - vdur = next( - ( - x - for x in get_iterable(db_vnfr, "vdur") - if ( - x.get("vdu-id-ref") == vdu_id - and x.get("count-index") == vdu_index - ) - ), - {}, - ) - if vdur.get("name"): - vdur_name = vdur.get("name") - break - if kdu_name and kdu_index is not None: - kdur = next( - ( - x - for x in get_iterable(db_vnfr, "kdur") - if ( - x.get("kdu-name") == kdu_name - and x.get("count-index") == kdu_index - ) - ), - {}, - ) - if kdur.get("name"): - kdur_name = kdur.get("name") - break + # obtain the VDUR or KDUR, if the element type is VDU or KDU + if element_type in ("VDU", "KDU"): + for _ in range(360): + db_vnfr = self.db.get_one("vnfrs", {"_id": vnfr_id}) + if vdu_id and vdu_index is not None: + vdur = next( + ( + x + for x in get_iterable(db_vnfr, "vdur") + if ( + x.get("vdu-id-ref") == vdu_id + and x.get("count-index") == vdu_index + ) + ), + {}, + ) + if vdur.get("name"): + vdur_name = vdur.get("name") + break + if kdu_name and kdu_index is not None: + kdur = next( + ( + x + for x in get_iterable(db_vnfr, "kdur") + if ( + x.get("kdu-name") == kdu_name + and x.get("count-index") == kdu_index + ) + ), + {}, + ) + if kdur.get("name"): + kdur_name = kdur.get("name") + break - await asyncio.sleep(10, loop=self.loop) - else: - if vdu_id and vdu_index is not None: - raise LcmException( - f"Timeout waiting VDU with name={vdu_id} and index={vdu_index} to be intantiated" - ) - if kdu_name and kdu_index is not None: - raise LcmException( - f"Timeout waiting KDU with name={kdu_name} and index={kdu_index} to be intantiated" - ) + await asyncio.sleep(10, loop=self.loop) + else: + if vdu_id and vdu_index is not None: + raise LcmException( + f"Timeout waiting VDU with name={vdu_id} and index={vdu_index} to be intantiated" + ) + if kdu_name and kdu_index is not None: + raise LcmException( + f"Timeout waiting KDU with name={kdu_name} and index={kdu_index} to be intantiated" + ) # TODO get_service _, _, service = ee_id.partition(".") # remove prefix "namespace." @@ -7377,6 +7329,7 @@ class NsLcm(LcmBase): "VNF_MEMBER_INDEX": vnf_member_index, "VDUR_NAME": vdur_name, "KDUR_NAME": kdur_name, + "ELEMENT_TYPE": element_type, } job_list = parse_job(job_data, variables) # ensure job_name is using the vnfr_id. Adding the metadata nsr_id @@ -8169,7 +8122,6 @@ class NsLcm(LcmBase): } step = "" try: - element_type = "NS" element_under_configuration = nsr_id