Remove plan_management workflows and unused actions

Depends-On: https://review.opendev.org/714354
Change-Id: I21a33f14ca97a1b17468f874b1653d20cc90df68
This commit is contained in:
Rabi Mishra 2020-03-22 20:04:52 +05:30
parent 23423c0976
commit eb41f4103e
6 changed files with 1 additions and 1412 deletions

View File

@ -98,15 +98,12 @@ mistral.actions =
tripleo.derive_params.get_dpdk_core_list = tripleo_common.actions.derive_params:GetDpdkCoreListAction
tripleo.derive_params.get_dpdk_socket_memory = tripleo_common.actions.derive_params:GetDpdkSocketMemoryAction
tripleo.derive_params.get_host_cpus_list = tripleo_common.actions.derive_params:GetHostCpusListAction
tripleo.git.clean = tripleo_common.actions.vcs:GitCleanupAction
tripleo.git.clone = tripleo_common.actions.vcs:GitCloneAction
tripleo.package_update.update_stack = tripleo_common.actions.package_update:UpdateStackAction
tripleo.parameters.get_flatten = tripleo_common.actions.parameters:GetFlattenedParametersAction
tripleo.parameters.get_network_config = tripleo_common.actions.parameters:GetNetworkConfigAction
tripleo.parameters.reset = tripleo_common.actions.parameters:ResetParametersAction
tripleo.parameters.update = tripleo_common.actions.parameters:UpdateParametersAction
tripleo.parameters.update_role = tripleo_common.actions.parameters:UpdateRoleParametersAction
tripleo.parameters.generate_passwords = tripleo_common.actions.parameters:GeneratePasswordsAction
tripleo.parameters.get_profile_of_flavor = tripleo_common.actions.parameters:GetProfileOfFlavorAction
tripleo.parameters.generate_fencing = tripleo_common.actions.parameters:GenerateFencingParametersAction
tripleo.plan.create_container = tripleo_common.actions.plan:CreateContainerAction
@ -119,8 +116,6 @@ mistral.actions =
tripleo.scale.delete_node = tripleo_common.actions.scale:ScaleDownAction
tripleo.swift.tempurl = tripleo_common.actions.swifthelper:SwiftTempUrlAction
tripleo.swift.swift_information = tripleo_common.actions.swifthelper:SwiftInformationAction
tripleo.templates.upload = tripleo_common.actions.templates:UploadTemplatesAction
tripleo.templates.upload_plan_environment = tripleo_common.actions.templates:UploadPlanEnvironmentAction
tripleo.validations.get_pubkey = tripleo_common.actions.validations:GetPubkeyAction
tripleo.validations.get_privkey = tripleo_common.actions.validations:GetPrivkeyAction
tripleo.validations.enabled = tripleo_common.actions.validations:Enabled
@ -132,7 +127,6 @@ mistral.actions =
tripleo.ansible-generate-inventory = tripleo_common.actions.ansible:AnsibleGenerateInventoryAction
# deprecated for pike release, will be removed in queens
tripleo.ansible-playbook = tripleo_common.actions.ansible:AnsiblePlaybookAction
tripleo.templates.upload_default = tripleo_common.actions.templates:UploadTemplatesAction
# deprecated for rocky release, will be removed in the "S" cycle
tripleo.role.list = tripleo_common.actions.plan:ListRolesAction
@ -150,4 +144,4 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes
builtins = _
[pycodestyle]
exclude = .eggs,.tox
exclude = .eggs,.tox

View File

@ -23,7 +23,6 @@ from tripleo_common.actions import base
from tripleo_common import constants
from tripleo_common import exception
from tripleo_common.utils import parameters as parameter_utils
from tripleo_common.utils import plan as plan_utils
from tripleo_common.utils import stack_parameters as stack_param_utils
from tripleo_common.utils import template as template_utils
@ -98,44 +97,6 @@ class UpdateRoleParametersAction(base.TripleOAction):
return actions.Result(six.text_type(err))
class GeneratePasswordsAction(base.TripleOAction):
"""Generates passwords needed for Overcloud deployment
This method generates passwords and ensures they are stored in the
plan environment. By default, this method respects previously
generated passwords and adds new passwords as necessary.
If rotate_passwords is set to True, then passwords will be replaced as
follows:
- if password names are specified in the rotate_pw_list, then only those
passwords will be replaced.
- otherwise, all passwords not in the DO_NOT_ROTATE list (as they require
special handling, like KEKs and Fernet keys) will be replaced.
"""
def __init__(self, container=constants.DEFAULT_CONTAINER_NAME,
rotate_passwords=False,
rotate_pw_list=[]):
super(GeneratePasswordsAction, self).__init__()
self.container = container
self.rotate_passwords = rotate_passwords
self.rotate_pw_list = rotate_pw_list
def run(self, context):
heat = self.get_orchestration_client(context)
swift = self.get_object_client(context)
mistral = self.get_workflow_client(context)
try:
return plan_utils.generate_passwords(
swift, heat, mistral, container=self.container,
rotate_passwords=self.rotate_passwords,
rotate_pw_list=self.rotate_pw_list)
except Exception as err:
LOG.exception(six.text_type(err))
return actions.Result(six.text_type(err))
class GenerateFencingParametersAction(base.TripleOAction):
"""Generates fencing configuration for a deployment.

View File

@ -1,49 +0,0 @@
# Copyright 2016 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tripleo_common.actions import base
from tripleo_common import constants
from tripleo_common.utils import plan as plan_utils
from tripleo_common.utils import template as template_utils
class UploadTemplatesAction(base.TripleOAction):
"""Upload templates directory to Swift."""
def __init__(self, container=constants.DEFAULT_CONTAINER_NAME,
dir_to_upload=constants.DEFAULT_TEMPLATES_PATH):
super(UploadTemplatesAction, self).__init__()
self.container = container
self.dir_to_upload = dir_to_upload
def run(self, context):
swift = self.get_object_client(context)
template_utils.upload_templates_as_tarball(
swift, self.dir_to_upload, self.container)
class UploadPlanEnvironmentAction(base.TripleOAction):
"""Upload the plan environment into swift"""
def __init__(self, plan_environment,
container=constants.DEFAULT_CONTAINER_NAME):
super(UploadPlanEnvironmentAction, self).__init__()
self.container = container
self.plan_environment = plan_environment
def run(self, context):
# Get object client
swift = self.get_object_client(context)
# Push plan environment to the swift container
plan_utils.put_env(swift, self.plan_environment)

View File

@ -1,99 +0,0 @@
# Copyright 2017 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import glob
import logging
import shutil
import tempfile
import six
from mistral_lib import actions
from tripleo_common.utils.safe_import import Repo
LOG = logging.getLogger(__name__)
class GitCloneAction(actions.Action):
"""Clones a remote git repository
:param container: name of the container associated with the plan
:param url: url of git repository
:return: returns local path of cloned git repository
"""
def __init__(self, container, url):
super(GitCloneAction, self).__init__()
self.container = container
self.url = url
def _checkout_reference(self, repo, ref):
return repo.git.checkout(repo.refs[ref])
def run(self, context):
# make a temp directory to contain the repo
local_dir_path = tempfile.mkdtemp(
suffix="_%s_import" % self.container)
url_bits = self.url.rsplit('@')
err_msg = None
try:
# create a bare repo
repo = Repo.clone_from(url_bits[0], local_dir_path)
except Exception:
err_msg = ("Error cloning remote repository: %s " % url_bits[0])
LOG.exception(err_msg)
return actions.Result(error=err_msg)
# if a tag value was given, checkout that tag
if len(url_bits) > 1:
try:
self._checkout_reference(repo, url_bits[-1])
except IndexError:
err_msg = ("Error finding %s reference "
"from remote repository" % url_bits[-1])
LOG.exception(err_msg)
except Exception:
err_msg = ("Error checking out %s reference from remote "
"repository %s" % (url_bits[-1], url_bits[0]))
LOG.exception(err_msg)
if err_msg:
return actions.Result(error=err_msg)
return local_dir_path
class GitCleanupAction(actions.Action):
"""Removes temporary files associated with GitCloneAction operations
:param container: name of the container associated with the plan
:return: None if successful. Returns error on failure to delete
associated temporary files
"""
def __init__(self, container):
self.container = container
def run(self, context):
try:
temp_dir = tempfile.gettempdir()
target_path = '%s/*_%s_import' % (temp_dir, self.container)
path = glob.glob(target_path)[0]
shutil.rmtree(path)
except IndexError as idx_err:
LOG.exception("Directory not found: %s" % target_path)
return actions.Result(error=six.text_type(idx_err))
except OSError as os_err:
LOG.exception("Error removing directory: %s" % target_path)
return actions.Result(error=six.text_type(os_err))

View File

@ -1,140 +0,0 @@
# Copyright 2017 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import shutil
import tempfile
import uuid
from mistral_lib import actions
from tripleo_common.actions import vcs
from tripleo_common.tests import base
from tripleo_common.utils.safe_import import git
class GitCloneActionTest(base.TestCase):
def setUp(self):
super(GitCloneActionTest, self).setUp()
self.temp_url = "/tmp/testdir"
self.git_url = "https://github.com/openstack/tripleo-common.git"
self.tag_ref = "some.test.ref"
self.container = "overcloudtest"
self.ctx = mock.MagicMock()
@mock.patch('tempfile.mkdtemp')
@mock.patch('git.Repo.clone_from')
def test_run(self, mock_repo_clone, mock_mkdtemp):
mock_mkdtemp.return_value = self.temp_url
action = vcs.GitCloneAction(self.container, self.git_url)
action.run(self.ctx)
mock_mkdtemp.assert_called()
mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
@mock.patch('tempfile.mkdtemp')
@mock.patch('git.Repo.clone_from')
def test_run_repo_failure(self, mock_repo_clone, mock_mkdtemp):
mock_mkdtemp.return_value = self.temp_url
mock_repo_clone.side_effect = git.exc.GitCommandError
action = vcs.GitCloneAction(self.container, self.git_url)
result = action.run(self.ctx)
expected = actions.Result(
error="Error cloning remote repository: %s " % self.git_url
)
mock_mkdtemp.assert_called()
mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
self.assertEqual(result, expected)
@mock.patch('tempfile.mkdtemp')
@mock.patch('git.Repo.clone_from')
@mock.patch(
'tripleo_common.actions.vcs.GitCloneAction._checkout_reference')
def test_run_ref_not_found(self, mock_checkout, mock_repo_clone,
mock_mkdtemp):
mock_mkdtemp.return_value = self.temp_url
mock_checkout.side_effect = IndexError
action = vcs.GitCloneAction(
self.container,
"{url}@{tag}".format(url=self.git_url, tag=self.tag_ref)
)
result = action.run(self.ctx)
err_msg = ("Error finding %s reference from remote repository" %
self.tag_ref)
expected = actions.Result(error=err_msg)
self.assertEqual(result, expected, "Error messages don't match.")
mock_mkdtemp.assert_called()
mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
@mock.patch('tempfile.mkdtemp')
@mock.patch('git.Repo.clone_from')
@mock.patch(
'tripleo_common.actions.vcs.GitCloneAction._checkout_reference')
def test_run_ref_checkout_error(self, mock_checkout, mock_repo_clone,
mock_mkdtemp):
mock_mkdtemp.return_value = self.temp_url
mock_checkout.side_effect = git.cmd.GitCommandError
action = vcs.GitCloneAction(
self.container,
"{url}@{tag}".format(url=self.git_url, tag=self.tag_ref)
)
result = action.run(self.ctx)
err_msg = ("Error checking out %s reference from remote "
"repository %s" % (self.tag_ref, self.git_url))
expected = actions.Result(error=err_msg)
self.assertEqual(result, expected, "Error messages don't match.")
mock_mkdtemp.assert_called()
mock_repo_clone.assert_called_with(self.git_url, self.temp_url)
class GitCleanupActionTest(base.TestCase):
def setUp(self):
super(GitCleanupActionTest, self).setUp()
self.container = "overcloud"
self.temp_test_dir = tempfile.mkdtemp(
suffix="_%s_import" % self.container)
self.ctx = mock.MagicMock()
def tearDown(self):
super(GitCleanupActionTest, self).tearDown()
if os.path.exists(self.temp_test_dir):
shutil.rmtree(self.temp_test_dir)
def test_run(self):
action = vcs.GitCleanupAction(self.container)
action.run(self.ctx)
self.assertFalse(os.path.exists(self.temp_test_dir))
def test_run_with_error(self):
action = vcs.GitCleanupAction(str(uuid.uuid4()))
result = action.run(self.ctx)
self.assertIn("list index", str(result.error))

File diff suppressed because it is too large Load Diff