X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcommon%2Fpackage_tool.py;h=2531f7a089d9246528d077186c023cd0645a89ce;hb=d169d606f469ab5ccb76aeb11bd56edbcb6bd933;hp=a2cbd875adbed8642b37233a45f18d504f7c2e6b;hpb=e6e9ebfa7cc4d9c3d0bda4a2dcab7f337af63baf;p=osm%2Fosmclient.git diff --git a/osmclient/common/package_tool.py b/osmclient/common/package_tool.py index a2cbd87..2531f7a 100644 --- a/osmclient/common/package_tool.py +++ b/osmclient/common/package_tool.py @@ -519,13 +519,28 @@ class PackageTool(object): ] else: descriptors_paths = [f for f in glob.glob(package_folder + "/*.yaml")] - for file in descriptors_paths: - if file.endswith("nfd.yaml"): - descriptor_file = True - charms_set = self.charms_search(file, "vnf") - if file.endswith("nsd.yaml"): - descriptor_file = True - charms_set = self.charms_search(file, "ns") + if len(descriptors_paths) == 1: + # The base folder usually has a single yaml file with the descriptor + descriptor_file = True + pkg_type = utils.get_key_val_from_descriptor(descriptors_paths[0]) + if pkg_type is None: + raise ClientException("Cannot determine package type") + if pkg_type["type"] == "nsd": + charms_set = self.charms_search(descriptors_paths[0], "ns") + else: + charms_set = self.charms_search(descriptors_paths[0], "vnf") + elif len(descriptors_paths) > 1: + for file in descriptors_paths: + if file.endswith("nfd.yaml"): + descriptor_file = True + charms_set = self.charms_search(file, "vnf") + if file.endswith("nsd.yaml"): + descriptor_file = True + charms_set = self.charms_search(file, "ns") + else: + raise ClientException( + "Package folder does not contain valid descriptor files '*.yaml'" + ) print("List of charms in the descriptor: {}".format(charms_set)) if not descriptor_file: raise ClientException(