Simple to use ruby interface to libvirt
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
templates updated vmware templates Dec 29, 2011
test added basic VMWare support, WIP Dec 28, 2011
.document Adding jeweler generated Rakefile and other artifacts Jan 31, 2011
.gitignore
Gemfile ensure the libvirt is required via bundler Jan 22, 2012
Gemfile.lock ensure the libvirt is required via bundler Jan 22, 2012
LICENSE.txt Adding jeweler generated Rakefile and other artifacts Jan 31, 2011
README.rdoc fixes #977 - allow operating system reboot and shutdown Jun 12, 2011
Rakefile added basic VMWare support, WIP Dec 28, 2011
VERSION version bump Jan 22, 2012
virt.gemspec version bump Jan 22, 2012

README.rdoc

virt

Simple to use ruby interface to libvirt.

Libvirt is located at libvirt.org/ruby

Contributing

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

RDOC

for full API please visit rdoc.info/github/ohadlevy/virt

Examples

Connectivity Options

uri = "qemu:///system"              # libvirt running locally
uri = "qemu:/fqdn//system"          # used for QEMU+TLS connection
uri = "qemu+ssh:/user@fqdn//system" # used for SSH connection
uri = "qemu+tcp:/fqdn//system"      # used for non secured tcp connection

Establish the connection

conn = Virt.connect(uri)

get the hypervisor

host = conn.host

get the list of running guests

host.running_guests

get the list of stopped guests

host.defined_guests

or a simple hash of both

host.guests

create a new guest

guest=Virt::Guest.new({:name => "test123"})
guest.vcpu = 2
guest.volume.size = 10 # in GB

guest.save
guest.start

puts guest.mac

guest.shutdown     # initiate a shutdown
guest.poweroff     # forces a shutdown

Many more options exists, make sure checkout the api/tests

list of host bridges

host.interfaces # physical interfaces
host.networks   # virtual / NAT interfaces

Storage

host.storage_pools

host.volumes

Copyright

Copyright © 2011 Ohad Levy

This program and entire repository is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.