From 9a256dbc33676a12665c8a77e1e22154d34eab4b Mon Sep 17 00:00:00 2001 From: bravof Date: Mon, 22 Feb 2021 18:02:07 -0300 Subject: [PATCH] fix(configuration): juju related changes to honor descriptor changes introduced in v8 and fixes for new configuration model Change-Id: Ib5131a94b944c1aed985c2a612cf2b5d871673de Signed-off-by: bravof --- osm_lcm/data_utils/vnfd.py | 10 ++++++++++ osm_lcm/ns.py | 17 +++++++++-------- osm_lcm/tests/test_db_descriptors.py | 11 +++++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/osm_lcm/data_utils/vnfd.py b/osm_lcm/data_utils/vnfd.py index 16257db..f816a8d 100644 --- a/osm_lcm/data_utils/vnfd.py +++ b/osm_lcm/data_utils/vnfd.py @@ -139,3 +139,13 @@ def get_number_of_instances(vnfd, vdu_id): ), lambda a_vdu: a_vdu["vdu-id"] == vdu_id )["number-of-instances"] + + +def get_juju_ee_ref(vnfd, entity_id): + return list_utils.find_in_list( + get_configuration(vnfd, entity_id).get( + "execution-environment-list", + [] + ), + lambda ee: "juju" in ee + ) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index f5bdff3..4077d01 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -31,7 +31,7 @@ from osm_lcm.data_utils.nsd import get_vnf_profiles 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_configuration, \ - get_vdu_index, get_scaling_aspect, get_number_of_instances + get_vdu_index, get_scaling_aspect, get_number_of_instances, get_juju_ee_ref from osm_lcm.data_utils.list_utils import find_in_list from osm_lcm.data_utils.vnfr import get_osm_params from osm_lcm.data_utils.dict_utils import parse_yaml_strings @@ -2237,8 +2237,9 @@ class NsLcm(LcmBase): vnfr_update_dict["kdur.{}.status".format(kdu_index)] = "READY" self.update_db_2("vnfrs", vnfr_data.get("_id"), vnfr_update_dict) - kdu_config = kdud.get("kdu-configuration") - if kdu_config and kdu_config.get("initial-config-primitive") and kdu_config.get("juju") is None: + kdu_config = get_configuration(vnfd, k8s_instance_info["kdu-name"]) + if kdu_config and kdu_config.get("initial-config-primitive") and \ + get_juju_ee_ref(vnfd, k8s_instance_info["kdu-name"]) is None: initial_config_primitive_list = kdu_config.get("initial-config-primitive") initial_config_primitive_list.sort(key=lambda val: int(val["seq"])) @@ -2427,10 +2428,8 @@ class NsLcm(LcmBase): # fill db_nsr._admin.deployed.VCA. self.logger.debug(logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)) - if descriptor_config.get("juju"): # There is one execution envioronment of type juju - ee_list = [descriptor_config] - elif descriptor_config.get("execution-environment-list"): - ee_list = descriptor_config.get("execution-environment-list") + if "execution-environment-list" in descriptor_config: + ee_list = descriptor_config.get("execution-environment-list", []) else: # other types as script are not supported ee_list = [] @@ -3908,7 +3907,9 @@ class NsLcm(LcmBase): vnfr_params.update(db_vnfr["additionalParamsForVnf"]) # 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: diff --git a/osm_lcm/tests/test_db_descriptors.py b/osm_lcm/tests/test_db_descriptors.py index be420c7..6b4be6a 100644 --- a/osm_lcm/tests/test_db_descriptors.py +++ b/osm_lcm/tests/test_db_descriptors.py @@ -1000,8 +1000,13 @@ db_vnfds_text = """ operate-vnf-op-config: day1-2: - id: hackfest3charmed-vnf + execution-environment-list: + - id: simple-ee + juju: + charm: simple initial-config-primitive: - seq: "1" + execution-environment-ref: simple-ee name: config parameter: - name: ssh-hostname @@ -1011,18 +1016,18 @@ db_vnfds_text = """ - name: ssh-password value: osm4u - seq: "2" + execution-environment-ref: simple-ee name: touch parameter: - name: filename value: config-primitive: - name: touch + execution-environment-ref: simple-ee parameter: - data-type: STRING default-value: name: filename - juju: - charm: simple - _admin: created: 1575031727.5383403 @@ -1047,6 +1052,8 @@ db_vnfds_text = """ - name: mgmt description: KNF with two KDU using helm-charts id: multikdu_knf + df: + - id: "default_df" k8s-cluster: nets: - external-connection-point-ref: mgmt -- 2.17.1