Merge "Add arg to remove config-dir for config-download"

This commit is contained in:
Zuul 2018-04-21 07:50:35 +00:00 committed by Gerrit Code Review
commit 896ccdfe14
2 changed files with 30 additions and 3 deletions

View File

@ -32,9 +32,24 @@ class TestOvercloudConfig(utils.TestCommand):
arglist = ['--name', 'overcloud', '--config-dir', '/tmp']
verifylist = [
('name', 'overcloud'),
('config_dir', '/tmp')
('config_dir', '/tmp'),
('preserve_config_dir', True)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_config.assert_called_once_with('overcloud', '/tmp', None)
mock_config.assert_called_once_with('overcloud', '/tmp', None, True)
@mock.patch('tripleo_common.utils.config.Config.download_config')
def test_overcloud_download_config_no_preserve(self, mock_config):
arglist = ['--name', 'overcloud', '--config-dir', '/tmp',
'--no-preserve-config']
verifylist = [
('name', 'overcloud'),
('config_dir', '/tmp'),
('preserve_config_dir', False)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
mock_config.assert_called_once_with('overcloud', '/tmp', None, False)

View File

@ -49,6 +49,16 @@ class DownloadConfig(command.Command):
help=_('Type of object config to be extract from the deployment, '
'defaults to all keys available'),
)
parser.add_argument(
'--no-preserve-config',
dest='preserve_config_dir',
action='store_false',
default=True,
help=('If specified, will delete and recreate the --config-dir '
'if it already exists. Default is to use the existing dir '
'location and overwrite files. Files in --config-dir not '
'from the stack will be preserved by default.')
)
return parser
def take_action(self, parsed_args):
@ -59,8 +69,10 @@ class DownloadConfig(command.Command):
name = parsed_args.name
config_dir = parsed_args.config_dir
config_type = parsed_args.config_type
preserve_config_dir = parsed_args.preserve_config_dir
# Get config
config = ooo_config.Config(clients.orchestration)
config_path = config.download_config(name, config_dir, config_type)
config_path = config.download_config(name, config_dir, config_type,
preserve_config_dir)
print("The TripleO configuration has been successfully generated "
"into: {0}".format(config_path))