From ba0de393c4db961a2c5d63807101827c74e0a53c Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 3 Jul 2018 10:27:16 +0100 Subject: [PATCH] Select default "openstack" plan when no plan-environment.yaml found To avoid having a duplicate plan-environment and capabilities-map in the root of the container as initially proposed in https://review.openstack.org/#/c/574753/, we check for a user provided plan-environment.yaml and when none is found we select the default "openstack" plan. Change-Id: Ie26c2df437759a1b99c2498c9ba3039e2ac1c4ae --- workbooks/plan_management.yaml | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/workbooks/plan_management.yaml b/workbooks/plan_management.yaml index 033fc7721..8f3ca0b14 100644 --- a/workbooks/plan_management.yaml +++ b/workbooks/plan_management.yaml @@ -107,6 +107,18 @@ workflows: on-error: upload_to_container_set_status_failed create_plan: + on-success: + - ensure_plan_environment_exists + + # This selects the default "openstack" sample plan if no user + # provided plan-environment.yaml or capabilities-map.yaml exists + # Note in the case where a user provided plan-environment.yaml + # exists we'll still copy the missing capabilities-map.yaml + ensure_plan_environment_exists: + workflow: tripleo.plan_management.v1._check_plan_environment + input: + container: <% $.container %> + queue_name: <% queue_name %> on-success: - ensure_passwords_exist: <% $.generate_passwords = true %> - add_root_stack_name: <% $.generate_passwords != true %> @@ -193,6 +205,42 @@ workflows: message: <% $.get('message', '') %> deployment_status: UNDEPLOYED + _check_plan_environment: + input: + - container + - queue_name + tags: + - tripleo-common-managed + tasks: + check_for_plan_env: + workflow: tripleo.swift.v1.object_exists + input: + container: <% $.container %> + object: plan-environment.yaml + on-error: select_default_sample_plan + on-success: check_for_capabilities_map + + check_for_capabilities_map: + workflow: tripleo.swift.v1.object_exists + input: + container: <% $.container %> + object: capabilities-map.yaml + on-error: select_default_sample_plan + + # If there's no existing or user-defined plan-environment.yaml + # We run select_default_sample_plan with the default sample_plan_name + # to select the openstack default openstack plan + # Note in the case where plan-environment.yaml exists we'll skip + # copying that and only copy the capabilities-map.yaml, which is + # needed when a user provides a plan-environment.yaml - to select + # a new sample plan it will be necessary to delete both files + # from the root of the plan. + select_default_sample_plan: + workflow: tripleo.plan_management.v1.select_sample_plan + input: + container: <% $.container %> + queue_name: <% queue_name %> + update_deployment_plan: input: - container @@ -1287,6 +1335,14 @@ workflows: - tripleo-common-managed tasks: + # We skip any files where the root object already exists + check_for_existing_object: + workflow: tripleo.swift.v1.object_exists + input: + container: <% $.container %> + object: <% $.object_name.split('/').last() %> + on-error: copy_object + copy_object: action: swift.copy_object input: