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
This commit is contained in:
Thomas Herve
2016-12-01 11:23:59 +01:00
parent 0804d4f628
commit 327ee8d5b8
2 changed files with 12 additions and 4 deletions

View File

@@ -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,

View File

@@ -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,