From: garciaale Date: Mon, 22 Feb 2021 21:02:07 +0000 (-0300) Subject: fix(configuration): juju related changes to honor descriptor changes introduced in... X-Git-Tag: v9.1.0~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=762b6e7182f5bbba4b4206b12204e77bd45c3d33;p=osm%2FLCM.git 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 Signed-off-by: garciaale --- 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 ed8112b..1e40fee 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 @@ -2244,8 +2244,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"])) @@ -2434,10 +2435,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 = [] @@ -3915,7 +3914,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 9b12feb..482160a 100644 --- a/osm_lcm/tests/test_db_descriptors.py +++ b/osm_lcm/tests/test_db_descriptors.py @@ -998,8 +998,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 @@ -1009,18 +1014,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 @@ -1045,6 +1050,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