Skip to content

Commit

Permalink
[api] VM power operations are not queued properly
Browse files Browse the repository at this point in the history
When queueing VM power or smartstate operations, the zone was not getting
specified for the queue so in environments with providers in different zones,
those providers were not getting the task to perform on those VMs.

This fixes: #7998

https://bugzilla.redhat.com/show_bug.cgi?id=1326955
  • Loading branch information
abellotti committed Apr 25, 2016
1 parent 74e87d9 commit 7b76cc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/api_controller/action.rb
Expand Up @@ -26,6 +26,8 @@ def queue_object_action(object, summary, options)
:role => options[:role] || nil,
}

queue_options[:zone] = object.my_zone if %w(ems_operations smartstate).include?(options[:role])

MiqTask.generic_action_with_callback(task_options, queue_options)
end
end
Expand Down
13 changes: 13 additions & 0 deletions spec/requests/api/vms_spec.rb
Expand Up @@ -177,6 +177,19 @@ def update_raw_power_state(state, *vms)
expect_single_action_result(:success => true, :message => "starting", :href => :vm_url, :task => true)
end

it "starting a vm queues it properly" do
api_basic_authorize action_identifier(:vms, :start)
update_raw_power_state("poweredOff", vm)

run_post(vm_url, gen_request(:start))

expect_single_action_result(:success => true, :message => "starting", :href => :vm_url, :task => true)
expect(MiqQueue.where(:class_name => vm.class.name,
:instance_id => vm.id,
:method_name => "start",
:zone => zone.name).count).to eq(1)
end

it "starts multiple vms" do
api_basic_authorize action_identifier(:vms, :start)
update_raw_power_state("poweredOff", vm1, vm2)
Expand Down

0 comments on commit 7b76cc4

Please sign in to comment.