Skip to content

Commit

Permalink
Merge pull request #8225 from abellotti/api_vm_power_ops_zone
Browse files Browse the repository at this point in the history
[api] VM power operations are not queued properly
(cherry picked from commit f495df9)
  • Loading branch information
gtanzillo authored and chessbyte committed Apr 26, 2016
1 parent 4ea32cb commit d01648b
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 d01648b

Please sign in to comment.