Generate kolla config when running database commands

Change-Id: Ief9adfcff28d269fc80a073cdde536e8e803ca37
Story: 2009648
Task: 43807
This commit is contained in:
Kayobe deployment user 2021-10-28 13:42:24 +00:00 committed by Will Szumski
parent 97a7dc6b22
commit 4321471a13
3 changed files with 92 additions and 8 deletions

View File

@ -1264,6 +1264,10 @@ class OvercloudDatabaseBackup(KollaAnsibleMixin, KayobeAnsibleMixin,
def take_action(self, parsed_args): def take_action(self, parsed_args):
self.app.LOG.debug("Performing overcloud database backup") self.app.LOG.debug("Performing overcloud database backup")
# First prepare configuration.
self.generate_kolla_ansible_config(parsed_args, service_config=False)
extra_args = [] extra_args = []
if parsed_args.incremental: if parsed_args.incremental:
extra_args.append('--incremental') extra_args.append('--incremental')
@ -1288,6 +1292,10 @@ class OvercloudDatabaseRecover(KollaAnsibleMixin, KayobeAnsibleMixin,
def take_action(self, parsed_args): def take_action(self, parsed_args):
self.app.LOG.debug("Performing overcloud database recovery") self.app.LOG.debug("Performing overcloud database recovery")
extra_vars = {} extra_vars = {}
# First prepare configuration.
self.generate_kolla_ansible_config(parsed_args, service_config=True)
if parsed_args.force_recovery_host: if parsed_args.force_recovery_host:
extra_vars['mariadb_recover_inventory_name'] = ( extra_vars['mariadb_recover_inventory_name'] = (
parsed_args.force_recovery_host) parsed_args.force_recovery_host)

View File

@ -1476,14 +1476,27 @@ class TestCase(unittest.TestCase):
] ]
self.assertEqual(expected_calls, mock_kolla_run.call_args_list) self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin, @mock.patch.object(commands.KollaAnsibleMixin,
"run_kolla_ansible_overcloud") "run_kolla_ansible_overcloud")
def test_overcloud_database_backup(self, mock_run): def test_overcloud_database_backup(self, mock_kolla_run, mock_run):
command = commands.OvercloudDatabaseBackup(TestApp(), []) command = commands.OvercloudDatabaseBackup(TestApp(), [])
parser = command.get_parser("test") parser = command.get_parser("test")
parsed_args = parser.parse_args([]) parsed_args = parser.parse_args([])
result = command.run(parsed_args) result = command.run(parsed_args)
self.assertEqual(0, result) self.assertEqual(0, result)
expected_calls = [
mock.call(
mock.ANY,
[utils.get_data_files_path("ansible", "kolla-ansible.yml")],
tags="config",
ignore_limit=True,
),
]
self.assertEqual(expected_calls, mock_run.call_args_list)
expected_calls = [ expected_calls = [
mock.call( mock.call(
mock.ANY, mock.ANY,
@ -1491,16 +1504,30 @@ class TestCase(unittest.TestCase):
extra_args=[] extra_args=[]
), ),
] ]
self.assertEqual(expected_calls, mock_run.call_args_list) self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin, @mock.patch.object(commands.KollaAnsibleMixin,
"run_kolla_ansible_overcloud") "run_kolla_ansible_overcloud")
def test_overcloud_database_backup_incremental(self, mock_run): def test_overcloud_database_backup_incremental(self, mock_kolla_run,
mock_run):
command = commands.OvercloudDatabaseBackup(TestApp(), []) command = commands.OvercloudDatabaseBackup(TestApp(), [])
parser = command.get_parser("test") parser = command.get_parser("test")
parsed_args = parser.parse_args(["--incremental"]) parsed_args = parser.parse_args(["--incremental"])
result = command.run(parsed_args) result = command.run(parsed_args)
self.assertEqual(0, result) self.assertEqual(0, result)
expected_calls = [
mock.call(
mock.ANY,
[utils.get_data_files_path("ansible", "kolla-ansible.yml")],
tags="config",
ignore_limit=True,
),
]
self.assertEqual(expected_calls, mock_run.call_args_list)
expected_calls = [ expected_calls = [
mock.call( mock.call(
mock.ANY, mock.ANY,
@ -1508,16 +1535,37 @@ class TestCase(unittest.TestCase):
extra_args=["--incremental"] extra_args=["--incremental"]
), ),
] ]
self.assertEqual(expected_calls, mock_run.call_args_list) self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin, @mock.patch.object(commands.KollaAnsibleMixin,
"run_kolla_ansible_overcloud") "run_kolla_ansible_overcloud")
def test_overcloud_database_recover(self, mock_run): def test_overcloud_database_recover(self, mock_kolla_run, mock_run):
command = commands.OvercloudDatabaseRecover(TestApp(), []) command = commands.OvercloudDatabaseRecover(TestApp(), [])
parser = command.get_parser("test") parser = command.get_parser("test")
parsed_args = parser.parse_args([]) parsed_args = parser.parse_args([])
result = command.run(parsed_args) result = command.run(parsed_args)
self.assertEqual(0, result) self.assertEqual(0, result)
expected_calls = [
mock.call(
mock.ANY,
[utils.get_data_files_path("ansible", "kolla-ansible.yml")],
tags="config",
ignore_limit=True,
),
mock.call(
mock.ANY,
[
utils.get_data_files_path("ansible",
"kolla-openstack.yml"),
],
ignore_limit=True,
),
]
self.assertEqual(expected_calls, mock_run.call_args_list)
expected_calls = [ expected_calls = [
mock.call( mock.call(
mock.ANY, mock.ANY,
@ -1525,16 +1573,38 @@ class TestCase(unittest.TestCase):
extra_vars={} extra_vars={}
), ),
] ]
self.assertEqual(expected_calls, mock_run.call_args_list) self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin, @mock.patch.object(commands.KollaAnsibleMixin,
"run_kolla_ansible_overcloud") "run_kolla_ansible_overcloud")
def test_overcloud_database_recover_force_host(self, mock_run): def test_overcloud_database_recover_force_host(self, mock_kolla_run,
mock_run):
command = commands.OvercloudDatabaseRecover(TestApp(), []) command = commands.OvercloudDatabaseRecover(TestApp(), [])
parser = command.get_parser("test") parser = command.get_parser("test")
parsed_args = parser.parse_args(["--force-recovery-host", "foo"]) parsed_args = parser.parse_args(["--force-recovery-host", "foo"])
result = command.run(parsed_args) result = command.run(parsed_args)
self.assertEqual(0, result) self.assertEqual(0, result)
expected_calls = [
mock.call(
mock.ANY,
[utils.get_data_files_path("ansible", "kolla-ansible.yml")],
tags="config",
ignore_limit=True,
),
mock.call(
mock.ANY,
[
utils.get_data_files_path("ansible",
"kolla-openstack.yml"),
],
ignore_limit=True,
),
]
self.assertEqual(expected_calls, mock_run.call_args_list)
expected_calls = [ expected_calls = [
mock.call( mock.call(
mock.ANY, mock.ANY,
@ -1544,7 +1614,7 @@ class TestCase(unittest.TestCase):
} }
), ),
] ]
self.assertEqual(expected_calls, mock_run.call_args_list) self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin, @mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks") "run_kayobe_playbooks")

View File

@ -0,0 +1,6 @@
---
fixes:
- |
The set of commands starting with ``kayobe overcloud database`` now
generate the kolla configuration necessary to login to the nodes
running the database.