Merge "Support including and excluding files from config save"
This commit is contained in:
commit
6ef26e30a0
@ -15,6 +15,8 @@
|
||||
find:
|
||||
paths: "{{ node_config_directory }}"
|
||||
recurse: True
|
||||
excludes: "{{ exclude_patterns | default(omit) }}"
|
||||
patterns: "{{ include_patterns | default(omit) }}"
|
||||
register: find_result
|
||||
become: true
|
||||
|
||||
|
@ -353,11 +353,9 @@ function overcloud_upgrade {
|
||||
fi
|
||||
|
||||
echo "Saving overcloud service configuration"
|
||||
if ! run_kayobe overcloud service configuration save; then
|
||||
# NOTE(mgoddard): This fails in CI due to a memory error while copying
|
||||
# the IPA deployment images.
|
||||
echo "FIXME: Saving service configuration failed. Ignoring for now"
|
||||
fi
|
||||
# Don't copy the ironic IPA kernel and ramdisk, since these files can be
|
||||
# quite large.
|
||||
run_kayobe overcloud service configuration save --exclude 'ironic-agent.*'
|
||||
|
||||
echo "Deploying containerised overcloud services"
|
||||
run_kayobe overcloud service upgrade
|
||||
|
@ -952,6 +952,12 @@ class OvercloudServiceConfigurationSave(KayobeAnsibleMixin, VaultMixin,
|
||||
parser = super(OvercloudServiceConfigurationSave, self).get_parser(
|
||||
prog_name)
|
||||
group = parser.add_argument_group("Service configuration")
|
||||
group.add_argument("--exclude",
|
||||
help="optional comma-separated list of patterns "
|
||||
"matching filenames to exclude")
|
||||
group.add_argument("--include",
|
||||
help="optional comma-separated list of patterns "
|
||||
"matching filenames to include")
|
||||
group.add_argument("--node-config-dir",
|
||||
help="the directory to store the config files on "
|
||||
"the remote node (default /etc/kolla)")
|
||||
@ -964,6 +970,10 @@ class OvercloudServiceConfigurationSave(KayobeAnsibleMixin, VaultMixin,
|
||||
self.app.LOG.debug("Saving overcloud service configuration")
|
||||
playbooks = _build_playbook_list("overcloud-service-config-save")
|
||||
extra_vars = {}
|
||||
if parsed_args.exclude:
|
||||
extra_vars["exclude_patterns"] = parsed_args.exclude
|
||||
if parsed_args.include:
|
||||
extra_vars["include_patterns"] = parsed_args.include
|
||||
if parsed_args.output_dir:
|
||||
extra_vars["config_save_path"] = parsed_args.output_dir
|
||||
if parsed_args.node_config_dir:
|
||||
|
@ -1165,6 +1165,56 @@ class TestCase(unittest.TestCase):
|
||||
]
|
||||
self.assertEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_overcloud_service_configuration_save(self, mock_run):
|
||||
command = commands.OvercloudServiceConfigurationSave(TestApp(), [])
|
||||
parser = command.get_parser("test")
|
||||
parsed_args = parser.parse_args([])
|
||||
result = command.run(parsed_args)
|
||||
self.assertEqual(0, result)
|
||||
expected_calls = [
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
[
|
||||
utils.get_data_files_path(
|
||||
"ansible", "overcloud-service-config-save.yml"),
|
||||
],
|
||||
extra_vars={}
|
||||
),
|
||||
]
|
||||
self.assertEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_overcloud_service_configuration_save_args(self, mock_run):
|
||||
command = commands.OvercloudServiceConfigurationSave(TestApp(), [])
|
||||
parser = command.get_parser("test")
|
||||
parsed_args = parser.parse_args([
|
||||
"--exclude", "exclude1,exclude2",
|
||||
"--include", "include1,include2",
|
||||
"--node-config-dir", "/path/to/config",
|
||||
"--output-dir", "/path/to/output",
|
||||
])
|
||||
result = command.run(parsed_args)
|
||||
self.assertEqual(0, result)
|
||||
expected_calls = [
|
||||
mock.call(
|
||||
mock.ANY,
|
||||
[
|
||||
utils.get_data_files_path(
|
||||
"ansible", "overcloud-service-config-save.yml"),
|
||||
],
|
||||
extra_vars={
|
||||
"exclude_patterns": "exclude1,exclude2",
|
||||
"include_patterns": "include1,include2",
|
||||
"config_save_path": "/path/to/output",
|
||||
"node_config_directory": "/path/to/config",
|
||||
}
|
||||
),
|
||||
]
|
||||
self.assertEqual(expected_calls, mock_run.call_args_list)
|
||||
|
||||
@mock.patch.object(commands.KayobeAnsibleMixin,
|
||||
"run_kayobe_playbooks")
|
||||
def test_overcloud_container_image_build(self, mock_run):
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds support for including or excluding files from the output of ``kayobe
|
||||
overcloud service configuration save``. This is particularly useful for
|
||||
large files such as the Ironic IPA images.
|
Loading…
x
Reference in New Issue
Block a user