Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fog Libvirt Provider examples
require 'rubygems'
require 'fog'
#
# Helper to print all the servers
#
def print_servers(conn, uri)
puts "URI: #{uri}"
conn.servers.all.each do |s|
puts " #{s.name}"
puts " Server ID:".ljust(20) + "#{s.id}"
end
puts "\n"*3
end
#
# XEN Community
#
uri = 'xen+tcp://thunder08'
c = Fog::Compute.new(
{
:provider => 'Libvirt',
:libvirt_uri => uri
}
)
print_servers c, uri
#
# ESX
#
uri = 'esx://thunder03/?no_verify=1'
c = Fog::Compute.new(
{
:provider => 'Libvirt',
:libvirt_uri => uri,
:user => 'root',
:password => 'temporal'
}
)
print_servers c, uri
#
# KVM
#
uri = 'qemu+tcp://thunder11/system'
c = Fog::Compute.new(
{
:provider => 'Libvirt',
:libvirt_uri => uri,
}
)
print_servers c, uri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment