From 6743cc35ae479ae0d445a709bd9a67aa898752b0 Mon Sep 17 00:00:00 2001 From: Saravanan KR Date: Fri, 16 Feb 2018 15:52:19 +0530 Subject: [PATCH] Provide the output to add a validation for role-specific params on services In order to provide role-specific parameters for a service, "Parameters" should be used to provide the actual parameter to be applied to a specific role (in the parameter_defaults of user's environment file). Parameters require special implementation to support role-specific in a service. This workflow validates the user provided role-specific parameters with the actual implementation and provides the invalid ones. The actual role-specific parameters on a template could be found using the 'tags' attribute of a parameter in the heat template. Change-Id: Ie0abc345cea4a69b19b2ea760a29a2cab61c1ceb (cherry picked from commit 8586cc1542e894e52767507e1ec87f3d9ac95e03) --- ...-specific-validation-5ea0a31711ced6fe.yaml | 3 ++ workbooks/plan_management.yaml | 44 ++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/role-specific-validation-5ea0a31711ced6fe.yaml diff --git a/releasenotes/notes/role-specific-validation-5ea0a31711ced6fe.yaml b/releasenotes/notes/role-specific-validation-5ea0a31711ced6fe.yaml new file mode 100644 index 000000000..7619d0f0f --- /dev/null +++ b/releasenotes/notes/role-specific-validation-5ea0a31711ced6fe.yaml @@ -0,0 +1,3 @@ +--- +features: + - Added role-specific parameter validation workflow. diff --git a/workbooks/plan_management.yaml b/workbooks/plan_management.yaml index 358014f29..bda6f967d 100644 --- a/workbooks/plan_management.yaml +++ b/workbooks/plan_management.yaml @@ -504,6 +504,15 @@ workflows: - tripleo-common-managed tasks: + get_roles: + action: tripleo.role.list container=<% $.container %> + publish: + role_name_list: <% task().result %> + on-success: + - get_flatten_data: <% $.role_name_list %> + - set_status_failed_get_roles: <% not $.role_name_list %> + on-error: set_status_failed_on_error_get_roles + get_flatten_data: action: tripleo.parameters.get_flatten container=<% $.container %> on-success: get_deprecated_params @@ -512,6 +521,8 @@ workflows: user_params: <% task().result.environment_parameters %> plan_params: <% task().result.heat_resource_tree.parameters.keys() %> parameter_groups: <% task().result.heat_resource_tree.resources.values().where( $.get('parameter_groups') ).select($.parameter_groups).flatten() %> + params_role_specific_tag: <% task().result.heat_resource_tree.parameters.values().where( $.get('tags') and $.get('tags').contains('role_specific') ).select($.name).flatten() %> + valid_role_name_list: <% let(hr => task().result.heat_resource_tree.parameters) -> $.role_name_list.where(int($hr.get(concat($, 'Count'), {}).get('default', 0)) > 0) %> get_deprecated_params: on-success: check_if_user_param_has_deprecated @@ -527,16 +538,46 @@ workflows: # It may be possible that the parameter will be used by a service, but the service is not part of the plan. # In such cases, the parameter will be reported as unused, care should be take to understand whether it is really unused or not. get_unused_params: - on-success: send_message + on-success: get_user_role_params publish: unused_params: <% let(plan_params => $.plan_params) -> $.user_params.keys().where( not $plan_params.contains($) ) %> + get_user_role_params: + on-success: is_user_role_specific_input_provided + with-items: role_name in <% $.valid_role_name_list %> + concurrency: 1 + action: std.echo output=<% "{}Parameters".format($.role_name) %> + publish: + user_provided_role_specific: <% let(param => task().result) -> $.user_params.items().where( $param.contains($[0]) ).select( $[1] ).flatten() %> + + is_user_role_specific_input_provided: + on-success: + - find_invalid_role_specific_params: <% $.user_provided_role_specific %> + - send_message: <% not $.user_provided_role_specific %> + + find_invalid_role_specific_params: + on-success: send_message + publish: + invalid_role_specific: <% let(role_spec => $.params_role_specific_tag) -> $.user_provided_role_specific.sum().keys().where( not $role_spec.contains($) ) %> + set_status_failed_get_flatten_data: on-success: send_message publish: status: FAILED message: <% task(get_flatten_data).result %> + set_status_failed_get_roles: + on-success: send_message + publish: + status: FAILED + message: "Unable to determine the list of roles in the deployment plan" + + set_status_failed_on_error_get_roles: + on-success: send_message + publish: + status: FAILED + message: <% task(get_roles).result %> + send_message: action: zaqar.queue_post input: @@ -550,6 +591,7 @@ workflows: execution: <% execution() %> deprecated: <% $.get('deprecated_result', []) %> unused: <% $.get('unused_params', []) %> + invalid_role_specific: <% $.get('invalid_role_specific', []) %> on-success: - fail: <% $.get('status') = "FAILED" %>