Advertisement
greatbn

evacuate.yaml

Jun 30th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.26 KB | None | 0 0
  1. ---
  2. version: '2.0'
  3. evacuate_workflow:
  4.   output:
  5.     list_instances: <% $.list_instances %>
  6.   tasks:
  7.     get_host_failed:
  8.       action: nova.hypervisors_list
  9.       publish:
  10.         list_host_failed: <% task(get_host_failed).result.where($.state = "down").select($.hypervisor_hostname) %>
  11.       on-success:
  12.         - instances_list: <% len($.list_host_failed) > 0 %>
  13.     instances_list:
  14.       action: nova.servers_list
  15.       publish:
  16.         list_instances: <% let(root => $ ) -> task(instances_list).result.where($.get("OS-EXT-SRV-ATTR:hypervisor_hostname") = $root.list_host_failed.first() ).select($.id) %>
  17.       on-success:
  18.         - list_all_hypervisors: <% len($.list_instances) > 0 %>
  19.     list_all_hypervisors:
  20.       action: nova.hypervisors_list
  21.       publish:
  22.         all_hypervisor_active: <% let(root => $) -> task(list_all_hypervisors).result.where($.hypervisor_hostname != $root.list_host_failed.first()).select($.hypervisor_hostname) %>
  23.       on-success:
  24.        - evacuate_instances
  25.     evacuate_instances:
  26.       with-items:
  27.        - instance in <% $.list_instances %>
  28.       action: nova.servers_evacuate server=<% $.instance %> host=<% $.all_hypervisor_active[ random(0,len($.all_hypervisor_active)-1 )] %>
  29.       on-success:
  30.        - succeed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement