Fix bug 1370 08/10108/1 release-v9.0-start v9.0.0 v9.0.0rc1
authorDavid Garcia <david.garcia@canonical.com>
Mon, 14 Dec 2020 15:52:19 +0000 (16:52 +0100)
committerDavid Garcia <david.garcia@canonical.com>
Mon, 14 Dec 2020 15:52:19 +0000 (16:52 +0100)
ns-configuration charms were not properly discovered by the client

Change-Id: I56c87ff9285325934dc443bb3f4393fa5e5df2f7
Signed-off-by: David Garcia <david.garcia@canonical.com>
osmclient/common/package_tool.py

index 1457e79..c858150 100644 (file)
@@ -458,8 +458,13 @@ class PackageTool(object):
                  (desc_type=="ns" and ( "nsd:nsd-catalog" in descriptor_dict or "nsd-catalog" in descriptor_dict)) ):
                 charms_list = self._charms_search_on_osm_im_dict(descriptor_dict, desc_type)
             else:
-                charms_list = self._charms_search_on_sol006_dict(descriptor_dict, desc_type)
-
+                if desc_type == "ns":
+                    get_charm_list = self._charms_search_on_nsd_sol006_dict
+                elif desc_type == "vnf":
+                    get_charm_list = self._charms_search_on_vnfd_sol006_dict
+                else:
+                    raise Exception("Bad descriptor type")
+                charms_list = get_charm_list(descriptor_dict)
         return charms_list
 
     def _charms_search_on_osm_im_dict(self, osm_im_dict, desc_type):
@@ -482,12 +487,12 @@ class PackageTool(object):
                                         charms_list.append((v4['charm']))
         return charms_list
 
-    def _charms_search_on_sol006_dict(self, sol006_dict, desc_type):
+    def _charms_search_on_vnfd_sol006_dict(self, sol006_dict):
         self._logger.debug("")
         charms_list = []
         for k1, v1 in sol006_dict.items():
             for k2, v2 in v1.items():
-                if '{}-configuration'.format(desc_type) in k2:
+                if 'vnf-configuration' in k2:
                     for vnf_config in v2:
                         for k3, v3 in vnf_config.items():
                             if 'charm' in v3:
@@ -498,3 +503,13 @@ class PackageTool(object):
                             if 'charm' in v3:
                                 charms_list.append((v3['charm']))
         return charms_list
+
+    def _charms_search_on_nsd_sol006_dict(self, sol006_dict):
+        self._logger.debug("")
+        charms_list = []
+        nsd_list = sol006_dict.get("nsd", {}).get("nsd", [])
+        for nsd in nsd_list:
+            charm = nsd.get("ns-configuration", {}).get("juju", {}).get("charm")
+            if charm:
+                charms_list.append(charm)
+        return charms_list