diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 2c489370c..6dd8c95b7 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -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. diff --git a/plugins/commands/package/command.rb b/plugins/commands/package/command.rb index e1f14721a..02338aa9d 100644 --- a/plugins/commands/package/command.rb +++ b/plugins/commands/package/command.rb @@ -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