fog-openstack 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -28
  3. data/docs/workflow.md +129 -0
  4. data/examples/workflow/workflow-examples.rb +387 -0
  5. data/gemfiles/Gemfile-1.9 +1 -0
  6. data/lib/fog/openstack.rb +5 -1
  7. data/lib/fog/openstack/baremetal.rb +14 -38
  8. data/lib/fog/openstack/compute.rb +4 -33
  9. data/lib/fog/openstack/core.rb +104 -50
  10. data/lib/fog/openstack/identity.rb +2 -1
  11. data/lib/fog/openstack/identity_v2.rb +0 -2
  12. data/lib/fog/openstack/identity_v3.rb +0 -2
  13. data/lib/fog/openstack/image_v1.rb +6 -6
  14. data/lib/fog/openstack/image_v2.rb +7 -6
  15. data/lib/fog/openstack/introspection.rb +10 -35
  16. data/lib/fog/openstack/metering.rb +16 -35
  17. data/lib/fog/openstack/monitoring.rb +5 -31
  18. data/lib/fog/openstack/network.rb +5 -34
  19. data/lib/fog/openstack/nfv.rb +10 -35
  20. data/lib/fog/openstack/orchestration.rb +5 -40
  21. data/lib/fog/openstack/planning.rb +11 -36
  22. data/lib/fog/openstack/requests/compute/get_limits.rb +8 -7
  23. data/lib/fog/openstack/requests/network/update_router.rb +1 -1
  24. data/lib/fog/openstack/requests/workflow_v2/create_action.rb +28 -0
  25. data/lib/fog/openstack/requests/workflow_v2/create_action_execution.rb +31 -0
  26. data/lib/fog/openstack/requests/workflow_v2/create_cron_trigger.rb +55 -0
  27. data/lib/fog/openstack/requests/workflow_v2/create_environment.rb +31 -0
  28. data/lib/fog/openstack/requests/workflow_v2/create_execution.rb +30 -0
  29. data/lib/fog/openstack/requests/workflow_v2/create_workbook.rb +28 -0
  30. data/lib/fog/openstack/requests/workflow_v2/create_workflow.rb +28 -0
  31. data/lib/fog/openstack/requests/workflow_v2/delete_action.rb +25 -0
  32. data/lib/fog/openstack/requests/workflow_v2/delete_action_execution.rb +25 -0
  33. data/lib/fog/openstack/requests/workflow_v2/delete_cron_trigger.rb +25 -0
  34. data/lib/fog/openstack/requests/workflow_v2/delete_environment.rb +25 -0
  35. data/lib/fog/openstack/requests/workflow_v2/delete_execution.rb +25 -0
  36. data/lib/fog/openstack/requests/workflow_v2/delete_workbook.rb +25 -0
  37. data/lib/fog/openstack/requests/workflow_v2/delete_workflow.rb +25 -0
  38. data/lib/fog/openstack/requests/workflow_v2/get_action.rb +27 -0
  39. data/lib/fog/openstack/requests/workflow_v2/get_action_execution.rb +26 -0
  40. data/lib/fog/openstack/requests/workflow_v2/get_cron_trigger.rb +28 -0
  41. data/lib/fog/openstack/requests/workflow_v2/get_environment.rb +28 -0
  42. data/lib/fog/openstack/requests/workflow_v2/get_execution.rb +26 -0
  43. data/lib/fog/openstack/requests/workflow_v2/get_task.rb +27 -0
  44. data/lib/fog/openstack/requests/workflow_v2/get_workbook.rb +28 -0
  45. data/lib/fog/openstack/requests/workflow_v2/get_workflow.rb +28 -0
  46. data/lib/fog/openstack/requests/workflow_v2/list_action_executions.rb +28 -0
  47. data/lib/fog/openstack/requests/workflow_v2/list_actions.rb +30 -0
  48. data/lib/fog/openstack/requests/workflow_v2/list_cron_triggers.rb +28 -0
  49. data/lib/fog/openstack/requests/workflow_v2/list_environments.rb +28 -0
  50. data/lib/fog/openstack/requests/workflow_v2/list_executions.rb +28 -0
  51. data/lib/fog/openstack/requests/workflow_v2/list_services.rb +28 -0
  52. data/lib/fog/openstack/requests/workflow_v2/list_tasks.rb +28 -0
  53. data/lib/fog/openstack/requests/workflow_v2/list_workbooks.rb +28 -0
  54. data/lib/fog/openstack/requests/workflow_v2/list_workflows.rb +30 -0
  55. data/lib/fog/openstack/requests/workflow_v2/rerun_task.rb +33 -0
  56. data/lib/fog/openstack/requests/workflow_v2/update_action.rb +28 -0
  57. data/lib/fog/openstack/requests/workflow_v2/update_action_execution.rb +33 -0
  58. data/lib/fog/openstack/requests/workflow_v2/update_environment.rb +31 -0
  59. data/lib/fog/openstack/requests/workflow_v2/update_execution.rb +33 -0
  60. data/lib/fog/openstack/requests/workflow_v2/update_workbook.rb +28 -0
  61. data/lib/fog/openstack/requests/workflow_v2/update_workflow.rb +28 -0
  62. data/lib/fog/openstack/requests/workflow_v2/validate_action.rb +28 -0
  63. data/lib/fog/openstack/requests/workflow_v2/validate_workbook.rb +28 -0
  64. data/lib/fog/openstack/requests/workflow_v2/validate_workflow.rb +28 -0
  65. data/lib/fog/openstack/storage.rb +4 -35
  66. data/lib/fog/openstack/version.rb +1 -1
  67. data/lib/fog/openstack/volume_v1.rb +7 -5
  68. data/lib/fog/openstack/volume_v2.rb +7 -5
  69. data/lib/fog/openstack/workflow.rb +12 -0
  70. data/lib/fog/openstack/workflow_v2.rb +160 -0
  71. metadata +48 -95
  72. data/lib/fog/openstack/common.rb +0 -44
  73. data/tests/openstack/models/compute/images_tests.rb +0 -13
  74. data/tests/openstack/models/compute/security_group_tests.rb +0 -54
  75. data/tests/openstack/models/compute/server_tests.rb +0 -220
  76. data/tests/openstack/models/compute/service_tests.rb +0 -17
  77. data/tests/openstack/models/image/image_tests.rb +0 -36
  78. data/tests/openstack/models/image/images_tests.rb +0 -19
  79. data/tests/openstack/models/network/floating_ip_tests.rb +0 -35
  80. data/tests/openstack/models/network/floating_ips_tests.rb +0 -19
  81. data/tests/openstack/models/network/ike_policies_tests.rb +0 -28
  82. data/tests/openstack/models/network/ike_policy_tests.rb +0 -36
  83. data/tests/openstack/models/network/ipsec_policies_tests.rb +0 -26
  84. data/tests/openstack/models/network/ipsec_policy_tests.rb +0 -36
  85. data/tests/openstack/models/network/ipsec_site_connection_tests.rb +0 -50
  86. data/tests/openstack/models/network/ipsec_site_connections_tests.rb +0 -32
  87. data/tests/openstack/models/network/lb_health_monitor_tests.rb +0 -52
  88. data/tests/openstack/models/network/lb_health_monitors_tests.rb +0 -21
  89. data/tests/openstack/models/network/lb_member_tests.rb +0 -28
  90. data/tests/openstack/models/network/lb_members_tests.rb +0 -21
  91. data/tests/openstack/models/network/lb_pool_tests.rb +0 -53
  92. data/tests/openstack/models/network/lb_pools_tests.rb +0 -20
  93. data/tests/openstack/models/network/lb_vip_tests.rb +0 -39
  94. data/tests/openstack/models/network/lb_vips_tests.rb +0 -21
  95. data/tests/openstack/models/network/network_tests.rb +0 -61
  96. data/tests/openstack/models/network/networks_tests.rb +0 -21
  97. data/tests/openstack/models/network/port_tests.rb +0 -28
  98. data/tests/openstack/models/network/ports_tests.rb +0 -25
  99. data/tests/openstack/models/network/router_tests.rb +0 -39
  100. data/tests/openstack/models/network/routers_tests.rb +0 -21
  101. data/tests/openstack/models/network/security_group_rule_tests.rb +0 -27
  102. data/tests/openstack/models/network/security_group_rules_tests.rb +0 -25
  103. data/tests/openstack/models/network/security_group_tests.rb +0 -17
  104. data/tests/openstack/models/network/security_groups_tests.rb +0 -16
  105. data/tests/openstack/models/network/subnet_tests.rb +0 -30
  106. data/tests/openstack/models/network/subnets_tests.rb +0 -27
  107. data/tests/openstack/models/network/vpn_service_tests.rb +0 -27
  108. data/tests/openstack/models/network/vpn_services_tests.rb +0 -22
  109. data/tests/openstack/models/nfv/vnf_tests.rb +0 -35
  110. data/tests/openstack/models/nfv/vnfd_tests.rb +0 -23
  111. data/tests/openstack/models/nfv/vnfds_tests.rb +0 -31
  112. data/tests/openstack/models/nfv/vnfs_tests.rb +0 -38
  113. data/tests/openstack/models/planning/.gitkeep +0 -0
  114. data/tests/openstack/models/planning/plan_tests.rb +0 -51
  115. data/tests/openstack/models/planning/plans_tests.rb +0 -18
  116. data/tests/openstack/models/planning/role_tests.rb +0 -14
  117. data/tests/openstack/models/storage/file_tests.rb +0 -251
  118. data/tests/openstack/requests/compute/address_tests.rb +0 -58
  119. data/tests/openstack/requests/compute/aggregate_tests.rb +0 -59
  120. data/tests/openstack/requests/compute/availability_zone_tests.rb +0 -18
  121. data/tests/openstack/requests/compute/flavor_tests.rb +0 -95
  122. data/tests/openstack/requests/compute/helper.rb +0 -41
  123. data/tests/openstack/requests/compute/image_tests.rb +0 -58
  124. data/tests/openstack/requests/compute/keypair_tests.rb +0 -30
  125. data/tests/openstack/requests/compute/limit_tests.rb +0 -59
  126. data/tests/openstack/requests/compute/quota_tests.rb +0 -60
  127. data/tests/openstack/requests/compute/security_group_tests.rb +0 -61
  128. data/tests/openstack/requests/compute/server_tests.rb +0 -289
  129. data/tests/openstack/requests/compute/service_tests.rb +0 -33
  130. data/tests/openstack/requests/compute/tenant_tests.rb +0 -19
  131. data/tests/openstack/requests/compute/volume_tests.rb +0 -38
  132. data/tests/openstack/requests/image/image_tests.rb +0 -135
  133. data/tests/openstack/requests/metering/event_tests.rb +0 -17
  134. data/tests/openstack/requests/metering/meter_tests.rb +0 -52
  135. data/tests/openstack/requests/metering/resource_tests.rb +0 -19
  136. data/tests/openstack/requests/network/ike_policy_tests.rb +0 -65
  137. data/tests/openstack/requests/network/ipsec_policy_tests.rb +0 -65
  138. data/tests/openstack/requests/network/ipsec_site_connection_tests.rb +0 -82
  139. data/tests/openstack/requests/network/lb_health_monitor_tests.rb +0 -93
  140. data/tests/openstack/requests/network/lb_member_tests.rb +0 -60
  141. data/tests/openstack/requests/network/lb_pool_tests.rb +0 -80
  142. data/tests/openstack/requests/network/lb_vip_tests.rb +0 -71
  143. data/tests/openstack/requests/network/network_tests.rb +0 -107
  144. data/tests/openstack/requests/network/port_tests.rb +0 -66
  145. data/tests/openstack/requests/network/quota_tests.rb +0 -65
  146. data/tests/openstack/requests/network/router_tests.rb +0 -73
  147. data/tests/openstack/requests/network/security_group_rule_tests.rb +0 -58
  148. data/tests/openstack/requests/network/security_group_tests.rb +0 -43
  149. data/tests/openstack/requests/network/subnet_tests.rb +0 -66
  150. data/tests/openstack/requests/network/vpn_service_tests.rb +0 -61
  151. data/tests/openstack/requests/nfv/vnf_tests.rb +0 -70
  152. data/tests/openstack/requests/nfv/vnfd_tests.rb +0 -44
  153. data/tests/openstack/requests/orchestration/stack_tests.rb +0 -64
  154. data/tests/openstack/requests/planning/.gitkeep +0 -0
  155. data/tests/openstack/requests/planning/plan_tests.rb +0 -65
  156. data/tests/openstack/requests/planning/role_tests.rb +0 -16
  157. data/tests/openstack/requests/storage/container_tests.rb +0 -64
  158. data/tests/openstack/requests/storage/large_object_tests.rb +0 -372
  159. data/tests/openstack/requests/storage/object_tests.rb +0 -208
  160. data/tests/openstack/requests/volume/availability_zone_tests.rb +0 -13
  161. data/tests/openstack/requests/volume/quota_tests.rb +0 -50
  162. data/tests/openstack/requests/volume/volume_type_tests.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31a9071364facb7a54109c5a95e7c9b712c6f78a
4
- data.tar.gz: 81f2374694077b420e017aad70ad1c52268c01ec
3
+ metadata.gz: d9ce654512cff2b2a3f28e0824d064b301545033
4
+ data.tar.gz: a77a6c8e6ae3407c2ca6cb0cda7778475937dfb4
5
5
  SHA512:
6
- metadata.gz: 6c2f0405c2e7356ebd64426c7e4878a7526504180eb3bf5bfffb1556df985228688c74f6b9f93a253bc4eacd5441238dc2ff1d72c22d944938bc6720f79d5c94
7
- data.tar.gz: 41c0cc5fbd768ba1fffb0729609fe1504daed6a746a3c6d9b744f90693443fe3c599eab228438a0e56e613883c070e1d89fa38200895d2d6ecb13379dac71283
6
+ metadata.gz: a854f60f8714a51c8e8942c4186bcc9c8a5e2964bba44f566486965f5d9b31da92ccb11598722421c39069b88bace1ddf8f0a3425f3d568f8b794cadc4736557
7
+ data.tar.gz: 93d5e4dd2500f120a2458c658e125d0a2bd79f461ffab55ff62fed458cd5032d2f7ebe8b2f8c933bc631457a94f8d7d7f8b66261e9a8c22ddfa2e690b3048a31
data/README.md CHANGED
@@ -310,43 +310,26 @@ volume.destroy
310
310
 
311
311
  ### Image (Glance)
312
312
 
313
- Create Glance image from URL:
313
+ Download Glance image:
314
314
 
315
315
  ```ruby
316
316
 
317
317
  image = Fog::Image::OpenStack.new(@connection_params)
318
318
 
319
- cirros_location = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
319
+ image_out = File.open("/tmp/cirros-image-download", 'wb')
320
320
 
321
- image.images.create name: "cirros",
322
- disk_format: "qcow2",
323
- container_format: "bare",
324
- location: cirros_location
325
- # => <Fog::Image::OpenStack::V2::Image
326
- # id="4beedb46-e32f-4ef3-a87b-7f1234294dc1",
327
- # name="cirros",
328
- # visibility="private",
329
- # tags=[],
330
- # self="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1",
331
- # size=nil,
332
- # disk_format="qcow2",
333
- # container_format="bare",
334
- # id="4beedb46-e32f-4ef3-a87b-7f1234294dc1",
335
- # checksum=nil,
336
- # self="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1",
337
- # file="/v2/images/4beedb46-e32f-4ef3-a87b-7f1234294dc1/file",
338
- # min_disk=0,
339
- # created_at="2016-03-07T14:28:10Z",
340
- # updated_at="2016-03-07T14:28:10Z",
341
- # protected=false,
342
- # status="queued",
343
- # >
321
+ streamer = lambda do |chunk, _, _|
322
+ image_out.write chunk
323
+ end
324
+
325
+ image.download_image(image.images.first.id, response_block: streamer)
344
326
 
345
327
  ```
346
328
 
347
- Create Glance image from file:
329
+ Create Glance image from file or URL:
348
330
 
349
331
  ```ruby
332
+
350
333
  cirros_location = "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img"
351
334
  image_out = File.open("/tmp/cirros-image-#{SecureRandom.hex}", 'wb')
352
335
 
@@ -359,8 +342,9 @@ image_out.close
359
342
 
360
343
  image.images.create name: "cirros",
361
344
  disk_format: "qcow2",
362
- container_format: "bare",
363
- location: image_out.path
345
+ container_format: "bare"
346
+
347
+ image.upload_data File.binread(image_out.path)
364
348
 
365
349
  ```
366
350
 
@@ -0,0 +1,129 @@
1
+ # OpenStack Workflow (Mistral)
2
+
3
+ This document explains how to get started using OpenStack Workflow (Mistral) with Fog. It assumes you have read the [Getting Started with Fog and the OpenStack](getting_started.md) document.
4
+
5
+ Fog uses the [OpenStack Mistral API](http://docs.openstack.org/developer/mistral/developer/webapi/v2.html).
6
+
7
+ ## Workflow Service
8
+
9
+ Get a handle for the Workflow service:
10
+
11
+ ```ruby
12
+ service = Fog::Workflow::OpenStack.new({
13
+ :openstack_auth_url => 'http://KEYSTONE_HOST:KEYSTONE_PORT/v2.0/tokens', # OpenStack Keystone endpoint
14
+ :openstack_username => OPEN_STACK_USER, # Your OpenStack Username
15
+ :openstack_tenant => OPEN_STACK_TENANT, # Your tenant id
16
+ :openstack_api_key => OPEN_STACK_PASSWORD, # Your OpenStack Password
17
+ :connection_options => {} # Optional
18
+ })
19
+ ```
20
+
21
+ ## Executions
22
+
23
+ A Workflow is a composition of one or more actions.
24
+
25
+ To execute a workflow, we create an execution:
26
+
27
+ ```ruby
28
+ workflow = "tripleo.plan_management.v1.create_default_deployment_plan"
29
+ input = { :container => 'default' }
30
+ response = service.create_execution(workflow, input)
31
+ ```
32
+
33
+ Execution status and result can be checked by:
34
+
35
+ ```ruby
36
+ workflow_execution_id = response.body["id"]
37
+ response = mistral.get_execution(workflow_execution_id)
38
+ state = response.body["state"]
39
+ ```
40
+
41
+ To execute an individual action, we create an action execution:
42
+
43
+ ```ruby
44
+ input = { :container => 'default' }
45
+ service.create_action_execution("tripleo.get_capabilities", input)
46
+ ```
47
+
48
+ For actions, the result is returned when create_action_execution completes.
49
+
50
+ ## Workflows
51
+
52
+ ### Create a workflow
53
+
54
+ ```ruby
55
+ workflow_def = {
56
+ :version => "2.0",
57
+ :myworkflow => {
58
+ :type => "direct",
59
+ :description => "description1",
60
+ :tasks => {
61
+ :create_vm => {
62
+ :description => "create vm"
63
+ }
64
+ }
65
+ }
66
+ }
67
+ response = service.create_workflow(workflow_def)
68
+ workflow_id = response.body["workflows"][0]["id"]
69
+ ```
70
+
71
+ ### Validate a workflow before creating it
72
+
73
+ ```ruby
74
+ service.validate_workflow(workflow_def)
75
+ ```
76
+
77
+ ### Update a workflow
78
+
79
+ ```ruby
80
+ workflow_def_new = {
81
+ :version => "2.0",
82
+ :myworkflow => {
83
+ :type => "direct",
84
+ :description => "description2",
85
+ :tasks => {
86
+ :create_vm => {
87
+ :description => "create vm"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ service.update_workflow(workflow_def_new)
93
+ ```
94
+
95
+ ### List workflow
96
+
97
+ ```ruby
98
+ service.list_workflows
99
+ ```
100
+
101
+ ### Delete workflow
102
+
103
+ ```ruby
104
+ service.delete_workflow(workflow_id)
105
+ ```
106
+
107
+ ## Other Mistral resources
108
+
109
+ In addition to workflows, the following Mistral resources are also supported:
110
+
111
+ * Workbooks
112
+ * Actions
113
+ * Executions
114
+ * Tasks
115
+ * Action Executions
116
+ * Cron Triggers
117
+ * Environments
118
+ * Validations
119
+
120
+ For examples on how to interact with these resources, please refer to
121
+ https://github.com/fog/fog-openstack/tree/master/examples/workflow/workflow-examples.rb
122
+
123
+ ## Information about Mistral
124
+
125
+ * [Mistral Wiki](https://wiki.openstack.org/wiki/Mistral)
126
+ * [Mistral DSL v2](http://docs.openstack.org/developer/mistral/dsl/dsl_v2.html)
127
+ * [Mistral API v2](http://docs.openstack.org/developer/mistral/developer/webapi/v2.html)
128
+ * [Mistral python client](https://github.com/openstack/python-mistralclient) Can be useful to see how to interact with the API.
129
+
@@ -0,0 +1,387 @@
1
+ require 'fog/openstack'
2
+ require 'fog/openstack/workflow_v2'
3
+
4
+ auth_url = "http://192.0.2.1:5000/v3/auth/tokens"
5
+ username = "admin"
6
+ password = "1b1d81f7e25b53e497246b168971823c5754f395"
7
+ project = "admin"
8
+
9
+ @connection_params = {
10
+ :openstack_auth_url => auth_url,
11
+ :openstack_username => username,
12
+ :openstack_api_key => password,
13
+ :openstack_project_name => project,
14
+ :openstack_domain_id => "default",
15
+ }
16
+
17
+ mistral = Fog::Workflow::OpenStack.new(@connection_params)
18
+
19
+ puts "INFO: create_execution"
20
+
21
+ workflow = "tripleo.plan_management.v1.create_default_deployment_plan"
22
+ input = { :container => 'default' }
23
+
24
+ response = mistral.create_execution(workflow, input)
25
+
26
+ puts response.body
27
+
28
+ state = response.body["state"]
29
+ workflow_execution_id = response.body["id"]
30
+ puts "INFO: state #{state} execution_id #{workflow_execution_id}"
31
+
32
+ while state == "RUNNING"
33
+ sleep 5
34
+ response = mistral.get_execution(workflow_execution_id)
35
+ state = response.body["state"]
36
+ workflow_execution_id = response.body["id"]
37
+ puts "INFO: state #{state} execution_id #{workflow_execution_id}"
38
+ end
39
+
40
+ puts response.body
41
+
42
+ puts "INFO: list_executions"
43
+
44
+ response = mistral.list_executions
45
+
46
+ puts response.body
47
+
48
+ puts "INFO: update_execution"
49
+
50
+ response = mistral.update_execution(workflow_execution_id, "description",
51
+ "changed description")
52
+ puts response.body
53
+
54
+ puts "INFO: list_tasks #{workflow_execution_id}"
55
+
56
+ response = mistral.list_tasks(workflow_execution_id)
57
+ task_ex_id = response.body["tasks"][0]["id"]
58
+ puts response.body
59
+
60
+ puts "INFO: get_task #{task_ex_id}"
61
+
62
+ response = mistral.get_task(task_ex_id)
63
+ puts response.body
64
+
65
+ puts "INFO: rerun_task #{task_ex_id}"
66
+
67
+ response = mistral.rerun_task(task_ex_id)
68
+ puts response.body
69
+
70
+ puts "INFO: delete_execution"
71
+
72
+ response = mistral.delete_execution(workflow_execution_id)
73
+ puts response.body
74
+
75
+ puts "INFO: create_action_execution"
76
+
77
+ input = { :container => 'default' }
78
+ response = mistral.create_action_execution("tripleo.get_capabilities", input)
79
+
80
+ puts response.body
81
+
82
+ puts "INFO: list_action_executions"
83
+
84
+ response = mistral.list_action_executions
85
+
86
+ puts response.body
87
+
88
+ puts "INFO: get_action_execution"
89
+
90
+ execution_id = response.body["id"]
91
+ response = mistral.get_action_execution(execution_id)
92
+
93
+ puts response.body
94
+
95
+ puts "INFO: create_workbook"
96
+
97
+ workbook_def = {
98
+ :version => "2.0",
99
+ :name => "workbook name",
100
+ :description => "workbook description",
101
+ }
102
+ response = mistral.create_workbook(workbook_def)
103
+ workbook_name = response.body["name"]
104
+
105
+ puts response.body
106
+
107
+ puts "INFO: get_workbook"
108
+
109
+ response = mistral.get_workbook(workbook_name)
110
+
111
+ puts response.body
112
+
113
+ puts "INFO: list_workbooks"
114
+
115
+ response = mistral.list_workbooks
116
+
117
+ puts response.body
118
+
119
+ puts "INFO: update_workbook"
120
+
121
+ workbook_def = {
122
+ :version => "2.0",
123
+ :name => "workbook name",
124
+ :description => "workbook description2",
125
+ }
126
+
127
+ response = mistral.update_workbook(workbook_def)
128
+
129
+ puts response.body
130
+
131
+ puts "INFO: get_workbook2"
132
+
133
+ response = mistral.get_workbook(workbook_name)
134
+
135
+ puts response.body
136
+
137
+ puts "INFO: validate_workbook"
138
+
139
+ response = mistral.validate_workbook(workbook_def)
140
+
141
+ puts response.body
142
+
143
+ puts "INFO: delete_workbook"
144
+
145
+ response = mistral.delete_workbook(workbook_name)
146
+ puts response.body
147
+
148
+ puts "INFO: create_workflow"
149
+
150
+ workflow_def = {
151
+ :version => "2.0",
152
+ :myworkflow => {
153
+ :type => "direct",
154
+ :description => "description1",
155
+ :tasks => {
156
+ :create_vm => {
157
+ :description => "create vm"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ response = mistral.create_workflow(workflow_def)
163
+ workflow_id = response.body["workflows"][0]["id"]
164
+
165
+ puts response.body
166
+
167
+ puts "INFO: get_workflow #{workflow_id}"
168
+
169
+ response = mistral.get_workflow(workflow_id)
170
+
171
+ puts response.body
172
+
173
+ puts "INFO: list_workflows"
174
+
175
+ response = mistral.list_workflows
176
+
177
+ puts response.body
178
+
179
+ puts "INFO: list_workflows with params"
180
+
181
+ params = { :limit => 1 }
182
+ response = mistral.list_workflows(params)
183
+ perm_workflow_id = response.body["workflows"][0]["id"]
184
+
185
+ puts response.body
186
+
187
+ puts "INFO: update_workflow"
188
+
189
+ workflow_def = {
190
+ :version => "2.0",
191
+ :myworkflow => {
192
+ :type => "direct",
193
+ :description => "description2",
194
+ :tasks => {
195
+ :create_vm => {
196
+ :description => "create vm"
197
+ }
198
+ }
199
+ }
200
+ }
201
+ response = mistral.update_workflow(workflow_def)
202
+
203
+ puts response.body
204
+
205
+ puts "INFO: get_workflow2"
206
+
207
+ response = mistral.get_workflow(workflow_id)
208
+
209
+ puts response.body
210
+
211
+ puts "INFO: validate_workflow"
212
+
213
+ response = mistral.validate_workflow(workflow_def)
214
+
215
+ puts response.body
216
+
217
+ puts "INFO: delete_workflow #{workflow_id}"
218
+
219
+ response = mistral.delete_workflow(workflow_id)
220
+ puts response.body
221
+
222
+ puts "INFO: create_action"
223
+
224
+ action_def = {
225
+ :version => "2.0",
226
+ :myaction => {
227
+ :input => ['execution_id'],
228
+ :base => "std.email",
229
+ "base-input" => {
230
+ :to_addrs => ['admin@mywebsite.org'],
231
+ :subject => "subject1",
232
+ :body => "body1",
233
+ :from_addr => "mistral@openstack.org",
234
+ :smtp_server => "smtp.test.com",
235
+ :smtp_password => "secret"
236
+ }
237
+ }
238
+ }
239
+ response = mistral.create_action(action_def)
240
+
241
+ puts response.body
242
+
243
+ puts "INFO: get_action"
244
+
245
+ action_name = "myaction"
246
+ response = mistral.get_action(action_name)
247
+
248
+ puts response.body
249
+
250
+ puts "INFO: list_actions"
251
+
252
+ response = mistral.list_actions
253
+
254
+ puts response.body
255
+
256
+ puts "INFO: list_actions with params"
257
+
258
+ params = { :limit => 1 }
259
+ response = mistral.list_actions(params)
260
+
261
+ puts response.body
262
+
263
+ puts "INFO: update_action"
264
+
265
+ action_def = {
266
+ :version => "2.0",
267
+ :myaction => {
268
+ :input => ['execution_id'],
269
+ :base => "std.email",
270
+ "base-input" => {
271
+ :to_addrs => ['admin@mywebsite.org'],
272
+ :subject => "subject updated",
273
+ :body => "body1",
274
+ :from_addr => "mistral@openstack.org",
275
+ :smtp_server => "smtp.test.com",
276
+ :smtp_password => "secret"
277
+ }
278
+ }
279
+ }
280
+
281
+ response = mistral.update_action(action_def)
282
+
283
+ puts response.body
284
+
285
+ puts "INFO: get_action2"
286
+
287
+ response = mistral.get_action(action_name)
288
+
289
+ puts response.body
290
+
291
+ puts "INFO: validate_action"
292
+
293
+ response = mistral.validate_action(action_def)
294
+
295
+ puts response.body
296
+
297
+ puts "INFO: delete_action"
298
+
299
+ response = mistral.delete_action(action_name)
300
+ puts response.body
301
+
302
+ puts "INFO: create_cron_trigger #{perm_workflow_id}"
303
+
304
+ cron_name = "mycron"
305
+ workflow_input = { "container" => "test1" }
306
+ response = mistral.create_cron_trigger(cron_name,
307
+ perm_workflow_id,
308
+ workflow_input)
309
+
310
+ puts response.body
311
+
312
+ puts "INFO: get_cron_trigger"
313
+
314
+ response = mistral.get_cron_trigger(cron_name)
315
+
316
+ puts response.body
317
+
318
+ puts "INFO: list_cron_triggers"
319
+
320
+ response = mistral.list_cron_triggers
321
+
322
+ puts response.body
323
+
324
+ puts "INFO: delete_cron_trigger"
325
+
326
+ response = mistral.delete_cron_trigger(cron_name)
327
+
328
+ puts response.body
329
+
330
+ puts "INFO: create_environment"
331
+
332
+ environment_def = {
333
+ "name" => "environment-1",
334
+ "variables" => {
335
+ "var1" => "value1",
336
+ "var2" => "value2"
337
+ }
338
+ }
339
+ response = mistral.create_environment(environment_def)
340
+ puts response.body
341
+
342
+ puts "INFO: get_environment"
343
+
344
+ environment_name = environment_def["name"]
345
+ response = mistral.get_environment(environment_name)
346
+
347
+ puts response.body
348
+
349
+ puts "INFO: list_environments"
350
+
351
+ response = mistral.list_environments
352
+
353
+ puts response.body
354
+
355
+ puts "INFO: update_environment"
356
+
357
+ environment_def = {
358
+ "name" => "environment-1",
359
+ "variables" => {
360
+ "var1" => "value3",
361
+ "var2" => "value4"
362
+ }
363
+ }
364
+ response = mistral.update_environment(environment_def)
365
+
366
+ puts response.body
367
+
368
+ puts "INFO: get_environment2"
369
+
370
+ response = mistral.get_environment(environment_name)
371
+
372
+ puts response.body
373
+
374
+ puts "INFO: delete_environment"
375
+
376
+ response = mistral.delete_environment(environment_name)
377
+ puts response.body
378
+
379
+ #
380
+ # Services api is unsupported atm. Next call will fail.
381
+ #
382
+
383
+ puts "INFO: list_services"
384
+
385
+ response = mistral.list_services
386
+
387
+ puts response.body