From: bravof Date: Mon, 22 Feb 2021 21:04:40 +0000 (-0300) Subject: fix(configuration): juju related changes and configuration issues X-Git-Tag: v9.1.0~1^2~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=2325828219f5009508f34b34a43dfcdf58d0aa0b;p=osm%2FNBI.git fix(configuration): juju related changes and configuration issues Change-Id: I55db87441ccefd63c09f77c60c2de4097be4915f Signed-off-by: bravof --- diff --git a/osm_nbi/descriptor_topics.py b/osm_nbi/descriptor_topics.py index 7ea06c5..0ad3e83 100644 --- a/osm_nbi/descriptor_topics.py +++ b/osm_nbi/descriptor_topics.py @@ -625,11 +625,16 @@ class VnfdTopic(DescriptorTopic): for df in indata["df"]: if "lcm-operations-configuration" in df and "operate-vnf-op-config" in df["lcm-operations-configuration"]: configs = df["lcm-operations-configuration"]["operate-vnf-op-config"].get("day1-2", []) - for config in configs: - if config.get("juju"): - if not self._validate_package_folders(storage_params, 'charms'): - raise EngineException("Charm defined in vnf[id={}] but not present in " - "package".format(indata["id"])) + vdus = df["vdu-profile"] + for vdu in vdus: + for config in configs: + if config["id"] == vdu["id"] and utils.find_in_list( + config.get("execution-environment-list", []), + lambda ee: "juju" in ee + ): + if not self._validate_package_folders(storage_params, 'charms'): + raise EngineException("Charm defined in vnf[id={}] but not present in " + "package".format(indata["id"])) def _validate_vdu_cloud_init_in_package(self, storage_params, vdu, indata): if not vdu.get("cloud-init-file"): @@ -647,8 +652,10 @@ class VnfdTopic(DescriptorTopic): return for day_1_2_config in deployment_flavor["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"]: if day_1_2_config["id"] == indata["id"]: - vnf_configuration = day_1_2_config - if vnf_configuration.get("juju"): + if utils.find_in_list( + day_1_2_config.get("execution-environment-list", []), + lambda ee: "juju" in ee + ): if not self._validate_package_folders(storage_params, 'charms'): raise EngineException("Charm defined in vnf[id={}] but not present in " "package".format(indata["id"])) diff --git a/osm_nbi/tests/test_db_descriptors.py b/osm_nbi/tests/test_db_descriptors.py index 050f70b..8b0b226 100644 --- a/osm_nbi/tests/test_db_descriptors.py +++ b/osm_nbi/tests/test_db_descriptors.py @@ -212,8 +212,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 @@ -223,18 +228,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 """ db_nsds_text = """ diff --git a/osm_nbi/tests/test_descriptor_topics.py b/osm_nbi/tests/test_descriptor_topics.py index 7f07d96..b52b6e0 100755 --- a/osm_nbi/tests/test_descriptor_topics.py +++ b/osm_nbi/tests/test_descriptor_topics.py @@ -112,9 +112,21 @@ class Test_VnfdTopic(TestCase): self.assertEqual(db_args[1]["_admin"]["projects_read"], [test_pid], "Wrong read-only project list") self.assertEqual(db_args[1]["_admin"]["projects_write"], [test_pid], "Wrong read-write project list") tmp1 = test_vnfd["vdu"][0]["cloud-init-file"] - tmp2 = test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][0]["juju"] + tmp2 = test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] del test_vnfd["vdu"][0]["cloud-init-file"] - del test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][0]["juju"] + del test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] try: self.db.get_one.side_effect = [{"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])}, None] self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) @@ -145,7 +157,13 @@ class Test_VnfdTopic(TestCase): compare_desc(self, test_vnfd, db_args[2], "VNFD") finally: test_vnfd["vdu"][0]["cloud-init-file"] = tmp1 - test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][0]["juju"] = tmp2 + test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] = tmp2 self.db.get_one.side_effect = lambda table, filter, fail_on_empty=None, fail_on_more=None: \ {"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])} with self.subTest(i=2, t='Check Pyangbind Validation: additional properties'): @@ -182,10 +200,17 @@ class Test_VnfdTopic(TestCase): del test_vnfd["vdu"][0]["cloud-init-file"] with self.assertRaises(EngineException, msg="Accepted non-existent charm in VNF configuration") as e: self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) + print(str(e.exception)) self.assertEqual(e.exception.http_code, HTTPStatus.BAD_REQUEST, "Wrong HTTP status code") self.assertIn(norm("{} defined in vnf[id={}] but not present in package".format("charm", test_vnfd["id"])), norm(str(e.exception)), "Wrong exception text") - del test_vnfd["df"][0]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][0]["juju"] + del test_vnfd["df"][ + 0 + ]["lcm-operations-configuration"]["operate-vnf-op-config"]["day1-2"][ + 0 + ]["execution-environment-list"][ + 0 + ]["juju"] with self.subTest(i=6, t='Check Input Validation: mgmt-cp'): tmp = test_vnfd["mgmt-cp"] del test_vnfd["mgmt-cp"] diff --git a/osm_nbi/tests/test_pkg_descriptors.py b/osm_nbi/tests/test_pkg_descriptors.py index fd8cac9..91e5641 100644 --- a/osm_nbi/tests/test_pkg_descriptors.py +++ b/osm_nbi/tests/test_pkg_descriptors.py @@ -179,8 +179,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 @@ -190,18 +195,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 """ db_nsds_text = """