Add arg to remove config-dir for config-download
Adds an argument to config-download that removes the config-dir and contents before downloading the config, if it exists. Related-Bug: 1752118 Depends-On: Ie00f71b12f56262985c47810be0e80402e9e558e Depends-On: Ibb59b044dc0c14bf48dc3d500536195230414c81 Change-Id: I68a72e11dd66d8d5100512683633caa2174f9e6b
This commit is contained in:
parent
8d26f89ebd
commit
fb19922ad2
@ -32,9 +32,24 @@ class TestOvercloudConfig(utils.TestCommand):
|
|||||||
arglist = ['--name', 'overcloud', '--config-dir', '/tmp']
|
arglist = ['--name', 'overcloud', '--config-dir', '/tmp']
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('name', 'overcloud'),
|
('name', 'overcloud'),
|
||||||
('config_dir', '/tmp')
|
('config_dir', '/tmp'),
|
||||||
|
('preserve_config_dir', True)
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
self.cmd.take_action(parsed_args)
|
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)
|
||||||
|
@ -49,6 +49,16 @@ class DownloadConfig(command.Command):
|
|||||||
help=_('Type of object config to be extract from the deployment, '
|
help=_('Type of object config to be extract from the deployment, '
|
||||||
'defaults to all keys available'),
|
'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
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -59,8 +69,10 @@ class DownloadConfig(command.Command):
|
|||||||
name = parsed_args.name
|
name = parsed_args.name
|
||||||
config_dir = parsed_args.config_dir
|
config_dir = parsed_args.config_dir
|
||||||
config_type = parsed_args.config_type
|
config_type = parsed_args.config_type
|
||||||
|
preserve_config_dir = parsed_args.preserve_config_dir
|
||||||
# Get config
|
# Get config
|
||||||
config = ooo_config.Config(clients.orchestration)
|
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 "
|
print("The TripleO configuration has been successfully generated "
|
||||||
"into: {0}".format(config_path))
|
"into: {0}".format(config_path))
|
||||||
|
Loading…
Reference in New Issue
Block a user