mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Add support for deleting ondemand requests by request-id
This change enables floaty delete to accept request-ids (UUID format) in addition to hostnames. When a request-id is detected, floaty will: 1. Cancel pending ondemand requests by marking status as 'deleted' 2. Move any already-provisioned VMs to the termination queue Implementation: - Modified Pooler.delete to detect UUID format and use ondemandvm endpoint - Updated command syntax and examples to document request-id support - Added comprehensive tests for request-id deletion - Fixed Ruby 3.1+ compatibility by adding abbrev and base64 gems Fixes issue where users had no way to cancel ondemand requests or bulk-delete VMs from a completed request.
This commit is contained in:
parent
6b6d6f73cd
commit
4686213f49
6 changed files with 299 additions and 4 deletions
|
|
@ -145,6 +145,57 @@ describe Pooler do
|
|||
it 'raises a token error if no token provided' do
|
||||
expect { Pooler.delete(false, @vmpooler_url, ['myfakehost'], nil, nil) }.to raise_error(TokenError)
|
||||
end
|
||||
|
||||
context 'with ondemand request-id (UUID format)' do
|
||||
before :each do
|
||||
@request_id = 'e3ff6271-d201-4f31-a315-d17f4e15863a'
|
||||
@delete_request_response = { @request_id => { 'ok' => true } }
|
||||
end
|
||||
|
||||
it 'deletes an ondemand request via the ondemandvm endpoint' do
|
||||
stub_request(:delete, "#{@vmpooler_url}/ondemandvm/#{@request_id}")
|
||||
.with(headers: { 'X-Auth-Token' => 'mytokenfile' })
|
||||
.to_return(status: 200, body: @delete_response_body_success, headers: {})
|
||||
|
||||
expect(Pooler.delete(false, @vmpooler_url, [@request_id], 'mytokenfile', nil)).to eq @delete_request_response
|
||||
end
|
||||
|
||||
it 'handles multiple request-ids' do
|
||||
request_id_2 = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
|
||||
expected_response = {
|
||||
@request_id => { 'ok' => true },
|
||||
request_id_2 => { 'ok' => true }
|
||||
}
|
||||
|
||||
stub_request(:delete, "#{@vmpooler_url}/ondemandvm/#{@request_id}")
|
||||
.with(headers: { 'X-Auth-Token' => 'mytokenfile' })
|
||||
.to_return(status: 200, body: @delete_response_body_success, headers: {})
|
||||
|
||||
stub_request(:delete, "#{@vmpooler_url}/ondemandvm/#{request_id_2}")
|
||||
.with(headers: { 'X-Auth-Token' => 'mytokenfile' })
|
||||
.to_return(status: 200, body: @delete_response_body_success, headers: {})
|
||||
|
||||
expect(Pooler.delete(false, @vmpooler_url, [@request_id, request_id_2], 'mytokenfile', nil)).to eq expected_response
|
||||
end
|
||||
|
||||
it 'handles mixed hostnames and request-ids' do
|
||||
hostname = 'myvm-hostname'
|
||||
expected_response = {
|
||||
hostname => { 'ok' => true },
|
||||
@request_id => { 'ok' => true }
|
||||
}
|
||||
|
||||
stub_request(:delete, "#{@vmpooler_url}/vm/#{hostname}")
|
||||
.with(headers: { 'X-Auth-Token' => 'mytokenfile' })
|
||||
.to_return(status: 200, body: @delete_response_body_success, headers: {})
|
||||
|
||||
stub_request(:delete, "#{@vmpooler_url}/ondemandvm/#{@request_id}")
|
||||
.with(headers: { 'X-Auth-Token' => 'mytokenfile' })
|
||||
.to_return(status: 200, body: @delete_response_body_success, headers: {})
|
||||
|
||||
expect(Pooler.delete(false, @vmpooler_url, [hostname, @request_id], 'mytokenfile', nil)).to eq expected_response
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#status' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue