Module: LibvirtExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/libvirt_extensions.rb

Instance Method Summary collapse

Instance Method Details

#snapshot_status(uuid) ⇒ Object



16
17
18
19
# File 'app/models/libvirt_extensions.rb', line 16

def snapshot_status uuid
  # clone_volume is a blocking call so this is automatically true
  "ACTIVE"
end

#snapshot_vm(uuid, title = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'app/models/libvirt_extensions.rb', line 4

def snapshot_vm uuid, title = nil
  vm       = find_vm_by_uuid(uuid)
  vol_name = title.downcase.gsub(' ','_') + '.img'
  # TODO: We're assuming the first volume is the rootvol
  snapshot = vm.volumes.first.clone_volume(vol_name)
  # The return from clone_volume is the original vol, so re-find the new one
  vol      = client.volumes.detect{|n| n.name == vol_name}
  return false unless snapshot && vol
  return false unless vol
  vol.path
end