(DIO-1522) Show the VM state (running, destroyed) and colorize in red when it has been deleted

the ABS system does not have a real sense of the current state of the resources
it has allocated. When running list --active it can list VMs that have been
deleted or reaped after their lifetime expired.
This change enables to show more information when a vmpooler_fallback service
is provided to ABS, and will show the state (running, destroyed) and colorize
in red when the VM is destroyed.
This commit is contained in:
Samuel Beaulieu 2021-02-25 10:04:30 -06:00
parent 4192631d70
commit 8143641f83
No known key found for this signature in database
GPG key ID: 12030F74136D0F34
2 changed files with 21 additions and 5 deletions

View file

@ -130,8 +130,13 @@ class Utils
tag_pairs = []
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
metadata = [host_data['template'], duration, *tag_pairs]
output_target.puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
if host_data['state'] && host_data['state'] == "destroyed"
output_target.puts message.colorize(:red)
else
output_target.puts message
end
when 'NonstandardPooler'
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
line += ", #{host_data['hours_left_on_reservation']}h remaining"