From 327ee8d5b8fdc440c4cb075af595d6f2a045d745 Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Thu, 1 Dec 2016 11:23:59 +0100 Subject: [PATCH] Use absolute path when handling missing files When we try to handle rendered files in the environment, we create a whole new env file copying the resource registry. As the file is in a new location, we need to reference files with absolute directories, as relative directories won't point to anything. Change-Id: I19abb1ef8a003e45f414ba86e1dc763789c0b86f Closes-Bug: #1640324 --- .../v1/overcloud_deploy/test_overcloud_deploy.py | 14 +++++++++++--- tripleoclient/v1/overcloud_deploy.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py index b83c5580f..c1fbffbd2 100644 --- a/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py +++ b/tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py @@ -684,11 +684,19 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): mock_update_parameters.return_value = {} mock_utils_endpoint.return_value = 'foo.bar' + os.mkdir(self.tmp_dir.join('env')) + os.mkdir(self.tmp_dir.join('common')) - test_env = self.tmp_dir.join('foo2.yaml') + test_env = self.tmp_dir.join('env/foo2.yaml') with open(test_env, 'w') as temp_file: - temp_file.write('resource_registry:\n Test: /tmp/doesnexit.yaml') + temp_file.write('resource_registry:\n ' + 'Test1: ../common/bar.yaml\n ' + 'Test2: /tmp/doesnexit.yaml') + + test_sub_env = self.tmp_dir.join('common/bar.yaml') + with open(test_sub_env, 'w') as temp_file: + temp_file.write('outputs:\n data:\n value: 1') arglist = ['--templates'] verifylist = [ @@ -696,7 +704,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud): ] self.useFixture( fixtures.EnvironmentVariable('TRIPLEO_ENVIRONMENT_DIRECTORY', - self.tmp_dir.path)) + self.tmp_dir.join('env'))) parsed_args = self.check_parser(self.cmd, arglist, verifylist) error = self.assertRaises(hc_exc.CommandError, self.cmd.take_action, diff --git a/tripleoclient/v1/overcloud_deploy.py b/tripleoclient/v1/overcloud_deploy.py index 2f4b68678..364538e13 100644 --- a/tripleoclient/v1/overcloud_deploy.py +++ b/tripleoclient/v1/overcloud_deploy.py @@ -176,7 +176,7 @@ class DeployOvercloud(command.Command): % (env_path, rsrc, new_rsrc_path)) env_registry[rsrc] = new_rsrc_path else: - env_registry[rsrc] = rsrc_path + env_registry[rsrc] = abs_rsrc_path env_map['resource_registry'] = env_registry f_name = os.path.basename(os.path.splitext(abs_env_path)[0]) with tempfile.NamedTemporaryFile(dir=tht_root,