Browse Source

[stable-only] Use folder with plan name for config download export

To be consistent with auto config-download and overcloud export
create subfloder with plan/stack name.

Change-Id: I08b447379ae6e267f8dff11e6e703a991918683c
Closes-Bug: #1884246
(cherry picked from commit 46c9aa552f)
changes/41/741141/2
Rabi Mishra 1 month ago
committed by wes hayutin
parent
commit
309df8afbe
2 changed files with 15 additions and 5 deletions
  1. +9
    -1
      tripleoclient/tests/v1/overcloud_config/test_overcloud_config.py
  2. +6
    -4
      tripleoclient/v1/overcloud_config.py

+ 9
- 1
tripleoclient/tests/v1/overcloud_config/test_overcloud_config.py View File

@@ -50,6 +50,7 @@ class TestOvercloudConfig(utils.TestCommand):
mock_open.assert_called()
mock_request.urlopen.assert_called()

@mock.patch('os.path.exists')
@mock.patch('tripleoclient.v1.overcloud_config.processutils.execute')
@mock.patch('tripleoclient.v1.overcloud_config.open')
@mock.patch('tripleoclient.v1.overcloud_config.request')
@@ -57,7 +58,7 @@ class TestOvercloudConfig(utils.TestCommand):
@mock.patch('tripleoclient.workflows.deployment.config_download_export')
def test_overcloud_download_config_no_preserve(
self, mock_config, mock_rmtree, mock_request,
mock_open, mock_execute):
mock_open, mock_execute, mock_exists):
arglist = ['--name', 'overcloud', '--config-dir', '/tmp',
'--no-preserve-config']
verifylist = [
@@ -66,6 +67,13 @@ class TestOvercloudConfig(utils.TestCommand):
('preserve_config_dir', False)
]

def side_effect(arg):
if arg == '/tmp/overcloud':
return True
else:
return False

mock_exists.side_effect = side_effect
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_config.assert_called_once_with(


+ 6
- 4
tripleoclient/v1/overcloud_config.py View File

@@ -84,9 +84,11 @@ class DownloadConfig(command.Command):

name = parsed_args.name
config_dir = parsed_args.config_dir

work_dir = os.path.join(config_dir, name)
config_type = parsed_args.config_type
preserve_config_dir = parsed_args.preserve_config_dir
self.create_config_dir(config_dir, preserve_config_dir)
self.create_config_dir(work_dir, preserve_config_dir)

# Get config
print("Starting config-download export...")
@@ -101,14 +103,14 @@ class DownloadConfig(command.Command):
tarball_contents = f.read()
f.close()
tarball_name = "%s-config.tar.gz" % name
tarball_path = os.path.join(config_dir, tarball_name)
tarball_path = os.path.join(work_dir, tarball_name)

with open(tarball_path, 'wb') as f:
f.write(tarball_contents)

print("Extracting config-download...")
cmd = ['/usr/bin/tar', '-C', config_dir, '-xf', tarball_path]
cmd = ['/usr/bin/tar', '-C', work_dir, '-xf', tarball_path]
processutils.execute(*cmd)

print("The TripleO configuration has been successfully generated "
"into: {0}".format(config_dir))
"into: {0}".format(work_dir))

Loading…
Cancel
Save