Added libvirt_memorysize and libvirt_processorcount facts
This commit is contained in:
parent
0efc6d58d4
commit
c7c11cf83c
1 changed files with 44 additions and 2 deletions
|
@ -13,7 +13,7 @@ Facter.add(:libvirt_activedomains) do
|
||||||
doms.sort.join(',')
|
doms.sort.join(',')
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
Facter.debug('ruby-libvirt not available')
|
Facter.debug('ruby-libvirt not available')
|
||||||
rescue Exception
|
rescue Libvirt::ConnectionError
|
||||||
Facter.debug('libvirt connection failed')
|
Facter.debug('libvirt connection failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,49 @@ Facter.add(:libvirt_inactivedomains) do
|
||||||
doms.sort.join(',')
|
doms.sort.join(',')
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
Facter.debug('ruby-libvirt not available')
|
Facter.debug('ruby-libvirt not available')
|
||||||
rescue Exception
|
rescue Libvirt::ConnectionError
|
||||||
|
Facter.debug('libvirt connection failed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Facter.add(:libvirt_memorysize) do
|
||||||
|
confine :kernel => :linux
|
||||||
|
setcode do
|
||||||
|
begin
|
||||||
|
require 'libvirt'
|
||||||
|
conn = Libvirt::open_read_only('qemu:///system')
|
||||||
|
val = 0
|
||||||
|
conn.list_domains.each do |domid|
|
||||||
|
dom = conn.lookup_domain_by_id(domid)
|
||||||
|
val += dom.max_memory
|
||||||
|
end
|
||||||
|
conn.close
|
||||||
|
Facter::Memory.scale_number(val.to_f, "kB")
|
||||||
|
rescue LoadError
|
||||||
|
Facter.debug('ruby-libvirt not available')
|
||||||
|
rescue Libvirt::ConnectionError
|
||||||
|
Facter.debug('libvirt connection failed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Facter.add(:libvirt_processorcount) do
|
||||||
|
confine :kernel => :linux
|
||||||
|
setcode do
|
||||||
|
begin
|
||||||
|
require 'libvirt'
|
||||||
|
conn = Libvirt::open_read_only('qemu:///system')
|
||||||
|
val = 0
|
||||||
|
conn.list_domains.each do |domid|
|
||||||
|
dom = conn.lookup_domain_by_id(domid)
|
||||||
|
val += dom.max_vcpus
|
||||||
|
end
|
||||||
|
conn.close
|
||||||
|
val.to_s
|
||||||
|
rescue LoadError
|
||||||
|
Facter.debug('ruby-libvirt not available')
|
||||||
|
rescue Libvirt::ConnectionError
|
||||||
Facter.debug('libvirt connection failed')
|
Facter.debug('libvirt connection failed')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue