X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fdata_utils%2Fvnfd.py;h=ffcb58278004ca119892d1303b7b0a550316d7da;hb=dffa6217777142746ed9b5c9a7eaab7c0d8716be;hp=5351c41172c609319b3ce9229cdf4d9fcb8650cf;hpb=5697b8b03a3acd17827ce536cb8aff15df8776ad;p=osm%2FLCM.git diff --git a/osm_lcm/data_utils/vnfd.py b/osm_lcm/data_utils/vnfd.py index 5351c41..ffcb582 100644 --- a/osm_lcm/data_utils/vnfd.py +++ b/osm_lcm/data_utils/vnfd.py @@ -37,6 +37,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 ): @@ -101,6 +111,13 @@ def get_vdu_profile(vnfd, vdu_profile_id): ) +def get_kdu_resource_profile(vnfd, kdu_profile_id): + return list_utils.find_in_list( + vnfd.get("df", ())[0]["kdu-resource-profile"], + lambda kdu_profile: kdu_profile["id"] == kdu_profile_id, + ) + + def get_configuration(vnfd, entity_id): lcm_ops_config = vnfd.get("df")[0].get("lcm-operations-configuration") if not lcm_ops_config: @@ -114,6 +131,10 @@ def get_configuration(vnfd, entity_id): ) +def get_relation_list(vnfd, entity_id): + return (get_configuration(vnfd, entity_id) or {}).get("relation", []) + + def get_virtual_link_profiles(vnfd): return vnfd.get("df")[0].get("virtual-link-profile", ()) @@ -148,3 +169,25 @@ 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