Simplify the create_instance default workflow
This new create_instance will now use name instead of ID, like openstack cli. Also get rid of SSH connection and Floating IP. Change-Id: Iad120ce5fe4533098d3e9208c7a958a8391dcf69 Signed-off-by: Arnaud M <arnaud.morin@gmail.com>
This commit is contained in:
@@ -5,84 +5,71 @@ create_instance:
|
||||
type: direct
|
||||
|
||||
description: |
|
||||
Creates VM and waits till VM OS is up and running.
|
||||
Creates instance and waits till instance OS is up and running.
|
||||
|
||||
input:
|
||||
- name
|
||||
- image_id
|
||||
- flavor_id
|
||||
- ssh_username: null
|
||||
- ssh_password: null
|
||||
|
||||
# Name of previously created keypair to inject into the instance.
|
||||
# Either ssh credentials or keypair must be provided.
|
||||
- key_name: null
|
||||
|
||||
# Security_groups: A list of security group names
|
||||
- security_groups: null
|
||||
|
||||
# An ordered list of nics to be added to this server, with information about connected networks, fixed IPs, port etc.
|
||||
# Example: nics: [{"net-id": "27aa8c1c-d6b8-4474-b7f7-6cdcf63ac856"}]
|
||||
- nics: null
|
||||
|
||||
task-defaults:
|
||||
on-error:
|
||||
- delete_vm
|
||||
- image
|
||||
- flavor
|
||||
- keypair
|
||||
- network
|
||||
|
||||
output:
|
||||
ip: <% $.vm_ip %>
|
||||
id: <% $.vm_id %>
|
||||
name: <% $.name %>
|
||||
status: <% $.status %>
|
||||
|
||||
tasks:
|
||||
get_image:
|
||||
description: Get image ID from name
|
||||
action: glance.images_list
|
||||
input:
|
||||
name: <% $.image %>
|
||||
publish:
|
||||
image_id: <% task().result[0].id %>
|
||||
on-success:
|
||||
- create_vm
|
||||
|
||||
get_flavor:
|
||||
description: Get flavor ID from name
|
||||
action: nova.flavors_find
|
||||
input:
|
||||
name: <% $.flavor %>
|
||||
publish:
|
||||
flavor_id: <% task().result.id %>
|
||||
on-success:
|
||||
- create_vm
|
||||
|
||||
get_network:
|
||||
description: Get network ID from name
|
||||
action: neutron.list_networks
|
||||
input:
|
||||
name: <% $.network %>
|
||||
publish:
|
||||
network_id: <% task().result.networks[0].id %>
|
||||
on-success:
|
||||
- create_vm
|
||||
|
||||
create_vm:
|
||||
description: Initial request to create a VM.
|
||||
join: all
|
||||
description: Create an instance
|
||||
action: nova.servers_create name=<% $.name %> image=<% $.image_id %> flavor=<% $.flavor_id %>
|
||||
input:
|
||||
key_name: <% $.key_name %>
|
||||
security_groups: <% $.security_groups %>
|
||||
nics: <% $.nics %>
|
||||
name: <% $.name %>
|
||||
image: <% $.image_id %>
|
||||
flavor: <% $.flavor_id %>
|
||||
key_name: <% $.keypair %>
|
||||
nics: [{ "net-id": <% $.network_id %> }]
|
||||
publish:
|
||||
vm_id: <% task(create_vm).result.id %>
|
||||
on-success:
|
||||
- search_for_ip
|
||||
|
||||
search_for_ip:
|
||||
description: Gets first free ip from Nova floating IPs.
|
||||
action: nova.floating_ips_findall instance_id=null
|
||||
publish:
|
||||
vm_ip: <% task(search_for_ip).result[0].ip %>
|
||||
on-success:
|
||||
- wait_vm_active
|
||||
|
||||
wait_vm_active:
|
||||
description: Waits till VM is ACTIVE.
|
||||
description: Waits till instance is ACTIVE.
|
||||
action: nova.servers_find id=<% $.vm_id %> status="ACTIVE"
|
||||
retry:
|
||||
count: 10
|
||||
delay: 10
|
||||
publish:
|
||||
status: <% task(wait_vm_active).result.status %>
|
||||
on-success:
|
||||
- associate_ip
|
||||
|
||||
associate_ip:
|
||||
description: Associate server with one of floating IPs.
|
||||
action: nova.servers_add_floating_ip server=<% $.vm_id %> address=<% $.vm_ip %>
|
||||
wait-after: 5
|
||||
on-success:
|
||||
- wait_ssh
|
||||
|
||||
wait_ssh:
|
||||
description: Wait till operating system on the VM is up (SSH command).
|
||||
action: std.wait_ssh username=<% $.ssh_username %> password=<% $.ssh_password %> host=<% $.vm_ip %>
|
||||
retry:
|
||||
count: 10
|
||||
delay: 10
|
||||
|
||||
delete_vm:
|
||||
description: Destroy VM.
|
||||
workflow: delete_instance instance_id=<% $.vm_id %>
|
||||
on-complete:
|
||||
- fail
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Update the create_instance default workflow to simplify it.
|
||||
Now it will use names instead of ID as input.
|
||||
Also get rid of floating IP and wait_ssh tasks for simplicity.
|
||||
Reference in New Issue
Block a user