Skip to content

Commit

Permalink
Add user id argument for vm retire queueing to match the backend method
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Feb 26, 2020
1 parent 086814a commit 13f33f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/vms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def request_console_vm(vm, protocol)
def request_retire(virtual_machine)
desc = "#{vm_ident(virtual_machine)} request retire"

task_id = queue_object_action(virtual_machine, desc, queue_options("make_retire_request", "automate"))
task_id = queue_object_action(virtual_machine, desc, :method_name => "make_retire_request", :role => "automate", :args => [User.current_user.id])
action_result(true, desc, :task_id => task_id)
rescue StandardError => err
action_result(false, err.to_s)
Expand Down
16 changes: 16 additions & 0 deletions spec/requests/vms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,22 @@ def update_raw_power_state(state, *vms)
expect(response.parsed_body).to include(expected)
end

it "queues retirement task" do
api_basic_authorize(action_identifier(:vms, :request_retire))
message = "VM id:#{vm.id} name:'#{vm.name}' request retire"
task_id = MiqTask.find_by(:name => message)&.id
expect(task_id).to be_nil
expect(MiqRequest.count).to eq(0)

post(vm_url, :params => gen_request(:request_retire))

task = MiqTask.find_by(:name => message)

MiqTask.find(task.id).miq_queue.deliver

expect(MiqQueue.count).to eq(1)
end

it "to multiple Vms" do
api_basic_authorize(collection_action_identifier(:vms, :request_retire))
message_vm1 = "VM id:#{vm1.id} name:'#{vm1.name}' request retire"
Expand Down

0 comments on commit 13f33f0

Please sign in to comment.