Merge pull request #8910 from briancain/8479/master/disable-prov-install-global-id-up
Disable install providers when using global id on vagrant up
This commit is contained in:
commit
9f093f71d9
|
@ -78,6 +78,15 @@ module VagrantPlugins
|
||||||
# Build up the batch job of what we'll do
|
# Build up the batch job of what we'll do
|
||||||
machines = []
|
machines = []
|
||||||
if names
|
if names
|
||||||
|
# To prevent vagrant from attempting to validate a global vms config
|
||||||
|
# (which doesn't exist within the local dir) when attempting to
|
||||||
|
# install a machines provider, this check below will disable the
|
||||||
|
# install_providers function if a user gives us a machine id instead
|
||||||
|
# of the machines name.
|
||||||
|
machine_names = []
|
||||||
|
with_target_vms(names, provider: options[:provider]){|m| machine_names << m.name }
|
||||||
|
options[:install_provider] = false if !(machine_names - names).empty?
|
||||||
|
|
||||||
# If we're installing providers, then do that. We don't
|
# If we're installing providers, then do that. We don't
|
||||||
# parallelize this step because it is likely the same provider
|
# parallelize this step because it is likely the same provider
|
||||||
# anyways.
|
# anyways.
|
||||||
|
|
|
@ -5,6 +5,7 @@ require Vagrant.source_root.join("plugins/commands/up/command")
|
||||||
describe VagrantPlugins::CommandUp::Command do
|
describe VagrantPlugins::CommandUp::Command do
|
||||||
include_context "unit"
|
include_context "unit"
|
||||||
|
|
||||||
|
let(:entry_klass) { Vagrant::MachineIndex::Entry }
|
||||||
let(:argv) { [] }
|
let(:argv) { [] }
|
||||||
let(:vagrantfile_content){ "" }
|
let(:vagrantfile_content){ "" }
|
||||||
let(:iso_env) do
|
let(:iso_env) do
|
||||||
|
@ -17,6 +18,13 @@ describe VagrantPlugins::CommandUp::Command do
|
||||||
|
|
||||||
let(:action_runner) { double("action_runner") }
|
let(:action_runner) { double("action_runner") }
|
||||||
|
|
||||||
|
def new_entry(name)
|
||||||
|
entry_klass.new.tap do |e|
|
||||||
|
e.name = name
|
||||||
|
e.vagrantfile_path = "/bar"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
allow(iso_env).to receive(:action_runner).and_return(action_runner)
|
||||||
end
|
end
|
||||||
|
@ -62,4 +70,63 @@ describe VagrantPlugins::CommandUp::Command do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a global machine" do
|
||||||
|
let(:argv){ ["1234"] }
|
||||||
|
|
||||||
|
it "brings up a vm with an id" do
|
||||||
|
|
||||||
|
global_env = isolated_environment
|
||||||
|
global_env.vagrantfile("Vagrant.configure(2){|config| config.vm.box = 'dummy'}")
|
||||||
|
global_venv = global_env.create_vagrant_env
|
||||||
|
global_machine = global_venv.machine(global_venv.machine_names[0], :dummy)
|
||||||
|
global_machine.id = "1234"
|
||||||
|
global = new_entry(global_machine.name)
|
||||||
|
global.provider = "dummy"
|
||||||
|
global.vagrantfile_path = global_env.workdir
|
||||||
|
locked = iso_env.machine_index.set(global)
|
||||||
|
iso_env.machine_index.release(locked)
|
||||||
|
|
||||||
|
allow(subject).to receive(:with_target_vms) { |&block| block.call global_machine }
|
||||||
|
|
||||||
|
|
||||||
|
batch = double("environment_batch")
|
||||||
|
expect(iso_env).to receive(:batch).and_yield(batch)
|
||||||
|
expect(batch).to receive(:action).with(global_machine, :up, anything) do |machine,action,args|
|
||||||
|
expect(machine).to be_kind_of(Vagrant::Machine)
|
||||||
|
expect(action).to eq(:up)
|
||||||
|
end
|
||||||
|
subject.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with an argument" do
|
||||||
|
let(:vagrantfile_content) do
|
||||||
|
<<-VF
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.define "app"
|
||||||
|
config.vm.define "db"
|
||||||
|
end
|
||||||
|
VF
|
||||||
|
end
|
||||||
|
let(:argv){ ["app"] }
|
||||||
|
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
|
||||||
|
|
||||||
|
it "brings up a vm" do
|
||||||
|
batch = double("environment_batch")
|
||||||
|
expect(iso_env).to receive(:batch).and_yield(batch)
|
||||||
|
expect(batch).to receive(:action).with(machine, :up, anything) do |machine,action,args|
|
||||||
|
expect(machine).to be_kind_of(Vagrant::Machine)
|
||||||
|
expect(action).to eq(:up)
|
||||||
|
end
|
||||||
|
subject.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with an invalid argument" do
|
||||||
|
let(:argv){ ["notweb"] }
|
||||||
|
it "brings up a vm" do
|
||||||
|
expect { subject.execute }.to raise_error(Vagrant::Errors::MachineNotFound)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue