Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 3dcd28b9c0
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (48 sloc) 1.615 kB
class Chef
class Knife
class LibvirtHostList < Knife
deps do
require 'chef/knife/bootstrap'
Chef::Knife::Bootstrap.load_deps
end
banner "knife libvirt host list (options)"
def run
#TODO change hosts config in knife.rb, list hosts
end
end
class LibvirtHostShow < Knife
deps do
require 'chef/knife/bootstrap'
require 'libvirt'
Chef::Knife::Bootstrap.load_deps
end
def to_mb(kb)
(kb/1024.0).round(2)
end
banner "knife libvirt host show HOST (options)"
def run
#TODO format for display
@name_args.each do |host|
puts "Host: #{host}"
uri = "qemu+tls://#{host}/system?pkipath=#{Chef::Config[:knife][:libvirt_tls_path]}/#{host}"
connection = Libvirt::open(uri)
info = connection.node_get_info
puts "URI: #{connection.uri}"
puts "Encrypted connection: #{connection.encrypted?}"
puts "Secure connection: #{connection.secure?}"
puts "Hypervisor: #{connection.type}"
puts "Hypervisor Version: #{connection.version}"
puts "Libvirt Version: #{connection.libversion}"
puts "Architecture: #{info.model}"
puts "Total Memory: #{to_mb(info.memory)} MB"
puts "CPUs: #{info.cpus}"
puts "Speed: #{info.mhz}"
puts "Nodes: #{info.nodes}"
puts "Sockets: #{info.sockets}"
puts "Cores: #{info.cores}"
puts "Threads: #{info.threads}"
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.