mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
(rubocop) Fix Layout/CaseIndentation
This commit is contained in:
parent
f2ab052fa4
commit
f2167f8be7
2 changed files with 70 additions and 70 deletions
|
|
@ -371,23 +371,23 @@ class Vmfloaty
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case action
|
case action
|
||||||
when 'get'
|
when 'get'
|
||||||
token = service.get_new_token(verbose)
|
token = service.get_new_token(verbose)
|
||||||
puts token
|
puts token
|
||||||
when 'delete'
|
when 'delete'
|
||||||
result = service.delete_token(verbose, options.token)
|
result = service.delete_token(verbose, options.token)
|
||||||
puts result
|
puts result
|
||||||
when 'status'
|
when 'status'
|
||||||
token_value = options.token
|
token_value = options.token
|
||||||
token_value = args[1] if token_value.nil?
|
token_value = args[1] if token_value.nil?
|
||||||
status = service.token_status(verbose, token_value)
|
status = service.token_status(verbose, token_value)
|
||||||
puts status
|
puts status
|
||||||
when nil
|
when nil
|
||||||
STDERR.puts 'No action provided'
|
STDERR.puts 'No action provided'
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
STDERR.puts "Unknown action: #{action}"
|
STDERR.puts "Unknown action: #{action}"
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
rescue TokenError => e
|
rescue TokenError => e
|
||||||
STDERR.puts e
|
STDERR.puts e
|
||||||
|
|
|
||||||
|
|
@ -84,24 +84,24 @@ class Utils
|
||||||
host_data = response[hostname]
|
host_data = response[hostname]
|
||||||
|
|
||||||
case service.type
|
case service.type
|
||||||
when 'Pooler'
|
when 'Pooler'
|
||||||
tag_pairs = []
|
tag_pairs = []
|
||||||
unless host_data['tags'].nil?
|
unless host_data['tags'].nil?
|
||||||
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" }
|
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" }
|
||||||
end
|
end
|
||||||
duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
|
duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
|
||||||
metadata = [host_data['template'], duration, *tag_pairs]
|
metadata = [host_data['template'], duration, *tag_pairs]
|
||||||
puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})"
|
puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})"
|
||||||
when 'NonstandardPooler'
|
when 'NonstandardPooler'
|
||||||
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
|
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
|
||||||
line += ", #{host_data['hours_left_on_reservation']}h remaining"
|
line += ", #{host_data['hours_left_on_reservation']}h remaining"
|
||||||
unless host_data['reserved_for_reason'].empty?
|
unless host_data['reserved_for_reason'].empty?
|
||||||
line += ", reason: #{host_data['reserved_for_reason']}"
|
line += ", reason: #{host_data['reserved_for_reason']}"
|
||||||
end
|
end
|
||||||
line += ')'
|
line += ')'
|
||||||
puts line
|
puts line
|
||||||
else
|
else
|
||||||
raise "Invalid service type #{service.type}"
|
raise "Invalid service type #{service.type}"
|
||||||
end
|
end
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
STDERR.puts("Something went wrong while trying to gather information on #{hostname}:")
|
STDERR.puts("Something went wrong while trying to gather information on #{hostname}:")
|
||||||
|
|
@ -114,45 +114,45 @@ class Utils
|
||||||
status_response = service.status(verbose)
|
status_response = service.status(verbose)
|
||||||
|
|
||||||
case service.type
|
case service.type
|
||||||
when 'Pooler'
|
when 'Pooler'
|
||||||
message = status_response['status']['message']
|
message = status_response['status']['message']
|
||||||
pools = status_response['pools']
|
pools = status_response['pools']
|
||||||
pools.select! { |_, pool| pool['ready'] < pool['max'] } unless verbose
|
pools.select! { |_, pool| pool['ready'] < pool['max'] } unless verbose
|
||||||
|
|
||||||
width = pools.keys.map(&:length).max
|
width = pools.keys.map(&:length).max
|
||||||
pools.each do |name, pool|
|
pools.each do |name, pool|
|
||||||
begin
|
begin
|
||||||
max = pool['max']
|
max = pool['max']
|
||||||
ready = pool['ready']
|
ready = pool['ready']
|
||||||
pending = pool['pending']
|
pending = pool['pending']
|
||||||
missing = max - ready - pending
|
missing = max - ready - pending
|
||||||
char = 'o'
|
char = 'o'
|
||||||
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
puts "#{name.ljust(width)} #{e.red}"
|
puts "#{name.ljust(width)} #{e.red}"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
puts message.colorize(status_response['status']['ok'] ? :default : :red)
|
end
|
||||||
when 'NonstandardPooler'
|
puts message.colorize(status_response['status']['ok'] ? :default : :red)
|
||||||
pools = status_response
|
when 'NonstandardPooler'
|
||||||
pools.delete 'ok'
|
pools = status_response
|
||||||
pools.select! { |_, pool| pool['available_hosts'] < pool['total_hosts'] } unless verbose
|
pools.delete 'ok'
|
||||||
|
pools.select! { |_, pool| pool['available_hosts'] < pool['total_hosts'] } unless verbose
|
||||||
|
|
||||||
width = pools.keys.map(&:length).max
|
width = pools.keys.map(&:length).max
|
||||||
pools.each do |name, pool|
|
pools.each do |name, pool|
|
||||||
begin
|
begin
|
||||||
max = pool['total_hosts']
|
max = pool['total_hosts']
|
||||||
ready = pool['available_hosts']
|
ready = pool['available_hosts']
|
||||||
pending = pool['pending'] || 0 # not available for nspooler
|
pending = pool['pending'] || 0 # not available for nspooler
|
||||||
missing = max - ready - pending
|
missing = max - ready - pending
|
||||||
char = 'o'
|
char = 'o'
|
||||||
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
puts "#{name.ljust(width)} #{e.red}"
|
puts "#{name.ljust(width)} #{e.red}"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
raise "Invalid service type #{service.type}"
|
else
|
||||||
|
raise "Invalid service type #{service.type}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue