Skip to content

Instantly share code, notes, and snippets.

@jiphex
Created April 30, 2013 11:53
Show Gist options
  • Save jiphex/5488237 to your computer and use it in GitHub Desktop.
Save jiphex/5488237 to your computer and use it in GitHub Desktop.
Thing to add the missing method "create_snapshot" to the libvirt ruby domain bindings. Both the libvirt and builder libraries are in debian packages (apt-get install ruby-{libvirt,builder})
require 'libvirt'
require 'builder'
class Libvirt::Domain
def create_snapshot(sdesc=nil)
builder = Builder::XmlMarkup.new
snapshot_xml = builder.domainsnapshot do |ds|
if sdesc
ds.description(sdesc)
end
end
self.snapshot_create_xml(snapshot_xml)
end
end
c = Libvirt::open('qemu:///system')
d = c.lookup_domain_by_name 'jeff'
d.create_snapshot("Testing123")
p d.list_snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment