Merge "[train-only] Add ipa config check to _cleanup_ipa" into stable/train
This commit is contained in:
commit
3d8e33fcaf
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from tripleoclient import exceptions
|
||||||
from tripleoclient.tests.v1.overcloud_deploy import fakes
|
from tripleoclient.tests.v1.overcloud_deploy import fakes
|
||||||
from tripleoclient.v1 import overcloud_delete
|
from tripleoclient.v1 import overcloud_delete
|
||||||
|
|
||||||
|
@ -143,3 +144,25 @@ class TestDeleteOvercloud(fakes.TestDeployOvercloud):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
mock_overcloud_delete.assert_not_called()
|
mock_overcloud_delete.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch('os.path.exists')
|
||||||
|
@mock.patch('tripleoclient.utils.get_tripleo_ansible_inventory')
|
||||||
|
def test_skip_ipa_cleanup_without_inventory(self, inventory_mock, os_mock):
|
||||||
|
arglist = ["overcloud", "-y"]
|
||||||
|
verifylist = [
|
||||||
|
("stack", "overcloud"),
|
||||||
|
("yes", True)
|
||||||
|
]
|
||||||
|
|
||||||
|
os_mock.return_value = True
|
||||||
|
inventory_mock.side_effect = exceptions.InvalidConfiguration()
|
||||||
|
self.cmd.log.warning = mock.MagicMock()
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.cmd.log.warning.assert_called_with(
|
||||||
|
"Unable to generate the necessary ansible inventory required to "
|
||||||
|
"cleanup IPA. Ignoring IPA cleanup. Please cleanup IPA resources "
|
||||||
|
"for overcloud stack manually."
|
||||||
|
)
|
||||||
|
|
|
@ -26,6 +26,7 @@ from osc_lib import utils as osc_utils
|
||||||
|
|
||||||
from tripleoclient import command
|
from tripleoclient import command
|
||||||
from tripleoclient import constants
|
from tripleoclient import constants
|
||||||
|
from tripleoclient import exceptions
|
||||||
from tripleoclient import utils
|
from tripleoclient import utils
|
||||||
from tripleoclient.workflows import plan_management
|
from tripleoclient.workflows import plan_management
|
||||||
from tripleoclient.workflows import stack_management
|
from tripleoclient.workflows import stack_management
|
||||||
|
@ -101,6 +102,14 @@ class DeleteOvercloud(command.Command):
|
||||||
python_interpreter = \
|
python_interpreter = \
|
||||||
"/usr/bin/python{}".format(sys.version_info[0])
|
"/usr/bin/python{}".format(sys.version_info[0])
|
||||||
playbook = '/usr/share/ansible/tripleo-playbooks/cli-cleanup-ipa.yml'
|
playbook = '/usr/share/ansible/tripleo-playbooks/cli-cleanup-ipa.yml'
|
||||||
|
ipa_config = '/etc/ipa/default.conf'
|
||||||
|
|
||||||
|
if not os.path.exists(ipa_config):
|
||||||
|
self.log.debug(
|
||||||
|
"{} doesn't exist on system. "
|
||||||
|
"Ignoring IPA cleanup.".format(playbook)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
if not os.path.exists(playbook):
|
if not os.path.exists(playbook):
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
|
@ -109,8 +118,16 @@ class DeleteOvercloud(command.Command):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
static_inventory = utils.get_tripleo_ansible_inventory(
|
try:
|
||||||
return_inventory_file_path=True)
|
static_inventory = utils.get_tripleo_ansible_inventory(
|
||||||
|
return_inventory_file_path=True)
|
||||||
|
except exceptions.InvalidConfiguration:
|
||||||
|
self.log.warning(
|
||||||
|
"Unable to generate the necessary ansible inventory required "
|
||||||
|
"to cleanup IPA. Ignoring IPA cleanup. Please cleanup IPA "
|
||||||
|
"resources for {} stack manually.".format(stack_name)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# We don't technically need remote_user to generate an ansible.cfg for
|
# We don't technically need remote_user to generate an ansible.cfg for
|
||||||
# stack. The write_default_ansible_cfg() method treats this as an
|
# stack. The write_default_ansible_cfg() method treats this as an
|
||||||
|
|
Loading…
Reference in New Issue