Make query request before printing all vm information

This commit is contained in:
Brian Cain 2015-11-21 13:43:30 -08:00
parent 19255bb3ba
commit 56924fa811
3 changed files with 24 additions and 11 deletions

View file

@ -41,18 +41,31 @@ class Utils
os_types os_types
end end
def self.get_vm_info(hosts, verbose, url)
vms = {}
hosts.each do |host|
vm_info = Pooler.query(verbose, url, host)
if vm_info['ok']
vms[host] = {}
vms[host]['domain'] = vm_info[host]['domain']
vms[host]['template'] = vm_info[host]['template']
vms[host]['lifetime'] = vm_info[host]['lifetime']
vms[host]['running'] = vm_info[host]['running']
end
end
vms
end
def self.prettyprint_hosts(hosts, verbose, url) def self.prettyprint_hosts(hosts, verbose, url)
puts "Running VMs:" puts "Running VMs:"
hosts.each do |vm| vm_info = get_vm_info(hosts, verbose, url)
vm_info = Pooler.query(verbose, url, vm) vm_info.each do |vm,info|
if vm_info['ok'] domain = info['domain']
domain = vm_info[vm]['domain'] template = info['template']
template = vm_info[vm]['template'] lifetime = info['lifetime']
lifetime = vm_info[vm]['lifetime'] running = info['running']
running = vm_info[vm]['running']
puts "- #{vm}.#{domain} (#{template}, #{running}/#{lifetime} hours)" puts "- #{vm}.#{domain} (#{template}, #{running}/#{lifetime} hours)"
end end
end end
end end
end

View file

@ -1,6 +1,6 @@
class Version class Version
@version = '0.2.18' @version = '0.2.19'
def self.get def self.get
@version @version

View file

@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'vmfloaty' s.name = 'vmfloaty'
s.version = '0.2.18' s.version = '0.2.19'
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'