--- version: '2.0' name: tripleo.swift.v1 description: TripleO Swift Utility Workflows workflows: container_exists: description: >- Verify if a Swift container exists Given the name of a Swift container this workflow will verify if it already exists. The workflow will ERROR if it doesn't and end in SUCCESS if it does. If create_container: true is passed in, then the container will be created if it doesn't exist. In this case, if the workflow fails the container failed to create. input: - container - headers: {} - create_container: false tags: - tripleo-common-managed tasks: # We use the "prefix" input to only list the containers starting with # the container name we want to find. There is no way to do an exact # match, but this will greatly reduce the possible number of results. get_containers: action: swiftservice.list input: options: prefix: <% $.container %> publish: container_exists: <% bool(task().result) and $.container in task().result[0].listing.name %> create_input: <% $.headers and {"container" => $.container, "headers" => $.headers} or {"container" => $.container} %> on-success: - succeed: <% $.container_exists %> - fail: <% not $.create_container and not $.container_exists %> - create_container: <% $.create_container and not $.container_exists %> create_container: action: swift.put_container input: <% $.create_input %> object_exists: description: > Verify if a Swift object exists Given the name of a Swift container and object this workflow will verify if it already exists. The workflow will ERROR if it doesn't and end in SUCCESS if it does. input: - container - object tags: - tripleo-common-managed tasks: get_objects: action: swift.get_container input: container: <% $.container %> prefix: <% $.object %> publish: object_exists: <% bool(task().result) and $.object in task().result[1].select($.name) %> on-success: - succeed: <% $.object_exists %> - fail: <% not $.object_exists %>