File: doc.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (76 lines) | stat: -rw-r--r-- 1,721 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Package workflows provides interaction with the workflows API in the OpenStack Mistral service.

Workflow represents a process that can be described in a various number of ways and that can do some job interesting to the end user.
Each workflow consists of tasks (at least one) describing what exact steps should be made during workflow execution.

Example to list workflows

	listOpts := workflows.ListOpts{
		Namespace: "some-namespace",
	}

	allPages, err := workflows.List(mistralClient, listOpts).AllPages()
	if err != nil {
		panic(err)
	}

	allWorkflows, err := workflows.ExtractWorkflows(allPages)
	if err != nil {
		panic(err)
	}

	for _, workflow := range allWorkflows {
		fmt.Printf("%+v\n", workflow)
	}

Example to get a workflow by its ID

	workflow, err := workflows.Get(mistralClient, "workflow-id").Extract()
	if err != nil {
		t.Fatalf("Unable to get workflow %s: %v", id, err)
	}

	fmt.Printf("%+v\n", workflow)

Example to create a workflow

	workflowDefinition := `---
version: '2.0'

create_vm:
description: Simple workflow example
type: direct

input:
	- vm_name
	- image_ref
	- flavor_ref
output:
	vm_id: <% $.vm_id %>

tasks:
	create_server:
	action: nova.servers_create name=<% $.vm_name %> image=<% $.image_ref %> flavor=<% $.flavor_ref %>
	publish:
		vm_id: <% task(create_server).result.id %>
	on-success:
		- wait_for_instance

	wait_for_instance:
	action: nova.servers_find id=<% $.vm_id %> status='ACTIVE'
	retry:
		delay: 5
		count: 15`

	createOpts := &workflows.CreateOpts{
		Definition: strings.NewReader(workflowDefinition),
		Namespace: "some-namespace",
	}

	execution, err := workflows.Create(mistralClient, opts).Extract()
	if err != nil {
		panic(err)
	}
*/
package workflows