Jump to: navigation, search

Difference between revisions of "Mistral/DSL"

(Workflow)
(Task)
Line 77: Line 77:
 
==== Attributes ====
 
==== Attributes ====
  
* '''name''' - string without space, mandatory attribute
 
 
* '''action''' - name of action to perform
 
* '''action''' - name of action to perform
 
* '''requires''' - list of tasks which should be execute before this tasks, or list of task names as a keys and condition as a value, this is optional parameter
 
* '''requires''' - list of tasks which should be execute before this tasks, or list of task names as a keys and condition as a value, this is optional parameter
* '''parameters''' - list of parameters
+
* '''parameters''' - actual parameters for the task, each value can be either some number, string etc, or YAQL expression to retrieve value from task context
 
* '''on-success''' - task which will be scheduled on execution after current task has finished with state 'SUCCESS'
 
* '''on-success''' - task which will be scheduled on execution after current task has finished with state 'SUCCESS'
 
* '''on-error''' - task which will be scheduled on execution after current task has finished with state 'ERROR'
 
* '''on-error''' - task which will be scheduled on execution after current task has finished with state 'ERROR'
Line 87: Line 86:
 
YAML example:
 
YAML example:
  
   create-vms:
+
   create-vm:
     action: Nova:create-vm
+
     action: Nova.create-vm
 
     parameters:
 
     parameters:
        image_id: 1234
+
      image_id: $.image_id
        flavor_id: 42
+
      flavor_id: 42
 
     requires:
 
     requires:
 
       task2: '$.value2 = 123'
 
       task2: '$.value2 = 123'

Revision as of 10:51, 5 May 2014

Mistral DSL specification

Version 0.1

Main objects

  • Namespace
  • Action
  • Workflow
  • Task
  • Trigger

Namespaces

Provides some specific functionality. For example, Nova service provides functionality for VMs management in OpenStack.

Attributes

All attributes are inside main keys of Namespaces - namespaces names

  • class - currently we support the following classes: std.http, std.mistral_http, std.echo, std.email, std.ssh, this is an optional attribute
  • base-parameters - dictionary depending on type of the namespace, this parameter can be optional. Values of this parameters apply to all actions inside namespace. For example for std.http it can contain url, method, body and headers.
  • actions - list of actions provided by this namespace

YAML example:

 Namespaces:
    Nova:
      class: std.http
      parameters:
          method: GET
      actions:
          create-vm:
            ......
          delete-vm:  
            .....

Action

A function provided by specific Namespaces.

Attributes

  • name - string without space, mandatory attribute
  • base-parameters - dictionary, which structured is defined by action class (or namespace class if defined). For std.http class it contains url, method, body and headers.
  • parameters - list containing parameter names which should or could be specified in task
  • output - dictionary-transformer for action output to send this output next to task. Keys of this dictionary will be included in task result, values are YAQL-expression per key which mean how the specific output should be retrieved from raw output (from action)

YAML example:

 create-vm:
     base-parameters:
         url: servers
     parameters:
         - name
         - server_name  
     output:
       vm_id: $.content.server.id

Workflow

Attributes

  • tasks - list of task in this workflow, each task represent some step in worflow

YAML example:

 Workflow:
    tasks:
       create-vms:
         .....
       attache-volumes: 
         .....

Task

Represents a step in workflow, for example attaching volume

Attributes

  • action - name of action to perform
  • requires - list of tasks which should be execute before this tasks, or list of task names as a keys and condition as a value, this is optional parameter
  • parameters - actual parameters for the task, each value can be either some number, string etc, or YAQL expression to retrieve value from task context
  • on-success - task which will be scheduled on execution after current task has finished with state 'SUCCESS'
  • on-error - task which will be scheduled on execution after current task has finished with state 'ERROR'
  • on-finish - task which will be scheduled on execution after current task has finished

YAML example:

 create-vm:
    action: Nova.create-vm
    parameters:
     image_id: $.image_id
     flavor_id: 42
   requires:
     task2: '$.value2 = 123'
     task4: '$.value4 = 122'
   on-success: task3

Events

By event it is possible to invoke specific task.

Attributes

  • name - string without space, mandatory attribute
  • type - can be PERIODIC, TIMER, CEILOMETER_ALARM
  • tasks - list of tasks which should be execute on event
  • parameters - list of parameters, defined by task

YAML example:

 backup-vm:
    type: periodic
    tasks: [create_backup, delete_old_backup] 
    parameters:
       time: 1 0 * * *

Full YAML example:

 Workflow:
 tasks:
   runJob:
     requires:
       createVM: $.vm_ip != null
     action: DemoApp:runJob
     on-success: deleteVM
     on-error: sendJobError
 
   deleteVM:
     action: Nova:deleteVM
     on-finish: end
 
   sendJobError:
     action: std:email
     parameters:
       address: admin@mycompany.com
       subject: Workflow error
       body: Error occurred while running a VM job in execution {$.execution.id}
     on-finish: deleteVM
 
 # Creating a VM and waiting till it is up (an IP address has been assigned).
 
   createVM:
     action: Nova:createVM
     on-success: waitForIP
     on-error: sendCreateVMError
 
   waitForIP:
     action: std:repeat
     parameters:
       task: getIP
       retries: 5
       delay: 3000
       break-on: $.vm_ip != null
     on-finish:
       sendCreateVMError: $.vm_ip = null
     on-error:
       sendCreateVMError 
 
   getIP:
     action: Nova:getIP
 
   sendCreateVMError:
     action: std:email
     parameters:
       address: admin@mycompany.com
       subject: Workflow error
       body: Failed to create a VM in execution {$.execution.id}
     on-finish: end
 
 # Terminal no-op task.
 
   end:
     action: Util:no-op
 
 events:
   runJob:
     type: periodic
     tasks: runJob
     parameters:
       cron-pattern: "*/1 * * * *"
 
 Services:
   Nova:
     type: REST_API
     parameters:
       baseUrl: {$.novaURL}
     actions:
       createVM:
         parameters:
           url: /servers/{$.vm_id}
           method: POST
         response:
           select: $.server.id
           store-as: vm_id
       getIP:
         parameters:
           url: /servers/{$.vm_id}
           method: GET
         response:
           select: $.server.accessIPv4
           store-as: vm_ip 
       deleteVM:
         parameters:
           url: /servers/{$.vm_id}
           method: DELETE
 
 DemoAPP:
   type: MISTRAL_REST_API
   parameters:
     baseUrl: http://{$.vm_ip}:8080/
   actions:
     runJob:
       parameters:
         url: /runJob
         method: GET

Initial execution context

 {
   "novaURL": TBD,
   "imageID": TBD
 }

When a workflow starts Mistral also adds execution information into the context so the context looks like the following:

 {
   "novaURL": TBD,
   "imageID": TBD,
   "execution": {
     "id": "234234",
     "workbook_name" : "my_workbook",
     "project_id": "ghfgsdfasdfasdf"
     "auth_token": "sdfljsdfsdf-234234234",
     "trust_id": "oiretoilkjsdfglkjsdfglkjsdfg"
   }
 }