Difference between revisions of "Heat Mistral resources usage examples"
(These examples demonstrate how to use Mistral resources in Heat.) |
|||
Line 1: | Line 1: | ||
− | Case 1: Creating resources using Heat template and check that they are available in Mistral service. | + | == Case 1: Creating resources using Heat template and check that they are available in Mistral service. == |
− | 1. Create workflow template file nova_actions.yaml . This workflow allows to create nova server. | + | === 1. Create workflow template file nova_actions.yaml . This workflow allows to create nova server. === |
--- | --- | ||
Line 38: | Line 38: | ||
− | 2. Create template with OS::Mistral::Workflow and OS::Mistral::CronTrigger resources (template.yaml). | + | === 2. Create template with OS::Mistral::Workflow and OS::Mistral::CronTrigger resources (template.yaml). === |
heat_template_version: 2013-05-23 | heat_template_version: 2013-05-23 | ||
Line 66: | Line 66: | ||
− | 3. Create stack. | + | === 3. Create stack. === |
heat stack-create test1 -f template.yaml | heat stack-create test1 -f template.yaml | ||
− | 4. Check that resources were created in Mistral. | + | === 4. Check that resources were created in Mistral. === |
mistral workflow-list | mistral workflow-list | ||
− | +--------------------------+--------+------------------------------+---------------------+------------+ | + | <nowiki>+--------------------------+--------+------------------------------+---------------------+------------+ |
| Name | Tags | Input | Created at | Updated at | | | Name | Tags | Input | Created at | Updated at | | ||
+--------------------------+--------+------------------------------+---------------------+------------+ | +--------------------------+--------+------------------------------+---------------------+------------+ | ||
Line 80: | Line 80: | ||
| std.delete_instance | <none> | instance_id | 2015-01-26 00:00:49 | None | | | std.delete_instance | <none> | instance_id | 2015-01-26 00:00:49 | None | | ||
| test1.workflow.create_vm | <none> | vm_name, image_ref, flavo... | 2015-01-26 22:04:12 | None | | | test1.workflow.create_vm | <none> | vm_name, image_ref, flavo... | 2015-01-26 22:04:12 | None | | ||
− | +--------------------------+--------+------------------------------+---------------------+------------+ | + | +--------------------------+--------+------------------------------+---------------------+------------+</nowiki> |
mistral cron-trigger-list | mistral cron-trigger-list |
Revision as of 08:46, 26 February 2015
Case 1: Creating resources using Heat template and check that they are available in Mistral service.
1. Create workflow template file nova_actions.yaml . This workflow allows to create nova server.
--- version: '2.0'
create_vm:
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: $.id on-success: - check_server_exists
check_server_exists: action: nova.servers_get server={$.vm_id} publish: server_exists: True on-success: - wait_instance
wait_instance: action: nova.servers_find id={$.vm_id} status='ACTIVE' policies: retry: delay: 5 count: 15
2. Create template with OS::Mistral::Workflow and OS::Mistral::CronTrigger resources (template.yaml).
heat_template_version: 2013-05-23
parameters:
cron_pattern: type: string default: '54 15 25 * *'
resources:
workflow: type: OS::Mistral::Workflow properties: definition: { get_file: nova_actions.yaml } input: {"vm_name": "test_vm", "image_ref": "64200b6e-9c5e-46d7-a373-676e1335eb24", "flavor_ref": "84"}
trigger: type: OS::Mistral::CronTrigger properties: pattern: { get_param: cron_pattern } workflow: { get_attr: [workflow, available_workflows, create_vm] }
outputs:
execution_time: value: { get_attr: [trigger, next_execution_time] }
3. Create stack.
heat stack-create test1 -f template.yaml
4. Check that resources were created in Mistral.
mistral workflow-list
+--------------------------+--------+------------------------------+---------------------+------------+ | Name | Tags | Input | Created at | Updated at | +--------------------------+--------+------------------------------+---------------------+------------+ | std.create_instance | <none> | name, image_id, flavor_id... | 2015-01-26 00:00:49 | None | | std.delete_instance | <none> | instance_id | 2015-01-26 00:00:49 | None | | test1.workflow.create_vm | <none> | vm_name, image_ref, flavo... | 2015-01-26 22:04:12 | None | +--------------------------+--------+------------------------------+---------------------+------------+
mistral cron-trigger-list
+----------------------------+--------------+--------------------------+---------------------+---------------------+------------+ | Name | Pattern | Workflow | Next execution time | Created at | Updated at | +----------------------------+--------------+--------------------------+---------------------+---------------------+------------+ | test1-trigger-kqetnotnmvsx | 54 15 25 * * | test1.workflow.create_vm | 2015-02-25 15:54:00 | 2015-01-26 22:04:25 | None | +----------------------------+--------------+--------------------------+---------------------+---------------------+------------+