fix(config translation): execution environments for juju now are properly translated... 57/10757/2 release-v10.0-start
authorbravof <fbravo@whitestack.com>
Thu, 6 May 2021 00:37:03 +0000 (20:37 -0400)
committerbravof <fbravo@whitestack.com>
Thu, 6 May 2021 11:36:06 +0000 (13:36 +0200)
Change-Id: Icbada523938b0053802676732b10cc26df2888b2
Signed-off-by: bravof <fbravo@whitestack.com>
osm_im/im_translation.py
tests/examples/hackfest_charmed_vnfd_sol006.yaml
tests/examples/vepc_sol006.yaml

index 78a2931..466026c 100644 (file)
@@ -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:
index ab55af8..4136fb9 100644 (file)
@@ -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: <touch_filename>
             config-primitive:
               - name: touch
+                execution-environment-ref: simple-ee
                 parameter:
                   - data-type: STRING
                     default-value: <touch_filename2>
-                    name: filename
-            juju:
-              charm: simple
\ No newline at end of file
+                    name: filename
\ No newline at end of file
index f248efd..4137873 100644 (file)
@@ -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: <password>
+                execution-environment-ref: spgwcharm-ee
               - seq: "2"
                 name: configure-spgw
                 parameter:
@@ -149,8 +154,10 @@ vnfd:
                   - name: hss-ip
                     data-type: STRING
                     value: <hss_ip>
+                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: <hss_ip>
+                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: