Revert "Revert "Remove unused methods""
[osm/LCM.git] / osm_lcm / data_utils / vnfd.py
index 714487c..954a84c 100644 (file)
 from osm_lcm.data_utils import list_utils
 
 
-def get_lcm_operations_configuration(vnfd):
-    return vnfd.get("df", ())[0].get("lcm-operations-configuration", ())
-
-
 def get_vdu_list(vnfd):
     return vnfd.get("vdu", ())
 
@@ -37,6 +33,16 @@ def get_kdu_list(vnfd):
     return vnfd.get("kdu", ())
 
 
+def get_kdu(vnfd, kdu_name):
+    return list_utils.find_in_list(
+        get_kdu_list(vnfd), lambda kdu: kdu["name"] == kdu_name
+    )
+
+
+def get_kdu_services(kdu):
+    return kdu.get("service", [])
+
+
 def get_ee_sorted_initial_config_primitive_list(
     primitive_list, vca_deployed, ee_descriptor_id
 ):
@@ -159,3 +165,37 @@ def get_juju_ee_ref(vnfd, entity_id):
         get_configuration(vnfd, entity_id).get("execution-environment-list", []),
         lambda ee: "juju" in ee,
     )
+
+
+def find_software_version(vnfd: dict) -> str:
+    """Find the sotware version in the VNFD descriptors
+
+    Args:
+        vnfd (dict): Descriptor as a dictionary
+
+    Returns:
+        software-version (str)
+    """
+
+    default_sw_version = "1.0"
+
+    if vnfd.get("vnfd"):
+        vnfd = vnfd["vnfd"]
+
+    if vnfd.get("software-version"):
+        return vnfd["software-version"]
+
+    else:
+        return default_sw_version
+
+
+def check_helm_ee_in_ns(db_vnfds: list) -> bool:
+    for vnfd in db_vnfds:
+        descriptor_config = get_configuration(vnfd, vnfd["id"])
+        if not (
+            descriptor_config and "execution-environment-list" in descriptor_config
+        ):
+            continue
+        ee_list = descriptor_config.get("execution-environment-list", [])
+        if list_utils.find_in_list(ee_list, lambda ee_item: "helm-chart" in ee_item):
+            return True