Class: VagrantPlugins::PackageVMware::Command
- Inherits:
-
Object
- Object
- VagrantPlugins::PackageVMware::Command
- Defined in:
- lib/vagrant-package-vmware/command.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.synopsis ⇒ Object
4 5 6 |
# File 'lib/vagrant-package-vmware/command.rb', line 4 def self.synopsis "packages a running VMware vagrant environment into a box" end |
Instance Method Details
#execute ⇒ Object
8 9 10 11 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 39 40 41 |
# File 'lib/vagrant-package-vmware/command.rb', line 8 def execute = {} [:tty] = true opts = OptionParser.new do |o| o. = "Usage: vagrant package-vmware [options] [name]" o.separator "" o.separator "Options:" o.separator "" o.on("--output NAME", "Name of the file to output") do |output| [:output] = output end o.on("--include FILE,FILE..", Array, "Comma separated additional files to package with the box") do |i| [:include] = i end o.on("--vagrantfile FILE", "Vagrantfile to package with the box") do |v| [:vagrantfile] = v end end # Parse the options argv = (opts) return if !argv @logger.debug("package options: #{.inspect}") package_target(argv[0], ) # Success, exit status 0 0 end |
#package_target(name, options) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/vagrant-package-vmware/command.rb', line 43 def package_target(name, ) with_target_vms(name, single_target: true) do |vm| @logger.debug("Packaging VM: #{vm.name}") package_vm(vm, ) end end |
#package_vm(vm, options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/vagrant-package-vmware/command.rb', line 50 def package_vm(vm, ) require_relative 'action' opts = .inject({}) do |acc, data| k,v = data acc["package.#{k}"] = v acc end opts[:machine] = vm @env.action_runner.run(VagrantPlugins::PackageVMware::Action.action_package_vmware, opts) end |