Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- version: '2.0'
- evacuate_workflow:
- output:
- list_instances: <% $.list_instances %>
- tasks:
- get_host_failed:
- action: nova.hypervisors_list
- publish:
- list_host_failed: <% task(get_host_failed).result.where($.state = "down").select($.hypervisor_hostname) %>
- on-success:
- - instances_list: <% len($.list_host_failed) > 0 %>
- instances_list:
- action: nova.servers_list
- publish:
- list_instances: <% let(root => $ ) -> task(instances_list).result.where($.get("OS-EXT-SRV-ATTR:hypervisor_hostname") = $root.list_host_failed.first() ).select($.id) %>
- on-success:
- - list_all_hypervisors: <% len($.list_instances) > 0 %>
- list_all_hypervisors:
- action: nova.hypervisors_list
- publish:
- all_hypervisor_active: <% let(root => $) -> task(list_all_hypervisors).result.where($.hypervisor_hostname != $root.list_host_failed.first()).select($.hypervisor_hostname) %>
- on-success:
- - evacuate_instances
- evacuate_instances:
- with-items:
- - instance in <% $.list_instances %>
- action: nova.servers_evacuate server=<% $.instance %> host=<% $.all_hypervisor_active[ random(0,len($.all_hypervisor_active)-1 )] %>
- on-success:
- - succeed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement