diff --git a/workbooks/deployment.yaml b/workbooks/deployment.yaml index 2c34cf093..d523b321d 100644 --- a/workbooks/deployment.yaml +++ b/workbooks/deployment.yaml @@ -122,7 +122,7 @@ workflows: queue_name: <% $.queue_name %> on-complete: - run_validations: <% $.run_validations %> - - check_container: <% not $.run_validations %> + - create_swift_rings_backup_plan: <% not $.run_validations %> run_validations: workflow: tripleo.validations.v1.run_groups @@ -131,7 +131,7 @@ workflows: - 'pre-deployment' plan: <% $.container %> queue_name: <% $.queue_name %> - on-success: check_container + on-success: create_swift_rings_backup_plan on-error: set_validations_failed set_validations_failed: @@ -140,45 +140,14 @@ workflows: status: FAILED message: <% task(run_validations).result %> - check_container: - action: swift.head_container container=<% $.container %> - on-success: get_tempurl - on-error: create_container - - create_container: - action: tripleo.plan.create_container container="<% $.container %>-swift-rings" - on-success: get_tempurl - - get_tempurl: - action: tripleo.swift.tempurl - on-success: set_get_tempurl - input: - container: "<% $.container %>-swift-rings" - obj: "swift-rings.tar.gz" - - set_get_tempurl: - action: tripleo.parameters.update - input: - parameters: - SwiftRingGetTempurl: <% task(get_tempurl).result %> - container: <% $.container %> - on-success: put_tempurl - - put_tempurl: - action: tripleo.swift.tempurl - on-success: set_put_tempurl - input: - container: "<% $.container %>-swift-rings" - obj: "swift-rings.tar.gz" - method: "PUT" - - set_put_tempurl: - action: tripleo.parameters.update - input: - parameters: - SwiftRingPutTempurl: <% task(put_tempurl).result %> - container: <% $.container %> + create_swift_rings_backup_plan: + workflow: tripleo.swift_rings_backup.v1.create_swift_rings_backup_container_plan on-success: get_heat_stack + on-error: create_swift_rings_backup_plan_set_status_failed + input: + container: <% $.container %> + queue_name: <% $.queue_name %> + use_default_templates: true get_heat_stack: action: heat.stacks_get stack_id=<% $.container %> @@ -202,6 +171,12 @@ workflows: on-success: send_message on-error: set_deployment_failed + create_swift_rings_backup_plan_set_status_failed: + on-success: send_message + publish: + status: FAILED + message: <% task(create_swift_rings_backup_plan).result %> + set_deployment_failed: on-success: send_message publish: diff --git a/workbooks/plan_management.yaml b/workbooks/plan_management.yaml index d6949aac1..d4b623e58 100644 --- a/workbooks/plan_management.yaml +++ b/workbooks/plan_management.yaml @@ -217,13 +217,22 @@ workflows: upload_templates_directory: action: tripleo.templates.upload container=<% $.container %> templates_path=<% task(clone_git_repo).result %> - on-success: update_plan + on-success: create_swift_rings_backup_plan on-complete: cleanup_temporary_files on-error: upload_templates_directory_set_status_failed cleanup_temporary_files: action: tripleo.git.clean container=<% $.container %> + create_swift_rings_backup_plan: + workflow: tripleo.swift_rings_backup.v1.create_swift_rings_backup_container_plan + on-success: update_plan + on-error: create_swift_rings_backup_plan_set_status_failed + input: + container: <% $.container %> + queue_name: <% $.queue_name %> + use_default_templates: true + update_plan: action: tripleo.plan.update container=<% $.container %> on-success: @@ -247,6 +256,12 @@ workflows: status: SUCCESS message: <% task(update_plan).result %> + create_swift_rings_backup_plan_set_status_failed: + on-success: notify_zaqar + publish: + status: FAILED + message: <% task(create_swift_rings_backup_plan).result %> + clone_git_repo_set_status_failed: on-success: notify_zaqar publish: diff --git a/workbooks/swift_rings_backup.yaml b/workbooks/swift_rings_backup.yaml new file mode 100644 index 000000000..870e176c7 --- /dev/null +++ b/workbooks/swift_rings_backup.yaml @@ -0,0 +1,87 @@ +--- +version: '2.0' +name: tripleo.swift_rings_backup.v1 +description: TripleO Swift Rings backup container Deployment Workflow v1 + +workflows: + + create_swift_rings_backup_container_plan: + description: > + This plan ensures existence of container for Swift Rings backup. + input: + - container + - queue_name: tripleo + tasks: + check_container: + action: swift.head_container container=<% $.container %> + on-success: get_tempurl + on-error: create_container + + create_container: + action: tripleo.plan.create_container container="<% $.container %>-swift-rings" + on-error: set_create_container_failed + on-success: get_tempurl + + get_tempurl: + action: tripleo.swift.tempurl + on-success: set_get_tempurl + input: + container: "<% $.container %>-swift-rings" + obj: "swift-rings.tar.gz" + + set_get_tempurl: + action: tripleo.parameters.update + input: + parameters: + SwiftRingGetTempurl: <% task(get_tempurl).result %> + container: <% $.container %> + on-success: put_tempurl + + put_tempurl: + action: tripleo.swift.tempurl + on-success: set_put_tempurl + input: + container: "<% $.container %>-swift-rings" + obj: "swift-rings.tar.gz" + method: "PUT" + + set_put_tempurl: + action: tripleo.parameters.update + input: + parameters: + SwiftRingPutTempurl: <% task(put_tempurl).result %> + container: <% $.container %> + on-success: set_status_success + on-error: set_put_tempurl_failed + + set_status_success: + on-success: notify_zaqar + publish: + status: SUCCESS + message: <% task(set_put_tempurl).result %> + + set_put_tempurl_failed: + on-success: notify_zaqar + publish: + status: FAILED + message: <% task(set_put_tempurl).result %> + + set_create_container_failed: + on-success: notify_zaqar + publish: + status: FAILED + message: <% task(create_container_failed).result %> + + notify_zaqar: + action: zaqar.queue_post + input: + queue_name: <% $.queue_name %> + messages: + body: + type: tripleo.swift_rings_backup.v1.create_swift_rings_backup_container_plan + payload: + status: <% $.status %> + message: <% $.get('message', '') %> + execution: <% execution() %> + on-success: + - fail: <% $.get('status') = "FAILED" %>