From: David Garcia Date: Tue, 26 Oct 2021 15:17:50 +0000 (+0200) Subject: Fix bug 1721: charms can include reference to .charm files X-Git-Tag: v10.1.1-rc1~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F11995%2F1;p=osm%2Fosmclient.git Fix bug 1721: charms can include reference to .charm files Change-Id: I7bb1c468c528e390b4368e7bdb172f47066c8d48 Signed-off-by: David Garcia Signed-off-by: garciadeblas --- diff --git a/osmclient/common/package_tool.py b/osmclient/common/package_tool.py index 658b8e0..21e9670 100644 --- a/osmclient/common/package_tool.py +++ b/osmclient/common/package_tool.py @@ -91,7 +91,9 @@ class PackageTool(object): "detailed": detailed, } elif package_type == "vnf": - template = env.get_template("vnfd.yaml.j2" if not old else "vnfd_old.yaml.j2") + template = env.get_template( + "vnfd.yaml.j2" if not old else "vnfd_old.yaml.j2" + ) content = { "name": package_name, "vendor": vendor, @@ -153,7 +155,9 @@ class PackageTool(object): f for f in glob.glob(base_directory + "/*.yaml", recursive=recursive) ] self._logger.info("Base directory: {}".format(base_directory)) - self._logger.info("{} Descriptors found to validate".format(len(descriptors_paths))) + self._logger.info( + "{} Descriptors found to validate".format(len(descriptors_paths)) + ) for desc_path in descriptors_paths: with open(desc_path) as descriptor_file: descriptor_data = descriptor_file.read() @@ -538,6 +542,8 @@ class PackageTool(object): else: if not os.path.isdir( "{}/charms/{}".format(package_folder, charmName) + ) and not os.path.isfile( + "{}/charms/{}".format(package_folder, charmName) ): raise ClientException( "The charm: {} referenced in the descriptor file " @@ -719,9 +725,12 @@ class PackageTool(object): self._logger.debug( "Copying tree: {} -> {}".format(s_charm, d_temp) ) - shutil.copytree( - s_charm, d_temp, symlinks=True, ignore=ignore - ) + if os.path.isdir(s_charm): + shutil.copytree( + s_charm, d_temp, symlinks=True, ignore=ignore + ) + else: + shutil.copy2(s_charm, d_temp) self._logger.debug("DONE") else: self._logger.debug("Copying tree: {} -> {}".format(s, d))