From 4054a86e8a9e206b36c53d84d67035646f0beee9 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Tue, 26 Oct 2021 17:17:50 +0200 Subject: [PATCH] Fix bug 1721: charms can include reference to .charm files Change-Id: I7bb1c468c528e390b4368e7bdb172f47066c8d48 Signed-off-by: David Garcia --- osmclient/common/package_tool.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osmclient/common/package_tool.py b/osmclient/common/package_tool.py index 50307e7..436053c 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)) -- 2.25.1