mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Print all non-success output to STDERR
This commit is contained in:
parent
d843066a56
commit
4755343df2
5 changed files with 47 additions and 56 deletions
|
|
@ -45,7 +45,7 @@ class Utils
|
|||
|
||||
result = {}
|
||||
|
||||
STDOUT.puts "response body is #{response_body}"
|
||||
STDERR.puts "response body is #{response_body}"
|
||||
filtered_response_body = response_body.reject { |key, _| key == 'request_id' || key == 'ready' }
|
||||
filtered_response_body.each do |os, value|
|
||||
hostnames = Array(value['hostname'])
|
||||
|
|
@ -79,7 +79,7 @@ class Utils
|
|||
os_types
|
||||
end
|
||||
|
||||
def self.pretty_print_hosts(verbose, service, hostnames = [])
|
||||
def self.pretty_print_hosts(verbose, service, hostnames = [], print_to_stderr = false)
|
||||
hostnames = [hostnames] unless hostnames.is_a? Array
|
||||
hostnames.each do |hostname|
|
||||
begin
|
||||
|
|
@ -91,7 +91,7 @@ class Utils
|
|||
# For ABS, 'hostname' variable is the jobID
|
||||
if host_data['state'] == 'allocated' || host_data['state'] == 'filled'
|
||||
host_data['allocated_resources'].each do |vm_name, _i|
|
||||
puts "- [JobID:#{host_data['request']['job']['id']}] #{vm_name['hostname']} (#{vm_name['type']}) <#{host_data['state']}>"
|
||||
STDOUT.puts "- [JobID:#{host_data['request']['job']['id']}] #{vm_name['hostname']} (#{vm_name['type']}) <#{host_data['state']}>"
|
||||
end
|
||||
end
|
||||
when 'Pooler'
|
||||
|
|
@ -99,13 +99,13 @@ 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['template'], duration, *tag_pairs]
|
||||
puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})"
|
||||
STDOUT.puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})"
|
||||
when 'NonstandardPooler'
|
||||
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
|
||||
line += ", #{host_data['hours_left_on_reservation']}h remaining"
|
||||
line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].empty?
|
||||
line += ')'
|
||||
puts line
|
||||
STDOUT.puts line
|
||||
else
|
||||
raise "Invalid service type #{service.type}"
|
||||
end
|
||||
|
|
@ -133,12 +133,12 @@ class Utils
|
|||
pending = pool['pending']
|
||||
missing = max - ready - pending
|
||||
char = 'o'
|
||||
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||
STDOUT.puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||
rescue StandardError => e
|
||||
puts "#{name.ljust(width)} #{e.red}"
|
||||
STDERR.puts "#{name.ljust(width)} #{e.red}"
|
||||
end
|
||||
end
|
||||
puts message.colorize(status_response['status']['ok'] ? :default : :red)
|
||||
STDOUT.puts message.colorize(status_response['status']['ok'] ? :default : :red)
|
||||
when 'NonstandardPooler'
|
||||
pools = status_response
|
||||
pools.delete 'ok'
|
||||
|
|
@ -152,14 +152,14 @@ class Utils
|
|||
pending = pool['pending'] || 0 # not available for nspooler
|
||||
missing = max - ready - pending
|
||||
char = 'o'
|
||||
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||
STDOUT.puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||
rescue StandardError => e
|
||||
puts "#{name.ljust(width)} #{e.red}"
|
||||
STDERR.puts "#{name.ljust(width)} #{e.red}"
|
||||
end
|
||||
end
|
||||
when 'ABS'
|
||||
puts 'ABS Not OK'.red unless status_response
|
||||
puts 'ABS is OK'.green if status_response
|
||||
STDERR.puts 'ABS Not OK'.red unless status_response
|
||||
STDOUT.puts 'ABS is OK'.green if status_response
|
||||
else
|
||||
raise "Invalid service type #{service.type}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue