Represents a Physical host which runs the libvirt daemon
# File lib/virt/host.rb, line 6 def initialize @connection = Virt.connection.connection end
# File lib/virt/host.rb, line 24 def defined_guests connection.list_defined_domains.map do |domain| find_guest_by_name domain end end
# File lib/virt/host.rb, line 54 def find_guest_by_id id Array(id).map do |did| return create_guest({:name => connection.lookup_domain_by_id(did).name}) end end
# File lib/virt/host.rb, line 48 def find_guest_by_name name if connection.lookup_domain_by_name name return create_guest({:name => name}) end end
# File lib/virt/host.rb, line 14 def guests {:running => running_guests, :defined => defined_guests} end
# File lib/virt/host.rb, line 10 def name connection.hostname end
# File lib/virt/host.rb, line 18 def running_guests connection.list_domains.map do |domain| find_guest_by_id(domain) end end
Returns a Virt::Pool object based on the pool name
# File lib/virt/host.rb, line 34 def storage_pool pool create_pool({:name => pool.is_a?(Libvirt::StoragePool) ? pool.name : pool }) rescue Libvirt::RetrieveError end
# File lib/virt/host.rb, line 29 def storage_pools connection.list_storage_pools.map {|p| create_pool({:name => p})} end
Returns a hash of pools and their volumes objects.
# File lib/virt/host.rb, line 40 def volumes pools = {} storage_pools.each do |storage| pools[storage.name] = storage.volumes end pools end
# File lib/virt/host.rb, line 62 def create_guest opts Virt::Guest.new opts end
# File lib/virt/host.rb, line 66 def create_pool opts Virt::Pool.new opts end