mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Move pretty status printing to Utils namespace and out of commands
This commit is contained in:
parent
5f0ace0c82
commit
2c04ab162a
4 changed files with 25 additions and 20 deletions
|
|
@ -427,24 +427,7 @@ class Vmfloaty
|
|||
if options.json
|
||||
pp status
|
||||
else
|
||||
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
|
||||
|
||||
width = pools.keys.map(&:length).max
|
||||
pools.each do |name,pool|
|
||||
begin
|
||||
max = pool['max']
|
||||
ready = pool['ready']
|
||||
pending = pool['pending']
|
||||
missing = max - ready - pending
|
||||
char = 'o'
|
||||
puts "#{name.ljust(width)} #{(char*ready).green}#{(char*pending).yellow}#{(char*missing).red}"
|
||||
rescue => e
|
||||
puts "#{name.ljust(width)} #{e.red}"
|
||||
end
|
||||
end
|
||||
|
||||
puts
|
||||
puts message.colorize(status['status']['ok'] ? :default : :red)
|
||||
Utils.prettyprint_status(status, message, pools, verbose)
|
||||
end
|
||||
|
||||
exit status['status']['ok']
|
||||
|
|
@ -464,6 +447,7 @@ class Vmfloaty
|
|||
|
||||
summary = Pooler.summary(verbose, url)
|
||||
pp summary
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -92,4 +92,25 @@ class Utils
|
|||
running_vms = vms['running']
|
||||
running_vms
|
||||
end
|
||||
|
||||
def self.prettyprint_status(status, message, pools, verbose)
|
||||
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
|
||||
|
||||
width = pools.keys.map(&:length).max
|
||||
pools.each do |name,pool|
|
||||
begin
|
||||
max = pool['max']
|
||||
ready = pool['ready']
|
||||
pending = pool['pending']
|
||||
missing = max - ready - pending
|
||||
char = 'o'
|
||||
puts "#{name.ljust(width)} #{(char*ready).green}#{(char*pending).yellow}#{(char*missing).red}"
|
||||
rescue => e
|
||||
puts "#{name.ljust(width)} #{e.red}"
|
||||
end
|
||||
end
|
||||
|
||||
puts
|
||||
puts message.colorize(status['status']['ok'] ? :default : :red)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
class Version
|
||||
@version = '0.7.4'
|
||||
@version = '0.7.5'
|
||||
|
||||
def self.get
|
||||
@version
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Gem::Specification.new do |s|
|
||||
s.name = 'vmfloaty'
|
||||
s.version = '0.7.4'
|
||||
s.version = '0.7.5'
|
||||
s.authors = ['Brian Cain']
|
||||
s.email = ['brian.cain@puppetlabs.com']
|
||||
s.license = 'Apache'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue