mitchellh / virtualbox

[ABANDONED] Create and modify virtual machines in VirtualBox using pure ruby.
http://mitchellh.github.com/virtualbox/
MIT License
245 stars 45 forks source link

Ability to cancel an export/import +background process #24

Closed KieranP closed 14 years ago

KieranP commented 14 years ago

e.g.

export = VM.find('...').export(:background => true) do |percent|
  update_progress(percent)
end

that'll be done in a fork or something, then:

export.progress   =>   45

and

export.stop!  => true
mitchellh commented 14 years ago

Kieran,

These are now cancellable:

VM.import("foo.ovf") do |progress|
  puts progress.percent.to_s
  progress.cancel if progress.to_i >= 20
end

I'm sure you can figure out how it works :)