From f44c7e25ed29d1217cf95944d29bee7978c7a8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Fri, 4 Jun 2021 18:02:37 +0200 Subject: [PATCH] Move copy_env_files to utils Use os.path.join purely to join the path, use of format is not required. Change-Id: I20db5526cb9c805cd65be154caff1eee0c66b3c1 --- tripleoclient/utils.py | 17 +++++++++++++++++ tripleoclient/v1/overcloud_deploy.py | 20 +------------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tripleoclient/utils.py b/tripleoclient/utils.py index 8a9758ffe..e8ff34d1c 100644 --- a/tripleoclient/utils.py +++ b/tripleoclient/utils.py @@ -2772,3 +2772,20 @@ def build_image_params(env_files, parsed_args, new_tht_root, user_tht_root): ) return image_params + + +def copy_env_files(files_dict, tht_root): + file_prefix = "file://" + + for full_path in files_dict.keys(): + if not full_path.startswith(file_prefix): + continue + + path = full_path[len(file_prefix):] + + if path.startswith(tht_root): + continue + + relocate_path = os.path.join(tht_root, "user-environments", + os.path.basename(path)) + safe_write(relocate_path, files_dict[full_path]) diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index db9a3b9b2..9ef80be1c 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -260,7 +260,7 @@ class DeployOvercloud(command.Command): cleanup=(not parsed_args.no_cleanup)) # Copy the env_files to tmp folder for archiving - self._copy_env_files(env_files, new_tht_root) + utils.copy_env_files(env_files, new_tht_root) if parsed_args.limit: # check if skip list is defined while using --limit and throw a @@ -304,24 +304,6 @@ class DeployOvercloud(command.Command): self._unprovision_baremetal(parsed_args) - def _copy_env_files(self, files_dict, tht_root): - file_prefix = "file://" - - for fullpath in files_dict.keys(): - - if not fullpath.startswith(file_prefix): - continue - - path = fullpath[len(file_prefix):] - - if path.startswith(tht_root): - continue - - reloc_path = os.path.join( - tht_root, - "user-environments/{}".format(os.path.basename(path))) - utils.safe_write(reloc_path, files_dict[fullpath]) - def _try_overcloud_deploy_with_compat_yaml(self, tht_root, stack, stack_name, env_files, timeout,