Get vagrant package --base working in some hacky way.

`vagrant package --base` is deprecated for a future feature so I didn't
want to waste any brain cycles on how to do this the "right" way since a
new system will be introduced to do this sort of thing in teh future.
This commit is contained in:
Mitchell Hashimoto 2012-08-19 18:51:36 -07:00
parent cc7768c535
commit ba0e426507
2 changed files with 19 additions and 4 deletions

View File

@ -46,7 +46,7 @@ module Vagrant
# @param [Box] box The box that is backing this virtual machine.
# @param [Environment] env The environment that this machine is a
# part of.
def initialize(name, provider_cls, config, box, env)
def initialize(name, provider_cls, config, box, env, base=false)
@logger = Log4r::Logger.new("vagrant::machine")
@logger.info("Initializing machine: #{name}")
@logger.info(" - Provider: #{provider_cls}")
@ -59,7 +59,13 @@ module Vagrant
# Read the ID, which is usually in local storage
@id = nil
@id = @env.local_data[:active][@name.to_s] if @env.local_data[:active]
# XXX: This is temporary. This will be removed very soon.
if base
@id = name
else
@id = @env.local_data[:active][@name.to_s] if @env.local_data[:active]
end
# Initializes the provider last so that it has access to all the
# state we setup on this machine.

View File

@ -47,8 +47,17 @@ module VagrantPlugins
protected
def package_base(options)
vm = Vagrant::VM.new(options[:base], @env, @env.config.global, :base => true)
raise Vagrant::Errors::BaseVMNotFound, :name => options[:base] if !vm.created?
# XXX: This whole thing is hardcoded and very temporary. The whole
# `vagrant package --base` process is deprecated for something much
# better in the future. We just hardcode this to keep VirtualBox working
# for now.
provider = nil
Vagrant.plugin("1").registered.each do |plugin|
provider = plugin.provider.get(:virtualbox)
break if provider
end
vm = Vagrant::Machine.new(options[:base], provider, @env.config.global, nil, @env, true)
@logger.debug("Packaging base VM: #{vm.name}")
package_vm(vm, options)
end