Class: VagrantPlugins::Parallels::Action::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-parallels/action/export.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Export

Returns a new instance of Export.



7
8
9
10
# File 'lib/vagrant-parallels/action/export.rb', line 7

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_parallels::action::export')
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-parallels/action/export.rb', line 12

def call(env)
  if env[:machine].state.id != :stopped
    raise Vagrant::Errors::VMPowerOffToPackage
  end

  # Clone source VM to the temporary copy
  clone(env)
  @home_path = env[:machine].provider.driver.read_settings(env[:package_box_id]).fetch('Home')
  @hdd_list = Dir.glob(File.join(@home_path, '*.hdd'))

  # Convert to full-sized VM, copy all external and linked disks (if any)
  convert_to_full(env)

  # Compact all virtual disks 
  # Note: The macvm (macOS VM on Apple Silicon Macs) only supports PLAIN virtual disks. 
  # As a result, these disks cannot be compacted. Therefore, the compacting step 
  # should be skipped for macvms.

  if !Util::Common::is_macvm(env[:machine])
    compact(env)
  end

  # Preparations completed. Unregister before packaging
  unregister_vm(env)

  @app.call(env)
end

#recover(env) ⇒ Object



40
41
42
# File 'lib/vagrant-parallels/action/export.rb', line 40

def recover(env)
  unregister_vm(env)
end