X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=f1c3fa1ffe37f8b19f5ad92eb325a0da9590cf06;hb=refs%2Fchanges%2F53%2F10953%2F1;hp=ca856614f4c6ea3d15372bcc17a30e934851a70e;hpb=536c908065565674fdb5f0e5d4b0c8e66cb4af9a;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index ca85661..f1c3fa1 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -664,12 +664,25 @@ class NsLcm(LcmBase): # check at nsd descriptor, if there is an ip-profile vld_params = {} - virtual_link_profiles = get_virtual_link_profiles(nsd) + nsd_vlp = find_in_list( + get_virtual_link_profiles(nsd), + lambda a_link_profile: a_link_profile["virtual-link-desc-id"] == vld["id"]) + if nsd_vlp 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"]["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 - for vlp in virtual_link_profiles: - ip_profile = find_in_list(nsd["ip-profiles"], - lambda profile: profile["name"] == vlp["ip-profile-ref"]) - vld_params["ip-profile"] = ip_profile["ip-profile-params"] # update vld_params with instantiation params vld_instantiation_params = find_in_list(get_iterable(ns_params, "vld"), lambda a_vld: a_vld["name"] in (vld["name"], vld["id"])) @@ -1644,9 +1657,6 @@ class NsLcm(LcmBase): # wait for any previous tasks in process await self.lcm_tasks.waitfor_related_HA('ns', 'nslcmops', nslcmop_id) - stage[1] = "Sync filesystem from database." - self.fs.sync() # TODO, make use of partial sync, only for the needed packages - # STEP 0: Reading database (nslcmops, nsrs, nsds, vnfrs, vnfds) stage[1] = "Reading from database." # nsState="BUILDING", currentOperation="INSTANTIATING", currentOperationID=nslcmop_id @@ -1679,6 +1689,7 @@ class NsLcm(LcmBase): db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) stage[1] = "Getting nsd={} from db.".format(db_nsr["nsd-id"]) nsd = self.db.get_one("nsds", {"_id": db_nsr["nsd-id"]}) + self.fs.sync(db_nsr["nsd-id"]) db_nsr["nsd"] = nsd # nsr_name = db_nsr["name"] # TODO short-name?? @@ -1695,6 +1706,7 @@ class NsLcm(LcmBase): db_vnfrs[vnfr["member-vnf-index-ref"]] = vnfr vnfd_id = vnfr["vnfd-id"] vnfd_ref = vnfr["vnfd-ref"] + self.fs.sync(vnfd_id) # if we haven't this vnfd, read it from db if vnfd_id not in db_vnfds: @@ -2051,8 +2063,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 @@ -2192,11 +2207,14 @@ class NsLcm(LcmBase): "filter": {"_id": nsr_id}, "path": nsr_db_path} - kdu_instance = self.k8scluster_map[k8sclustertype].generate_kdu_instance_name( - db_dict=db_dict_install, - kdu_model=k8s_instance_info["kdu-model"], - kdu_name=k8s_instance_info["kdu-name"], - ) + if k8s_instance_info.get("kdu-deployment-name"): + kdu_instance = k8s_instance_info.get("kdu-deployment-name") + else: + kdu_instance = self.k8scluster_map[k8sclustertype].generate_kdu_instance_name( + db_dict=db_dict_install, + kdu_model=k8s_instance_info["kdu-model"], + kdu_name=k8s_instance_info["kdu-name"], + ) self.update_db_2("nsrs", nsr_id, {nsr_db_path + ".kdu-instance": kdu_instance}) await self.k8scluster_map[k8sclustertype].install( cluster_uuid=k8s_instance_info["k8scluster-uuid"], @@ -2219,6 +2237,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")] @@ -2238,6 +2262,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"])) @@ -2338,6 +2367,7 @@ class NsLcm(LcmBase): vnfd_with_id = find_in_list(db_vnfds, lambda vnfd: vnfd["_id"] == vnfd_id) kdud = next(kdud for kdud in vnfd_with_id["kdu"] if kdud["name"] == kdur["kdu-name"]) namespace = kdur.get("k8s-namespace") + kdu_deployment_name = kdur.get("kdu-deployment-name") if kdur.get("helm-chart"): kdumodel = kdur["helm-chart"] # Default version: helm3, if helm-version is v2 assign v2 @@ -2401,7 +2431,8 @@ class NsLcm(LcmBase): "member-vnf-index": vnfr_data["member-vnf-index-ref"], "kdu-name": kdur["kdu-name"], "kdu-model": kdumodel, - "namespace": namespace} + "namespace": namespace, + "kdu-deployment-name": kdu_deployment_name} db_path = "_admin.deployed.K8s.{}".format(index) db_nsr_update[db_path] = k8s_instance_info self.update_db_2("nsrs", nsr_id, db_nsr_update) @@ -2438,6 +2469,8 @@ class NsLcm(LcmBase): self.logger.debug(logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)) if "execution-environment-list" in descriptor_config: ee_list = descriptor_config.get("execution-environment-list", []) + elif "juju" in descriptor_config: + ee_list = [descriptor_config] # ns charms else: # other types as script are not supported ee_list = [] @@ -3864,7 +3897,7 @@ class NsLcm(LcmBase): # Pre-scale retry check: Check if this sub-operation has been executed before op_index = self._check_or_add_scale_suboperation( - db_nslcmop, nslcmop_id, vnf_index, vnf_config_primitive, primitive_params, 'PRE-SCALE') + db_nslcmop, vnf_index, vnf_config_primitive, primitive_params, 'PRE-SCALE') if op_index == self.SUBOPERATION_STATUS_SKIP: # Skip sub-operation result = 'COMPLETED' @@ -3896,7 +3929,7 @@ class NsLcm(LcmBase): vdu_count_index=None, ee_descriptor_id=ee_descriptor_id) result, result_detail = await self._ns_execute_primitive( - ee_id, primitive_name, primitive_params, vca_type) + ee_id, primitive_name, primitive_params, vca_type=vca_type) self.logger.debug(logging_text + "vnf_config_primitive={} Done with result {} {}".format( vnf_config_primitive, result, result_detail)) # Update operationState = COMPLETED | FAILED @@ -4129,7 +4162,7 @@ class NsLcm(LcmBase): # Post-scale retry check: Check if this sub-operation has been executed before op_index = self._check_or_add_scale_suboperation( - db_nslcmop, nslcmop_id, vnf_index, vnf_config_primitive, primitive_params, 'POST-SCALE') + db_nslcmop, vnf_index, vnf_config_primitive, primitive_params, 'POST-SCALE') if op_index == self.SUBOPERATION_STATUS_SKIP: # Skip sub-operation result = 'COMPLETED' @@ -4161,7 +4194,7 @@ class NsLcm(LcmBase): vdu_count_index=None, ee_descriptor_id=ee_descriptor_id) result, result_detail = await self._ns_execute_primitive( - ee_id, primitive_name, primitive_params, vca_type) + ee_id, primitive_name, primitive_params, vca_type=vca_type) self.logger.debug(logging_text + "vnf_config_primitive={} Done with result {} {}".format( vnf_config_primitive, result, result_detail)) # Update operationState = COMPLETED | FAILED