Class: VagrantPlugins::PackageVMware::Action::PackageMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-package-vmware/action/package_machine.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PackageMachine

Returns a new instance of PackageMachine.



8
9
10
# File 'lib/vagrant-package-vmware/action/package_machine.rb', line 8

def initialize(app, env)
  @app = app
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
# File 'lib/vagrant-package-vmware/action/package_machine.rb', line 12

def call(env)
  require_relative '../errors'

  package_machine = env[:machine]
  package_output = env['package.output']
  package_directory = env['package.directory']

  output_name = File.basename(package_output, '.box')
  input_vmx = package_machine.provider.driver.vmx_path.to_s
  output_vmx = "#{package_directory}/#{output_name}.vmx"

  env[:ui].info "Cloning machine..."
  result = Vagrant::Util::Subprocess.execute("vmrun", "clone", input_vmx, output_vmx, "full", "-cloneName=#{output_name}")

  raise Errors::CloneFailed, result: result if result.exit_code != 0

  @app.call(env)
end