##
from osm_lcm.data_utils import list_utils
-from osm_lcm.lcm_utils import get_iterable
def get_lcm_operations_configuration(vnfd):
lambda vdu_profile: vdu_profile["id"] == vdu_profile_id)
-def get_vnf_configuration(vnfd):
- if "vnf-configuration-id" not in vnfd.get("df")[0]:
+def get_configuration(vnfd, entity_id):
+ lcm_ops_config = vnfd.get("df")[0].get("lcm-operations-configuration")
+ if not lcm_ops_config:
return None
- vnf_config_id = vnfd.get("df")[0]["vnf-configuration-id"]
- return list_utils.find_in_list(
- vnfd.get("vnf-configuration", {}),
- lambda vnf_config: vnf_config["id"] == vnf_config_id)
-
-
-def get_vdu_configuration(vnfd, vdu_id):
- vdu_profile = get_vdu_profile(vnfd, vdu_id)
- return list_utils.find_in_list(
- vnfd.get("vdu-configuration", ()),
- lambda vdu_configuration: vdu_configuration["id"] == vdu_profile["vdu-configuration-id"])
-
-
-def get_kdu_configuration(vnfd, kdu_name):
- for kdu in get_iterable(vnfd, "kdu"):
- if kdu_name == kdu["name"]:
- return kdu.get("kdu-configuration")
+ ops_vnf = lcm_ops_config.get("operate-vnf-op-config")
+ if not ops_vnf:
+ return None
+ day12ops = ops_vnf.get("day1-2", [])
+ list_utils.find_in_list(
+ day12ops,
+ lambda configuration: configuration["id"] == entity_id)
def get_virtual_link_profiles(vnfd):
from osm_lcm.ng_ro import NgRoClient, NgRoException
from osm_lcm.lcm_utils import LcmException, LcmExceptionNoMgmtIP, LcmBase, deep_get, get_iterable, populate_dict
from osm_lcm.data_utils.nsd import get_vnf_profiles
-from osm_lcm.data_utils.vnfd import get_vnf_configuration, get_vdu_list, get_vdu_profile, \
+from osm_lcm.data_utils.vnfd import get_vdu_list, get_vdu_profile, \
get_ee_sorted_initial_config_primitive_list, get_ee_sorted_terminate_config_primitive_list, \
- get_kdu_list, get_virtual_link_profiles, get_vdu, get_vdu_configuration, get_kdu_configuration, \
+ get_kdu_list, get_virtual_link_profiles, get_vdu, get_configuration, \
get_vdu_index, get_scaling_aspect, get_number_of_instances
from osm_lcm.data_utils.list_utils import find_in_list
from osm_lcm.data_utils.vnfr import get_osm_params
# remove unused by RO configuration, monitoring, scaling and internal keys
vnfd_RO.pop("_id", None)
vnfd_RO.pop("_admin", None)
- vnfd_RO.pop("vnf-configuration", None)
vnfd_RO.pop("monitoring-param", None)
vnfd_RO.pop("scaling-group-descriptor", None)
vnfd_RO.pop("kdu", None)
self.logger.debug("NS > ssh_keys > {}".format(ssh_keys_all))
if ssh_keys_all:
- vdu_configuration = get_vdu_configuration(vnfd, vdur["vdu-id-ref"])
- vnf_configuration = get_vnf_configuration(vnfd)
+ vdu_configuration = get_configuration(vnfd, vdur["vdu-id-ref"])
+ vnf_configuration = get_configuration(vnfd, vnfd["id"])
if vdu_configuration and vdu_configuration.get("config-access") and \
vdu_configuration.get("config-access").get("ssh-access"):
vdur["ssh-keys"] = ssh_keys_all
if db_vnfr.get("additionalParamsForVnf"):
deploy_params.update(parse_yaml_strings(db_vnfr["additionalParamsForVnf"].copy()))
- descriptor_config = get_vnf_configuration(vnfd)
+ descriptor_config = get_configuration(vnfd, vnfd["id"])
if descriptor_config:
self._deploy_n2vc(
logging_text=logging_text + "member_vnf_index={} ".format(member_vnf_index),
# Deploy charms for each VDU that supports one.
for vdud in get_vdu_list(vnfd):
vdu_id = vdud["id"]
- descriptor_config = get_vdu_configuration(vnfd, vdu_id)
+ descriptor_config = get_configuration(vnfd, vdu_id)
vdur = find_in_list(db_vnfr["vdur"], lambda vdu: vdu["vdu-id-ref"] == vdu_id)
if vdur.get("additionalParams"):
)
for kdud in get_kdu_list(vnfd):
kdu_name = kdud["name"]
- descriptor_config = kdud.get('kdu-configuration')
+ descriptor_config = get_configuration(vnfd, kdu_name)
if descriptor_config:
vdu_id = None
vdu_index = 0
if db_vnfd_list:
for vnfd in db_vnfd_list:
db_vnfd = self.db.get_one("vnfds", {"_id": vnfd})
- db_vnf_relations = deep_get(db_vnfd, ('vnf-configuration', 'relation'))
+ db_vnf_relations = get_configuration(db_vnfd, db_vnfd["id"]).get("relation", [])
if db_vnf_relations:
for r in db_vnf_relations:
# check if this VCA is in the relation
config_descriptor = db_nsr.get("ns-configuration")
elif vca.get("vdu_id"):
db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
- vdud = next((vdu for vdu in db_vnfd.get("vdu", ()) if vdu["id"] == vca.get("vdu_id")), None)
- if vdud:
- config_descriptor = vdud.get("vdu-configuration")
+ config_descriptor = get_configuration(db_vnfd, vca.get("vdu_id"))
elif vca.get("kdu_name"):
db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
- kdud = next((kdu for kdu in db_vnfd.get("kdu", ()) if kdu["name"] == vca.get("kdu_name")), None)
- if kdud:
- config_descriptor = kdud.get("kdu-configuration")
+ config_descriptor = get_configuration(db_vnfd, vca.get("kdu_name"))
else:
- config_descriptor = db_vnfds_from_member_index[vca["member-vnf-index"]].get("vnf-configuration")
+ db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
+ config_descriptor = get_configuration(db_vnfd, db_vnfd["id"])
vca_type = vca.get("type")
exec_terminate_primitives = (not operation_params.get("skip_terminate_primitives") and
vca.get("needed_terminate"))
# look for primitive
config_primitive_desc = descriptor_configuration = None
if vdu_id:
- descriptor_configuration = get_vdu_configuration(db_vnfd, vdu_id)
+ descriptor_configuration = get_configuration(db_vnfd, vdu_id)
elif kdu_name:
- descriptor_configuration = get_kdu_configuration(db_vnfd, kdu_name)
+ descriptor_configuration = get_configuration(db_vnfd, kdu_name)
elif vnf_index:
- descriptor_configuration = get_vnf_configuration(db_vnfd)
+ descriptor_configuration = get_configuration(db_vnfd, db_vnfd["id"])
else:
descriptor_configuration = db_nsd.get("ns-configuration")
desc_params = parse_yaml_strings(db_vnfr.get("additionalParamsForVnf"))
else:
desc_params = parse_yaml_strings(db_nsr.get("additionalParamsForNs"))
- if kdu_name and get_kdu_configuration(db_vnfd, kdu_name):
- kdu_configuration = get_kdu_configuration(db_vnfd, kdu_name)
+ if kdu_name and get_configuration(db_vnfd, kdu_name):
+ kdu_configuration = get_configuration(db_vnfd, kdu_name)
actions = set()
for primitive in kdu_configuration.get("initial-config-primitive", []):
actions.add(primitive["name"])
"executing pre-scale scaling-config-action '{}'".format(vnf_config_primitive)
# look for primitive
- for config_primitive in db_vnfd.get("vnf-configuration", {}).get("config-primitive", ()):
+ for config_primitive in (get_configuration(
+ db_vnfd, db_vnfd["id"]
+ ) or {}).get("config-primitive", ()):
if config_primitive["name"] == vnf_config_primitive:
break
else: