Fix floaty list --active for vmpooler api v2

This commit is contained in:
Jake Spain 2023-03-20 14:00:17 -04:00
parent 15d9da4514
commit d5d87ed54a
No known key found for this signature in database
GPG key ID: BC1C4DA0A085E113
2 changed files with 75 additions and 2 deletions

View file

@ -150,7 +150,14 @@ class Utils
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['state'], host_data['template'], duration, *tag_pairs]
message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
# For backwards compatibility with vmpooler api v1
message =
if host_data['domain']
"- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
else
"- #{host_data['fqdn']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
end
if host_data['state'] && host_data['state'] == 'destroyed'
output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
else