Giter Club home page Giter Club logo

execute-workflow-example's Introduction

Example: Workflow Executions

This example shows:

  • Binding a script implementation to a standard lifecycle operation
  • Binding a script implementation to a custom operation
  • Running scripts via Fabric (SSH)
  • Implementing a workflow as a Python script
  • Running a workflow
  • Resuming a workflow

Deployment Creation

First, upload the blueprint:

cfy blueprints upload blueprint.yaml -b execute_workflow

Next, create a deployment (this command-line example is for OpenStack. For AWS, GCP or Azure, replace openstack with aws, gcp or azure, respectively):

cfy deployments create dep_1 -b execute_workflow -i infra_name=openstack

Installation

To install the topology:

cfy executions start install -d dep_1

The out-of-the-box install workflow runs the standard lifecycle operations, so you should see printouts from these operations (you can find the respective scripts inside the scripts directory).

Running a Specific Operation

Often, there is a need to execute a specific operation on the topology. This can be done by the execute_operation workflow. In this example, we will run the poll operation on the app node.

cfy executions start execute_operation -d dep_1 -p operation=maintenance.poll -p node_ids=[app]

This command will execute the poll operation of the maintenance interface, on all instances of the app node template.

You can also execute the operation on a specific instance of the node template, if the node template has multiple instances. For that, you will need to obtain the node instance ID. You can use the following command:

cfy node-instances list -d dep_1 -n app

And then (assuming the node instance ID is app_123456):

cfy executions start execute_operation -d dep_1 -p operation=maintenance.poll -p node_instance_ids=[app_123456]

Executing a Custom Workflow

The blueprint defines a custom workflow called rollout. The workflow is mapped to a script.

To execute the workflow, run the following command:

cfy executions start rollout -d dep_1

This workflow runs the maintenance.update and maintenance.commit operations in sequence (see the workflow implementation in scripts/rollout.py).

Resuming a Workflow

The maintenance.commit operation contains a condition: the operation will fail if the app node instance has a runtime property called fail_commit and its value is True.

By default, this runtime property doesn't exist on any node instance.

To demonstrate how to resume a workflow, we will set the runtime property's value from the command line.

First, obtain the node instance ID:

cfy node-instances list -d dep_1 -n app

(We will assume that the node instance ID is app_123456)

Next, set the runtime property value:

cfy node-instances update-runtime -p fail_commit=True app_123456

Now, let's run the workflow again:

cfy executions start rollout -d dep_1

The execution will run, however it will fail at the maintenance.commit operation.

Now, we will remove the runtime property and then resume the execution (we will assume that the execution ID is abcdefgh):

cfy node-instances delete-runtime -p fail_commit app_123456
cfy executions resume abcdefgh

This will trigger the execution's resumption. You can then use the cfy events list command (optionally with the --tail parameter) to look at the execution log:

cfy events list abcdefgh

execute-workflow-example's People

Contributors

isaac-s avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.