Update ceph-ansible playbook path in parameter default for update
We need to provide an option to let the user change the default ansible playbook path for ceph-ansible update. Closes-Bug: #1723428 Change-Id: I42f1583acfb10747d447372001b1a046d68d7577
This commit is contained in:
parent
83cb7d897f
commit
35e7c136cd
@ -109,6 +109,7 @@ mistral.actions =
|
||||
tripleo.plan.list = tripleo_common.actions.plan:ListPlansAction
|
||||
tripleo.plan.export = tripleo_common.actions.plan:ExportPlanAction
|
||||
tripleo.plan.update_from_dir = tripleo_common.actions.plan:UpdatePlanFromDirAction
|
||||
tripleo.plan.update_plan_environment = tripleo_common.actions.plan:UpdatePlanEnvironmentAction
|
||||
tripleo.logging_to_swift.format_messages = tripleo_common.actions.logging_to_swift:FormatMessagesAction
|
||||
tripleo.logging_to_swift.publish_ui_log_to_swift = tripleo_common.actions.logging_to_swift:PublishUILogToSwiftAction
|
||||
tripleo.logging_to_swift.prepare_log_download = tripleo_common.actions.logging_to_swift:PrepareLogDownloadAction
|
||||
|
@ -28,11 +28,12 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class UpdateStackAction(templates.ProcessTemplatesAction):
|
||||
|
||||
def __init__(self, timeout, container_registry,
|
||||
def __init__(self, timeout, container_registry, ceph_ansible_playbook,
|
||||
container=constants.DEFAULT_CONTAINER_NAME):
|
||||
super(UpdateStackAction, self).__init__(container)
|
||||
self.timeout_mins = timeout
|
||||
self.container_registry = container_registry
|
||||
self.ceph_ansible_playbook = ceph_ansible_playbook
|
||||
|
||||
def run(self, context):
|
||||
# get the stack. Error if doesn't exist
|
||||
@ -76,11 +77,12 @@ class UpdateStackAction(templates.ProcessTemplatesAction):
|
||||
noop_env['resource_registry'].update(role_env)
|
||||
update_env.update(noop_env)
|
||||
template_utils.deep_update(env, update_env)
|
||||
|
||||
# Update parameters
|
||||
parameters = {}
|
||||
if self.container_registry is not None:
|
||||
parameters.update(self.container_registry['parameter_defaults'])
|
||||
if self.ceph_ansible_playbook:
|
||||
parameters.update({'CephAnsiblePlaybook': '%s' %
|
||||
self.ceph_ansible_playbook})
|
||||
plan_utils.update_in_env(swift, env, 'parameter_defaults', parameters)
|
||||
|
||||
# process all plan files and create or update a stack
|
||||
|
@ -26,6 +26,7 @@ from swiftclient import exceptions as swiftexceptions
|
||||
from tripleo_common.actions import base
|
||||
from tripleo_common import constants
|
||||
from tripleo_common import exception
|
||||
from tripleo_common.utils import plan as plan_utils
|
||||
from tripleo_common.utils import swift as swiftutils
|
||||
from tripleo_common.utils import tarball
|
||||
from tripleo_common.utils.validations import pattern_validator
|
||||
@ -259,3 +260,58 @@ class UpdatePlanFromDirAction(base.TripleOAction):
|
||||
except Exception as err:
|
||||
msg = "Error while updating plan: %s" % err
|
||||
return actions.Result(error=msg)
|
||||
|
||||
|
||||
class UpdatePlanEnvironmentAction(base.TripleOAction):
|
||||
"""Updates the plan environment values
|
||||
|
||||
Updates a plan environment values with the given parameters:
|
||||
Add new parameter
|
||||
Delete parameter
|
||||
|
||||
:param parameter: key value of the parameter to add or delete
|
||||
:param value: value of the parameter to add or delete
|
||||
:param delete: True if the parameter should be deleted from the env
|
||||
:param env_key: environment key that should be one of the keys present
|
||||
in the plan environment dictionary:
|
||||
'passwords',
|
||||
'description',
|
||||
'parameter_defaults',
|
||||
'environments',
|
||||
'version',
|
||||
'template',
|
||||
'resource_registry',
|
||||
'name'
|
||||
:param container: name of the Swift container / plan name
|
||||
"""
|
||||
|
||||
def __init__(self, parameter, env_key, value=None, delete=False,
|
||||
container=constants.DEFAULT_CONTAINER_NAME):
|
||||
super(UpdatePlanEnvironmentAction, self).__init__()
|
||||
self.container = container
|
||||
self.parameter = parameter
|
||||
self.value = value
|
||||
self.delete = delete
|
||||
self.env_key = env_key
|
||||
|
||||
def run(self, context):
|
||||
try:
|
||||
swift = self.get_object_client(context)
|
||||
plan_env = plan_utils.get_env(swift, self.container)
|
||||
if self.env_key in plan_env.keys():
|
||||
if self.delete:
|
||||
try:
|
||||
plan_env[self.env_key].pop(self.parameter)
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
plan_env[self.env_key].update({self.parameter: self.value})
|
||||
else:
|
||||
msg = "The environment key doesn't exist: %s" % self.env_key
|
||||
return actions.Result(error=msg)
|
||||
except swiftexceptions.ClientException as err:
|
||||
msg = "Error attempting an operation on container: %s" % err
|
||||
return actions.Result(error=msg)
|
||||
except Exception as err:
|
||||
msg = "Error while updating plan: %s" % err
|
||||
return actions.Result(error=msg)
|
||||
|
@ -97,7 +97,6 @@ class UpdateStackActionTest(base.TestCase):
|
||||
|
||||
update_env = {'resource_registry':
|
||||
{'OS::TripleO::DeploymentSteps': 'OS::Heat::None'}}
|
||||
|
||||
mock_getenv.return_value = env
|
||||
fake_registry = {'parameter_defaults':
|
||||
{'DockerKeystoneImage': '192.168.24.1:8787/'
|
||||
@ -109,7 +108,8 @@ class UpdateStackActionTest(base.TestCase):
|
||||
mock_object_client.return_value = mock_swift
|
||||
|
||||
action = package_update.UpdateStackAction(self.timeout, fake_registry,
|
||||
container=self.container)
|
||||
container=self.container,
|
||||
ceph_ansible_playbook=None)
|
||||
action.run(mock_ctx)
|
||||
mock_updateinenv.assert_called_once_with(
|
||||
mock_swift, env, 'parameter_defaults',
|
||||
|
@ -12,6 +12,7 @@ workflows:
|
||||
input:
|
||||
- container
|
||||
- container_registry
|
||||
- ceph_ansible_playbook
|
||||
- timeout: 240
|
||||
- queue_name: tripleo
|
||||
- skip_deploy_identifier: False
|
||||
@ -29,11 +30,22 @@ workflows:
|
||||
on-error: set_update_failed
|
||||
|
||||
update:
|
||||
action: tripleo.package_update.update_stack container=<% $.container %> timeout=<% $.timeout %> container_registry=<% $.container_registry %>
|
||||
action: tripleo.package_update.update_stack container=<% $.container %> timeout=<% $.timeout %> container_registry=<% $.container_registry %> ceph_ansible_playbook=<% $.ceph_ansible_playbook %>
|
||||
input:
|
||||
timeout: <% $.timeout %>
|
||||
container: <% $.container %>
|
||||
container_registry: <% $.container_registry %>
|
||||
ceph_ansible_playbook: <% $.ceph_ansible_playbook %>
|
||||
on-success: clean_plan
|
||||
on-error: set_update_failed
|
||||
|
||||
clean_plan:
|
||||
action: tripleo.plan.update_plan_environment
|
||||
input:
|
||||
container: <% $.container %>
|
||||
parameter: CephAnsiblePlaybook
|
||||
env_key: parameter_defaults
|
||||
delete: true
|
||||
on-success: get_config
|
||||
on-error: set_update_failed
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user