Revision 0084ffc5

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
2172 2172
    # Create a snapshot for the VM
2173 2173
    def create_snapshot(snap_id, snap_name)
2174 2174
        snapshot_hash = {
2175
            :name        => snap_name,
2176
            :description => "OpenNebula's snapshot at #{Time.now}",
2175
            :name        => snap_id,
2176
            :description => "OpenNebula Snapshot: #{snap_name}",
2177 2177
            :memory      => true,
2178 2178
            :quiesce     => true
2179 2179
        }
......
2211 2211
    end
2212 2212

  
2213 2213
    # Revert to a VM snapshot
2214
    def revert_snapshot(snap_id, snap_name)
2214
    def revert_snapshot(snap_id)
2215 2215

  
2216 2216
        snapshot_list = self["snapshot.rootSnapshotList"]
2217
        snapshot = find_snapshot_in_list(snapshot_list, snap_id, snap_name)
2217
        snapshot = find_snapshot_in_list(snapshot_list, snap_id)
2218 2218

  
2219 2219
        return nil if !snapshot
2220 2220

  
......
2227 2227
    end
2228 2228

  
2229 2229
    # Delete VM snapshot
2230
    def delete_snapshot(snap_id, snap_name)
2230
    def delete_snapshot(snap_id)
2231 2231

  
2232 2232
        snapshot_list = self["snapshot.rootSnapshotList"]
2233
        snapshot = find_snapshot_in_list(snapshot_list, snap_id, snap_name)
2233
        snapshot = find_snapshot_in_list(snapshot_list, snap_id)
2234 2234

  
2235 2235
        return nil if !snapshot
2236 2236

  
......
2245 2245
        end
2246 2246
    end
2247 2247

  
2248
    def find_snapshot_in_list(list, snap_id, snap_name)
2248
    def find_snapshot_in_list(list, snap_id)
2249 2249
        list.each do |i|
2250
            if i.name == snap_id.to_s || i.name == snap_name.to_s
2250
            if i.name == snap_id.to_s
2251 2251
                return i.snapshot
2252 2252
            elsif !i.childSnapshotList.empty?
2253
                snap = find_snapshot_in_list(i.childSnapshotList, snap_id, snap_name)
2253
                snap = find_snapshot_in_list(i.childSnapshotList, snap_id)
2254 2254
                return snap if snap
2255 2255
            end
2256 2256
        end rescue nil
src/vmm_mad/remotes/vcenter/snapshot_delete
31 31

  
32 32
vm_ref          = ARGV[0]
33 33
snap_id         = ARGV[1]
34
vm_id           = ARGV[2]
35 34
vc_cluster_name = ARGV[3]
36 35

  
37 36
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
......
42 41

  
43 42
    vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
44 43

  
45
    # Get snapshot name
46
    one_vm = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualMachine, vm_id)
47
    snap_name = one_vm["TEMPLATE/SNAPSHOT[SNAPSHOT_ID=#{snap_id}]/NAME"]
48

  
49
    vm.delete_snapshot(snap_id, snap_name)
44
    vm.delete_snapshot(snap_id)
50 45

  
51 46
rescue Exception => e
52 47
    STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\
src/vmm_mad/remotes/vcenter/snapshot_revert
31 31

  
32 32
vm_ref          = ARGV[0]
33 33
snap_id         = ARGV[1]
34
vm_id           = ARGV[2]
35 34
vc_cluster_name = ARGV[3]
36 35

  
37 36
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
......
42 41

  
43 42
    vm = VCenterDriver::VirtualMachine.new_from_ref(vm_ref, vi_client)
44 43

  
45
    # Get snapshot name
46
    one_vm = VCenterDriver::VIHelper.one_item(OpenNebula::VirtualMachine, vm_id)
47
    snap_name = one_vm["TEMPLATE/SNAPSHOT[SNAPSHOT_ID=#{snap_id}]/NAME"]
48

  
49
    vm.revert_snapshot(snap_id, snap_name)
44
    vm.revert_snapshot(snap_id)
50 45

  
51 46
rescue Exception => e
52 47
    STDERR.puts "Snapshot of VM #{vm_ref} on vCenter cluster "\

Also available in: Unified diff