The main goal for this PR is to enable using all of the vmfloaty scenarios when

the service is set to ABS. Since ABS does not implement all the services, it
fallsback on vmpooler when needed (example increasing the lifetime value)

- Validating JSON can be parsed before parsing, as it used to throw uncaught errors
- self.list_active is returning hosts for both nspooler and vmpooler but was returning
job_ids for abs. Now standardized the returned values for use in the "modify" cli,
and created a separate list_active_job_ids for the cases where a job_id list is expected

- added a way to change the service in place for methods that do not make sense
for ABS, and instead fallback on using vmpooler in those cases:
1. summary
2. modify
3. snapshot
4. revert
5. disk
For those methods in the class itself, raising a NoMethodError, in case it is used directly

- query now returns the queue info. For information on VMs, users should use --service vmpooler
- pretty_print_hosts (used in list, and delete scenarios) will now print the job_id
ABS information and indent each VM within and print it's metadata. Useful for
knowing the running time and extending it.

- added a new utility method to get the config for the vmpooler service, used for the fallback
- added a passthrough for the vmpooler token to use when running ABS. This enables
vmpooler to track the VMs used by each token (user). Also aligns the list between
both ABS and vmpooler. Fixes the bit-bar issue where the VMs do not appear when created
via ABS
This commit is contained in:
Samuel Beaulieu 2020-09-10 13:49:46 -05:00
parent 5a0640c515
commit dbf6c54173
4 changed files with 166 additions and 51 deletions

View file

@ -99,7 +99,12 @@ class Vmfloaty
if options.active
# list active vms
running_vms = service.list_active(verbose)
if service.type == "ABS"
# this is actually job_ids
running_vms = service.list_active_job_ids(verbose, service.url, service.user)
else
running_vms = service.list_active(verbose)
end
host = URI.parse(service.url).host
if running_vms.empty?
if options.json
@ -126,7 +131,7 @@ class Vmfloaty
command :query do |c|
c.syntax = 'floaty query hostname [options]'
c.summary = 'Get information about a given vm'
c.description = 'Given a hostname from the pooler service, vmfloaty with query the service to get various details about the vm.'
c.description = 'Given a hostname from the pooler service, vmfloaty with query the service to get various details about the vm. If using ABS, you can query a job_id'
c.example 'Get information about a sample host', 'floaty query hostname --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output'
c.option '--service STRING', String, 'Configured pooler service name'
@ -165,7 +170,12 @@ class Vmfloaty
FloatyLogger.error 'ERROR: Provide a hostname or specify --all.'
exit 1
end
running_vms = modify_all ? service.list_active(verbose) : hostname.split(',')
running_vms =
if modify_all
service.list_active(verbose)
else
hostname.split(',')
end
tags = options.tags ? JSON.parse(options.tags) : nil
modify_hash = {
@ -189,7 +199,7 @@ class Vmfloaty
end
if ok
if modify_all
puts 'Successfully modified all VMs.'
puts "Successfully modified all #{running_vms.count} VMs."
else
puts "Successfully modified VM #{hostname}."
end
@ -225,7 +235,12 @@ class Vmfloaty
successes = []
if delete_all
running_vms = service.list_active(verbose)
if service.type == "ABS"
# this is actually job_ids
running_vms = service.list_active_job_ids(verbose, service.url, service.user)
else
running_vms = service.list_active(verbose)
end
if running_vms.empty?
if options.json
puts {}.to_json
@ -274,7 +289,6 @@ class Vmfloaty
end
unless successes.empty?
FloatyLogger.info unless failures.empty?
if options.json
puts successes.to_json
else