X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fdata_utils%2Fnsd.py;h=d436e1f525fb708e0733503eb21c338b9ec6e474;hb=7f26b3f6740e12dd35d8024b14c3fe3a32ec5dbf;hp=2917c04be8d911faa218a04340776a6b19a5887b;hpb=922c41753ffbb4b526f2135a23c39f480c58e2cb;p=osm%2FLCM.git diff --git a/osm_lcm/data_utils/nsd.py b/osm_lcm/data_utils/nsd.py index 2917c04..d436e1f 100644 --- a/osm_lcm/data_utils/nsd.py +++ b/osm_lcm/data_utils/nsd.py @@ -21,18 +21,28 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact: fbravo@whitestack.com ## -import ast + +from osm_lcm.data_utils.list_utils import find_in_list def get_vnf_profiles(nsd): return nsd.get("df")[0].get("vnf-profile", ()) +def get_vnf_profile(nsd, vnf_profile_id): + return find_in_list( + get_vnf_profiles(nsd), + lambda vnf_profile: vnf_profile["id"] == vnf_profile_id, + ) + + def get_virtual_link_profiles(nsd): return nsd.get("df")[0].get("virtual-link-profile", ()) -def replace_vnf_id(nsd, old_vnf_id, new_vnf_id): - dict_str = str(nsd) - dict_str.replace(old_vnf_id, new_vnf_id) - return ast.literal_eval(dict_str) +def get_ns_configuration(nsd): + return nsd.get("ns-configuration", {}) + + +def get_ns_configuration_relation_list(nsd): + return get_ns_configuration(nsd).get("relation", [])