Use the standard messaging in the networks workbook

Update the networks workbook to use the standard message sending
workflow. This workflow reduces the boilerplate that is copied between
workflows by defining the message structure, providing the retry logic
and ensuring the task on a "FAILED" message.

The workflow also offers optional persistence in Swift. If the plan name
is given to the workflow it will store the messages in a Swift container
named <plan_name>-messages.

Related-Bug: #1757372

Change-Id: Ib346f56b4de59c275e907a6ee4364eb311af2fc5
This commit is contained in:
Dougal Matthews 2018-03-20 14:10:47 +00:00
parent 2f91f4c58e
commit 6b47b360af

View File

@ -29,33 +29,28 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
set_status_success: set_status_success:
on-success: notify_zaqar on-success: send_message
publish: publish:
status: SUCCESS status: SUCCESS
message: <% task(validate_network_names).result %> message: <% task(validate_network_names).result %>
set_status_error: set_status_error:
on-success: notify_zaqar on-success: send_message
publish: publish:
status: FAILED status: FAILED
message: "One or more entries did not contain the required field 'name'" message: "One or more entries did not contain the required field 'name'"
notify_zaqar: send_message:
action: zaqar.queue_post workflow: tripleo.messaging.v1.send
input: input:
queue_name: <% $.queue_name %> queue_name: <% $.queue_name %>
messages: type: <% execution().name %>
body: status: <% $.status %>
type: tripleo.networks.v1.validate_networks_input execution: <% execution() %>
payload: message: <% $.get('message', '') %>
status: <% $.status %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>
update_networks: update_networks:
description: > description: >
@ -87,7 +82,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
validate_network_files: validate_network_files:
description: > description: >
@ -103,7 +98,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
get_available_networks: get_available_networks:
workflow: tripleo.plan_management.v1.list_available_networks workflow: tripleo.plan_management.v1.list_available_networks
@ -116,7 +111,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
get_current_networks: get_current_networks:
workflow: tripleo.plan_management.v1.get_network_data workflow: tripleo.plan_management.v1.get_network_data
@ -130,7 +125,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
update_network_data: update_network_data:
description: > description: >
@ -146,7 +141,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
update_network_data_in_swift: update_network_data_in_swift:
description: > description: >
@ -160,7 +155,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
regenerate_templates: regenerate_templates:
action: tripleo.templates.process container=<% $.container %> action: tripleo.templates.process container=<% $.container %>
@ -168,7 +163,7 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
get_networks: get_networks:
description: > description: >
@ -185,24 +180,20 @@ workflows:
publish-on-error: publish-on-error:
status: FAILED status: FAILED
message: <% task().result %> message: <% task().result %>
on-error: notify_zaqar on-error: send_message
set_status_success: set_status_success:
on-success: notify_zaqar on-success: send_message
publish: publish:
status: SUCCESS status: SUCCESS
message: <% task(get_networks).result %> message: <% task(get_networks).result %>
notify_zaqar: send_message:
action: zaqar.queue_post workflow: tripleo.messaging.v1.send
input: input:
queue_name: <% $.queue_name %> queue_name: <% $.queue_name %>
messages: type: <% execution().name %>
body: status: <% $.status %>
type: tripleo.networks.v1.update_networks execution: <% execution() %>
payload: message: <% $.get('message', '') %>
status: <% $.status %> plan_name: <% $.container %>
message: <% $.get('message', '') %>
execution: <% execution() %>
on-success:
- fail: <% $.get('status') = "FAILED" %>