Add kayobe overcloud service prechecks command

Runs 'kolla-ansible prechecks' without deploying services.

Change-Id: I3806b707593fc6ac9d7125e1b12d716ad40a2808
Story: 2008912
Task: 42503
This commit is contained in:
Mark Goddard 2021-05-21 11:17:39 +01:00
parent 211c68aa6c
commit b398e28dc5
5 changed files with 81 additions and 0 deletions

View File

@ -130,6 +130,18 @@ and/or kolla-ansible::
(kayobe) $ kayobe overcloud service upgrade --tags config --kolla-tags keystone
Running Prechecks
=================
Sometimes it may be useful to run prechecks without deploying services::
(kayobe) $ kayobe overcloud service prechecks
As for other similar commands, it is possible to specify tags for Kayobe and/or
kolla-ansible::
(kayobe) $ kayobe overcloud service upgrade --tags config --kolla-tags keystone
Stopping the Overcloud Services
===============================

View File

@ -1283,6 +1283,29 @@ class OvercloudServiceDeployContainers(KollaAnsibleMixin, KayobeAnsibleMixin,
extra_vars=extra_vars, limit="overcloud")
class OvercloudServicePrechecks(KollaAnsibleMixin, KayobeAnsibleMixin,
VaultMixin, Command):
"""Run prechecks against overcloud services.
* Configure kolla-ansible.
* Configure overcloud services in kolla-ansible.
* Perform kolla-ansible prechecks to verify the system state for
deployment.
This can be used in conjunction with the --tags and --kolla-tags arguments
to check specific services.
"""
def take_action(self, parsed_args):
self.app.LOG.debug("Running overcloud prechecks")
# First prepare configuration.
self.generate_kolla_ansible_config(parsed_args)
# Run the kolla-ansible prechecks.
self.run_kolla_ansible_overcloud(parsed_args, "prechecks")
class OvercloudServiceReconfigure(KollaAnsibleMixin, KayobeAnsibleMixin,
VaultMixin, Command):
"""Reconfigure the overcloud services.

View File

@ -1426,6 +1426,44 @@ class TestCase(unittest.TestCase):
]
self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin,
"run_kolla_ansible_overcloud")
def test_overcloud_service_prechecks(self, mock_kolla_run, mock_run):
command = commands.OvercloudServicePrechecks(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", "kolla-ansible.yml")],
ignore_limit=True,
tags="config",
),
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 = [
mock.call(
mock.ANY,
"prechecks",
),
]
self.assertEqual(expected_calls, mock_kolla_run.call_args_list)
@mock.patch.object(commands.KayobeAnsibleMixin,
"run_kayobe_playbooks")
@mock.patch.object(commands.KollaAnsibleMixin,

View File

@ -0,0 +1,5 @@
---
features:
- |
Adds a new ``kayobe overcloud service prechecks`` command to run Kolla
Ansible prechecks without deploying services.

View File

@ -72,6 +72,7 @@ kayobe.cli=
overcloud_service_deploy = kayobe.cli.commands:OvercloudServiceDeploy
overcloud_service_deploy_containers = kayobe.cli.commands:OvercloudServiceDeployContainers
overcloud_service_destroy = kayobe.cli.commands:OvercloudServiceDestroy
overcloud_service_prechecks = kayobe.cli.commands:OvercloudServicePrechecks
overcloud_service_reconfigure = kayobe.cli.commands:OvercloudServiceReconfigure
overcloud_service_stop = kayobe.cli.commands:OvercloudServiceStop
overcloud_service_upgrade = kayobe.cli.commands:OvercloudServiceUpgrade
@ -159,6 +160,8 @@ kayobe.cli.overcloud_service_deploy_containers =
hooks = kayobe.cli.commands:HookDispatcher
kayobe.cli.overcloud_service_destroy =
hooks = kayobe.cli.commands:HookDispatcher
kayobe.cli.overcloud_service_prechecks =
hooks = kayobe.cli.commands:HookDispatcher
kayobe.cli.overcloud_service_reconfigure =
hooks = kayobe.cli.commands:HookDispatcher
kayobe.cli.overcloud_service_stop =