Fix multi-vdu workflow w/o charm 97/5997/1
authorAdam Israel <adam.israel@canonical.com>
Wed, 18 Apr 2018 17:12:12 +0000 (13:12 -0400)
committerAdam Israel <adam.israel@canonical.com>
Wed, 18 Apr 2018 17:12:12 +0000 (13:12 -0400)
Consider the use-case where a VNF defines a vnf-configuration, and
contains two VDUs without vdu-configuration. There should only be one
charm deployed, at the VNF level.

This patch complies with the above use-case.

Change-Id: I16eadef6c4a5807d47194d4b3ee9e7c66ec67be3
Signed-off-by: Adam Israel <adam.israel@canonical.com>
lcm/osm_lcm/lcm.py

index d2a560b..2b62c1f 100644 (file)
@@ -744,6 +744,20 @@ class Lcm:
                 vnf_index = str(c_vnf["member-vnf-index"])
                 vnfd = needed_vnfd[vnfd_id]
 
+                # Check if this VNF has a charm configuration
+                vnf_config = vnfd.get("vnf-configuration")
+
+                if vnf_config and vnf_config.get("juju"):
+                    proxy_charm = vnf_config["juju"]["charm"]
+                    params = {}
+
+                    if proxy_charm:
+                        if 'initial-config-primitive' in vnf_config:
+                            params['initial-config-primitive'] = vnf_config['initial-config-primitive']
+
+                        deploy()
+                        number_to_configure += 1
+
                 # Deploy charms for each VDU that supports one.
                 for vdu in vnfd['vdu']:
                     vdu_config = vdu.get('vdu-configuration')
@@ -756,22 +770,9 @@ class Lcm:
                         if 'initial-config-primitive' in vdu_config:
                             params['initial-config-primitive'] = vdu_config['initial-config-primitive']
 
-                    else:
-                        # If a VDU doesn't declare it's own charm, check
-                        # if the VNF does and deploy that instead.
-
-                        # Check if this VNF has a charm configuration
-                        vnf_config = vnfd.get("vnf-configuration")
-
-                        if vnf_config and vnf_config.get("juju"):
-                            proxy_charm = vnf_config["juju"]["charm"]
-
-                            if 'initial-config-primitive' in vnf_config:
-                                params['initial-config-primitive'] = vnf_config['initial-config-primitive']
-
-                    if proxy_charm:
-                        deploy()
-                        number_to_configure += 1
+                        if proxy_charm:
+                            deploy()
+                            number_to_configure += 1
 
             db_nsr["config-status"] = "configuring" if number_to_configure else "configured"
             db_nsr["detailed-status"] = "configuring: init: {}".format(number_to_configure) if number_to_configure else "done"