Class: RbVmomi::VIM::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/rbvmomi/vim/Task.rb

Instance Method Summary collapse

Instance Method Details

#wait_for_completionObject

Wait for a task to finish.

Returns:

  • info.result on success.

Raises:

  • info.error on error.


5
6
7
8
9
10
11
12
13
# File 'lib/rbvmomi/vim/Task.rb', line 5

def wait_for_completion
  wait_until('info.state') { %w(success error).member? info.state }
  case info.state
  when 'success'
    info.result
  when 'error'
    raise info.error
  end
end

#wait_for_progress {|info.progress| ... } ⇒ Object

Wait for a task to finish, with progress notifications.

Yields:

  • (info.progress)

Returns:

  • info.result on success.

Raises:

  • info.error on error.


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rbvmomi/vim/Task.rb', line 19

def wait_for_progress
  wait_until('info.state', 'info.progress') do
    yield info.progress if block_given?
    %w(success error).member? info.state
  end
  case info.state
  when 'success'
    info.result
  when 'error'
    raise info.error
  end
end