fog/fog-vsphere

View on GitHub
lib/fog/vsphere/requests/compute/vm_revert_snapshot.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Fog
  module Vsphere
    class Compute
      class Real
        def vm_revert_snapshot(vm_id, snapshot_id)
          vm = servers.get(vm_id)
          snapshot = vm.snapshots.get(snapshot_id).mo_ref
          task = snapshot.RevertToSnapshot_Task

          task.wait_for_completion

          {
            'task_state' => task.info.state,
            'was_cancelled' => task.info.cancelled
          }
        end
      end

      class Mock
        def vm_revert_snapshot(_vm_id, _snapshot_id)
          {
            'task_state' => 'success',
            'was_cancelled' => false
          }
        end
      end
    end
  end
end