mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 13:28:42 -05:00
Move pretty status printing to Utils namespace and out of commands
This commit is contained in:
parent
5f0ace0c82
commit
b023339516
4 changed files with 25 additions and 20 deletions
|
|
@ -427,24 +427,7 @@ class Vmfloaty
|
||||||
if options.json
|
if options.json
|
||||||
pp status
|
pp status
|
||||||
else
|
else
|
||||||
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
|
Utils.prettyprint_status(status, message, pools, 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
|
||||||
|
|
||||||
exit status['status']['ok']
|
exit status['status']['ok']
|
||||||
|
|
@ -464,6 +447,7 @@ class Vmfloaty
|
||||||
|
|
||||||
summary = Pooler.summary(verbose, url)
|
summary = Pooler.summary(verbose, url)
|
||||||
pp summary
|
pp summary
|
||||||
|
exit 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,4 +92,25 @@ class Utils
|
||||||
running_vms = vms['running']
|
running_vms = vms['running']
|
||||||
running_vms
|
running_vms
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
class Version
|
class Version
|
||||||
@version = '0.7.4'
|
@version = '0.7.5'
|
||||||
|
|
||||||
def self.get
|
def self.get
|
||||||
@version
|
@version
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'vmfloaty'
|
s.name = 'vmfloaty'
|
||||||
s.version = '0.7.4'
|
s.version = '0.7.5'
|
||||||
s.authors = ['Brian Cain']
|
s.authors = ['Brian Cain']
|
||||||
s.email = ['brian.cain@puppetlabs.com']
|
s.email = ['brian.cain@puppetlabs.com']
|
||||||
s.license = 'Apache'
|
s.license = 'Apache'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue