Revision 469ff036 src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
989 989
    end
990 990

  
991 991
    # Create a snapshot for the VM
992
    def create_snapshot(snapshot_name, vm_ref)
992
    def create_snapshot(snap_id, snap_name)
993 993
        snapshot_hash = {
994
            :name => snapshot_name,
995
            :description => "OpenNebula Snapshot of VM #{vm_ref}",
996
            :memory => true,
997
            :quiesce => true
994
            :name        => snap_id,
995
            :description => snap_name,
996
            :memory      => true,
997
            :quiesce     => true
998 998
        }
999 999

  
1000 1000
        begin
......
1003 1003
            raise "Cannot create snapshot for VM: #{e.message}"
1004 1004
        end
1005 1005

  
1006
        return snapshot_name
1006
        return snap_id
1007 1007
    end
1008 1008

  
1009 1009
    # Revert to a VM snapshot
1010
    def revert_snapshot(snapshot_name)
1010
    def revert_snapshot(snap_id)
1011 1011

  
1012 1012
        snapshot_list = self["snapshot.rootSnapshotList"]
1013
        snapshot = find_snapshot_in_list(snapshot_list, snapshot_name)
1013
        snapshot = find_snapshot_in_list(snapshot_list, snap_id)
1014 1014

  
1015 1015
        return nil if !snapshot
1016 1016

  
......
1023 1023
    end
1024 1024

  
1025 1025
    # Delete VM snapshot
1026
    def delete_snapshot(snapshot_name)
1026
    def delete_snapshot(snap_id)
1027 1027

  
1028 1028
        snapshot_list = self["snapshot.rootSnapshotList"]
1029
        snapshot = find_snapshot_in_list(snapshot_list, snapshot_name)
1029
        snapshot = find_snapshot_in_list(snapshot_list, snap_id)
1030 1030

  
1031 1031
        return nil if !snapshot
1032 1032

  
......
1041 1041
        end
1042 1042
    end
1043 1043

  
1044
    def find_snapshot_in_list(list, snapshot_name)
1044
    def find_snapshot_in_list(list, snap_id)
1045 1045
        list.each do |i|
1046
            if i.name == snapshot_name
1046
            if i.name == snap_id.to_s
1047 1047
                return i.snapshot
1048 1048
            elsif !i.childSnapshotList.empty?
1049
                snap = find_snapshot(i.childSnapshotList, snapshot_name)
1049
                snap = find_snapshot(i.childSnapshotList, snap_id)
1050 1050
                return snap if snap
1051 1051
            end
1052 1052
        end rescue nil

Also available in: Unified diff