`vagrant package`
This commit is contained in:
parent
0e43d8b55f
commit
4d56e68268
|
@ -0,0 +1,31 @@
|
|||
module Vagrant
|
||||
module Command
|
||||
class PackageCommand < Base
|
||||
desc "Package a Vagrant environment for distribution"
|
||||
class_option :base, :type => :string, :default => nil
|
||||
class_option :output, :type => :string, :default => nil
|
||||
class_option :include, :type => :array, :default => nil
|
||||
register "package"
|
||||
|
||||
def execute
|
||||
return package_base if options[:base]
|
||||
package_target
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def package_base
|
||||
vm = VM.find(options[:base], env)
|
||||
raise VMNotFoundError.new("Specified base VM not found: #{options[:base]}") if !vm.created?
|
||||
vm.package(options)
|
||||
end
|
||||
|
||||
def package_target
|
||||
raise MultiVMTargetRequired.new("`vagrant package` requires the name of the VM to package in a multi-vm environment.") if target_vms.length > 1
|
||||
vm = target_vms.first
|
||||
raise VMNotCreatedError.new("The VM must be created to package it. Run `vagrant up` first.") if !vm.created?
|
||||
vm.package(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,4 +10,6 @@ module Vagrant
|
|||
class NoEnvironmentError < VagrantError; status_code(3); end
|
||||
class VMNotFoundError < VagrantError; status_code(4); end
|
||||
class MultiVMEnvironmentRequired < VagrantError; status_code(5); end
|
||||
class VMNotCreatedError < VagrantError; status_code(6); end
|
||||
class MultiVMTargetRequired < VagrantError; status_code(7); end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue