From: yshah Date: Thu, 19 Dec 2024 11:06:24 +0000 (+0000) Subject: Update sw_catalog_path for KSU create and update to be relevant to profile_type X-Git-Tag: v17.0.0~5 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=2f39b8a4f0b38541b63e288a4517e82997003bd8;p=osm%2FLCM.git Update sw_catalog_path for KSU create and update to be relevant to profile_type Change-Id: I4f61c03d9c768d8ad8dd6d33c44608aa33823ca4 Signed-off-by: yshah --- diff --git a/osm_lcm/k8s.py b/osm_lcm/k8s.py index 0c445f05..70dee64d 100644 --- a/osm_lcm/k8s.py +++ b/osm_lcm/k8s.py @@ -28,6 +28,13 @@ from osm_lcm import odu_workflows from osm_lcm import vim_sdn from osm_lcm.data_utils.list_utils import find_in_list +MAP_PROFILE = { + "infra_controller_profiles": "infra-controllers", + "infra_config_profiles": "infra-configs", + "resource_profiles": "managed_resources", + "app_profiles": "apps", +} + class GitOpsLcm(LcmBase): db_collection = "gitops" @@ -41,13 +48,6 @@ class GitOpsLcm(LcmBase): "app_profiles": "k8sapp", } - profile_collection_mapping = { - "infra_controller_profiles": "k8sinfra_controller", - "infra_config_profiles": "k8sinfra_config", - "resource_profiles": "k8sresource", - "app_profiles": "k8sapp", - } - def __init__(self, msg, lcm_tasks, config): self.logger = logging.getLogger("lcm.gitops") self.lcm_tasks = lcm_tasks @@ -1618,12 +1618,6 @@ class OkaLcm(GitOpsLcm): class KsuLcm(GitOpsLcm): db_collection = "ksus" - profile_collection_mapping = { - "infra_controller_profiles": "k8sinfra_controller", - "infra_config_profiles": "k8sinfra_config", - "resource_profiles": "k8sresource", - "app_profiles": "k8sapp", - } def __init__(self, msg, lcm_tasks, config): """ @@ -1659,7 +1653,10 @@ class KsuLcm(GitOpsLcm): if "sw_catalog_path" not in oka: oka_id = oka["_id"] db_oka = self.db.get_one("okas", {"_id": oka_id}) - oka["sw_catalog_path"] = f"infra-controllers/{db_oka['git_name']}" + oka_type = MAP_PROFILE[ + db_oka.get("profile_type", "infra_controller_profiles") + ] + oka["sw_catalog_path"] = f"{oka_type}/{db_oka['git_name']}" op_params.append(ksu_params) _, workflow_name = await self.odu.launch_workflow( @@ -1708,7 +1705,10 @@ class KsuLcm(GitOpsLcm): if "sw_catalog_path" not in oka: oka_id = oka["_id"] db_oka = self.db.get_one("okas", {"_id": oka_id}) - oka["sw_catalog_path"] = f"infra-controllers/{db_oka['git_name']}" + oka_type = MAP_PROFILE[ + db_oka.get("profile_type", "infra_controller_profiles") + ] + oka["sw_catalog_path"] = f"{oka_type}/{db_oka['git_name']}" op_params.append(ksu_params) _, workflow_name = await self.odu.launch_workflow(