From 7f410e9c22072883e207b9a8f9832ffdd7e80834 Mon Sep 17 00:00:00 2001 From: bravof Date: Wed, 5 May 2021 20:37:03 -0400 Subject: [PATCH] fix(config translation): execution environments for juju now are properly translated. Bug 1490 Change-Id: Icbada523938b0053802676732b10cc26df2888b2 Signed-off-by: bravof --- osm_im/im_translation.py | 30 +++++++++++++++++++ .../hackfest_charmed_vnfd_sol006.yaml | 11 +++++-- tests/examples/vepc_sol006.yaml | 19 +++++++++--- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/osm_im/im_translation.py b/osm_im/im_translation.py index 78a2931..466026c 100644 --- a/osm_im/im_translation.py +++ b/osm_im/im_translation.py @@ -61,6 +61,7 @@ def translate_im_vnfd_to_sol006(im_vnfd): _add_im_kdus_to_sol006_vnfd(im_vnfd, sol006_vnfd) _add_im_k8s_clusters_to_sol006_vnfd(im_vnfd, sol006_vnfd) _add_im_placement_groups_to_sol006_vnfd(im_vnfd, sol006_vnfd) + _cleanup_juju_in_configurations(sol006_vnfd) return {"vnfd": sol006_vnfd} @@ -417,6 +418,35 @@ def _prepare_dict_entries_for_configurations(sol006_vnfd): } } +def _cleanup_juju_in_configurations(sol006_vnfd): + configs = sol006_vnfd["df"][0].get("lcm-operations-configuration") + if configs: + for day12_config in configs["operate-vnf-op-config"]["day1-2"]: + if "juju" in day12_config: + ee_name = _create_execution_environment_for_juju(day12_config, day12_config["juju"]["charm"]) + for primitive in day12_config.get("config-primitive", []): + primitive["execution-environment-ref"] = ee_name + for primitive in day12_config.get("initial-config-primitive", []): + primitive["execution-environment-ref"] = ee_name + for primitive in day12_config.get("terminate-config-primitive", []): + primitive["execution-environment-ref"] = ee_name + day12_config.pop("juju", None) + +def _create_execution_environment_for_juju(day12_config, charm_name): + if not "execution-environment-list" in day12_config: + day12_config["execution-environment-list"] = [] + + day12_config["execution-environment-list"].append( + { + "id": charm_name + "-ee", + "juju": { + "charm": charm_name + } + } + ) + + return charm_name + "-ee" + def _add_im_vnf_configuration_to_sol006_vnfd(im_vnfd, sol006_vnfd): vnf_configuration = im_vnfd.get("vnf-configuration") if not vnf_configuration: diff --git a/tests/examples/hackfest_charmed_vnfd_sol006.yaml b/tests/examples/hackfest_charmed_vnfd_sol006.yaml index ab55af8..4136fb9 100644 --- a/tests/examples/hackfest_charmed_vnfd_sol006.yaml +++ b/tests/examples/hackfest_charmed_vnfd_sol006.yaml @@ -152,8 +152,13 @@ vnfd: 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 @@ -163,15 +168,15 @@ vnfd: - 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 \ No newline at end of file + name: filename \ No newline at end of file diff --git a/tests/examples/vepc_sol006.yaml b/tests/examples/vepc_sol006.yaml index f248efd..4137873 100644 --- a/tests/examples/vepc_sol006.yaml +++ b/tests/examples/vepc_sol006.yaml @@ -130,6 +130,10 @@ vnfd: operate-vnf-op-config: day1-2: - id: vEPC_vnfd + execution-environment-list: + - id: spgwcharm-ee + juju: + charm: spgwcharm initial-config-primitive: - seq: "1" name: config @@ -140,6 +144,7 @@ vnfd: value: ubuntu - name: ssh-password value: + execution-environment-ref: spgwcharm-ee - seq: "2" name: configure-spgw parameter: @@ -149,8 +154,10 @@ vnfd: - name: hss-ip data-type: STRING value: + execution-environment-ref: spgwcharm-ee - seq: "3" name: restart-spgw + execution-environment-ref: spgwcharm-ee config-primitive: - name: add-route parameter: @@ -160,11 +167,15 @@ vnfd: - name: next-hop data-type: STRING default-value: "192.168.2.1" - juju: - charm: spgwcharm + execution-environment-ref: spgwcharm-ee - id: hss + execution-environment-list: + - id: hsscharm-ee + juju: + charm: hsscharm initial-config-primitive: - seq: "1" + execution-environment-ref: hsscharm-ee name: config parameter: - name: ssh-hostname @@ -182,10 +193,10 @@ vnfd: - name: hss-ip data-type: STRING value: + execution-environment-ref: hsscharm-ee - seq: "3" name: restart-hss - juju: - charm: hsscharm + execution-environment-ref: hsscharm-ee int-virtual-link-desc: - id: s6a ext-cpd: -- 2.25.1