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
|
|
@ -219,10 +219,12 @@ class Vmfloaty
|
|||
command :delete do |c|
|
||||
c.syntax = 'floaty delete hostname,hostname2 [options]'
|
||||
c.syntax += "\n floaty delete job1,job2 [options] (only supported with ABS)"
|
||||
c.syntax += "\n floaty delete request-id [options] (for ondemand requests)"
|
||||
c.summary = 'Schedules the deletion of a host or hosts'
|
||||
c.description = 'Given a comma separated list of hostnames, or --all for all vms, vmfloaty makes a request to the pooler service to schedule the deletion of those vms. If you are using the ABS service, you can also pass in JobIDs here. Note that passing in a Job ID will delete *all* of the hosts in the job.' # rubocop:disable Layout/LineLength
|
||||
c.description = 'Given a comma separated list of hostnames, or --all for all vms, vmfloaty makes a request to the pooler service to schedule the deletion of those vms. If you are using the ABS service, you can also pass in JobIDs here. Note that passing in a Job ID will delete *all* of the hosts in the job. For vmpooler, you can also pass in a request-id (UUID format) to cancel an ondemand request and move any already-provisioned VMs to the deletion queue.' # rubocop:disable Layout/LineLength
|
||||
c.example 'Schedules the deletion of a host or hosts', 'floaty delete myhost1,myhost2 --url http://vmpooler.example.com'
|
||||
c.example 'Schedules the deletion of a JobID or JobIDs', 'floaty delete 1579300120799,1579300120800 --url http://abs.example.com'
|
||||
c.example 'Cancels an ondemand request and deletes provisioned VMs', 'floaty delete e3ff6271-d201-4f31-a315-d17f4e15863a --url http://vmpooler.example.com'
|
||||
c.option '--verbose', 'Enables verbose output'
|
||||
c.option '--service STRING', String, 'Configured pooler service name'
|
||||
c.option '--all', 'Deletes all vms acquired by a token'
|
||||
|
|
|
|||
|
|
@ -135,9 +135,19 @@ class Pooler
|
|||
response_body = {}
|
||||
|
||||
hosts.each do |host|
|
||||
response = conn.delete "vm/#{host}"
|
||||
res_body = JSON.parse(response.body)
|
||||
response_body[host] = res_body
|
||||
# Check if this looks like a request-id (UUID format)
|
||||
# UUIDs are 36 characters with dashes: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
if host =~ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
# This is a request-id, use the ondemandvm endpoint
|
||||
response = conn.delete "ondemandvm/#{host}"
|
||||
res_body = JSON.parse(response.body)
|
||||
response_body[host] = res_body
|
||||
else
|
||||
# This is a hostname, use the vm endpoint
|
||||
response = conn.delete "vm/#{host}"
|
||||
res_body = JSON.parse(response.body)
|
||||
response_body[host] = res_body
|
||||
end
|
||||
end
|
||||
|
||||
response_body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue