Merge remote-tracking branch 'mitchellh/master' into feature-hyperv-integration-services-fresh

# Conflicts:
#	plugins/providers/hyperv/action/import.rb
#	plugins/providers/hyperv/config.rb
#	website/source/docs/hyperv/configuration.html.md
This commit is contained in:
Bjorn Brala 2017-03-23 07:49:57 +01:00
commit 0534ebf895
20 changed files with 425 additions and 160 deletions

View File

@ -2,12 +2,21 @@
FEATURES: FEATURES:
IMPROVEMENTS:
BUG FIXES:
## 1.9.3 (March 21, 2017)
IMPROVEMENTS: IMPROVEMENTS:
- command/plugin: Remove requirement for paths with no spaces [GH-7967] - command/plugin: Remove requirement for paths with no spaces [GH-7967]
- core: Support host_ip for forwarded ports [GH-7035, GH-8350] - core: Support host_ip for forwarded ports [GH-7035, GH-8350]
- core: Include disk space hint in box install failure message [GH-8089] - core: Include disk space hint in box install failure message [GH-8089]
- core/bundler: Allow vagrant constraint matching in prerelease mode [GH-8341] - core/bundler: Allow vagrant constraint matching in prerelease mode [GH-8341]
- provisioner/docker: Include /bin/docker as valid path [GH-8390]
- provider/hyperv: Support enabling Hyper-V nested virtualization [GH-8325, GH-7738]
BUG FIXES: BUG FIXES:
@ -15,6 +24,8 @@ BUG FIXES:
- contrib/bash: Handle path spaces in bash completion [GH-8337] - contrib/bash: Handle path spaces in bash completion [GH-8337]
- core: Fix box sorting on find and list [GH-7956, GH-8334] - core: Fix box sorting on find and list [GH-7956, GH-8334]
- core/bundler: Force path as preferred source on install [GH-8327] - core/bundler: Force path as preferred source on install [GH-8327]
- core/provision: Update "never" behavior to match documentation [GH-8366, GH-8016]
- plugins/push: Isolate deprecation to Atlas strategy only
- plugins/synced_folders: Give UID/GID precedence if found within mount options - plugins/synced_folders: Give UID/GID precedence if found within mount options
[GH-8122, GH-8064, GH-7859] [GH-8122, GH-8064, GH-7859]

View File

@ -102,12 +102,17 @@ module Vagrant
type_map = provisioner_type_map(env) type_map = provisioner_type_map(env)
provisioner_instances(env).each do |p, options| provisioner_instances(env).each do |p, options|
type_name = type_map[p] type_name = type_map[p]
next if env[:provision_types] && \
!env[:provision_types].include?(type_name) && \
!env[:provision_types].include?(options[:name])
# Don't run if sentinel is around and we're not always running if options[:run] == :never
next if !provision_enabled && options[:run] != :always next if env[:provision_types].nil? || !env[:provision_types].include?(options[:name])
else
next if env[:provision_types] && \
!env[:provision_types].include?(type_name) && \
!env[:provision_types].include?(options[:name])
# Don't run if sentinel is around and we're not always running
next if !provision_enabled && options[:run] != :always
end
name = type_name name = type_name
if options[:name] if options[:name]

View File

@ -29,11 +29,11 @@ module Vagrant
end end
alias_method :non_deprecated_execute, :execute alias_method :non_deprecated_execute, :execute
def execute def execute(*args, &block)
@env[:ui].warn(I18n.t("vagrant.commands.deprecated", @env[:ui].warn(I18n.t("vagrant.commands.deprecated",
name: deprecation_command_name name: deprecation_command_name
) + "\n") ) + "\n")
non_deprecated_execute non_deprecated_execute(*args, &block)
end end
end end
end end
@ -44,7 +44,7 @@ module Vagrant
def self.included(klass) def self.included(klass)
klass.include(CommandDeprecation) klass.include(CommandDeprecation)
klass.class_eval do klass.class_eval do
def execute def execute(*_)
raise Vagrant::Errors::CommandDeprecated, raise Vagrant::Errors::CommandDeprecated,
name: deprecation_command_name name: deprecation_command_name
end end

View File

@ -70,8 +70,6 @@ module VagrantPlugins
return name return name
end end
include Vagrant::Util::CommandDeprecation::Complete
end end
end end
end end

View File

@ -21,11 +21,13 @@ module VagrantPlugins
differencing_disk = env[:machine].provider_config.differencing_disk differencing_disk = env[:machine].provider_config.differencing_disk
auto_start_action = env[:machine].provider_config.auto_start_action auto_start_action = env[:machine].provider_config.auto_start_action
auto_stop_action = env[:machine].provider_config.auto_stop_action auto_stop_action = env[:machine].provider_config.auto_stop_action
enable_virtualization_extensions = env[:machine].provider_config.enable_virtualization_extensions
vm_integration_services = env[:machine].provider_config.vm_integration_services vm_integration_services = env[:machine].provider_config.vm_integration_services
env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory
env[:ui].output("Configured startup memory is #{memory}") if memory env[:ui].output("Configured startup memory is #{memory}") if memory
env[:ui].output("Configured cpus number is #{cpus}") if cpus env[:ui].output("Configured cpus number is #{cpus}") if cpus
env[:ui].output("Configured enable virtualization extensions is #{enable_virtualization_extensions}") if enable_virtualization_extensions
env[:ui].output("Configured vmname is #{vmname}") if vmname env[:ui].output("Configured vmname is #{vmname}") if vmname
env[:ui].output("Configured differencing disk instead of cloning") if differencing_disk env[:ui].output("Configured differencing disk instead of cloning") if differencing_disk
env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action
@ -146,6 +148,7 @@ module VagrantPlugins
options[:auto_start_action] = auto_start_action if auto_start_action options[:auto_start_action] = auto_start_action if auto_start_action
options[:auto_stop_action] = auto_stop_action if auto_stop_action options[:auto_stop_action] = auto_stop_action if auto_stop_action
options[:differencing_disk] = differencing_disk if differencing_disk options[:differencing_disk] = differencing_disk if differencing_disk
options[:enable_virtualization_extensions] = "$True" if enable_virtualization_extensions and enable_virtualization_extensions == true
env[:ui].detail("Creating and registering the VM...") env[:ui].detail("Creating and registering the VM...")
server = env[:machine].provider.driver.import(options) server = env[:machine].provider.driver.import(options)

View File

@ -11,8 +11,9 @@ module VagrantPlugins
attr_accessor :vlan_id # VLAN ID for network interface for the virtual machine. @return [Integer] attr_accessor :vlan_id # VLAN ID for network interface for the virtual machine. @return [Integer]
attr_accessor :mac # MAC address for network interface for the virtual machine. @return [String] attr_accessor :mac # MAC address for network interface for the virtual machine. @return [String]
attr_accessor :differencing_disk # Create differencing disk instead of cloning whole VHD [Boolean] attr_accessor :differencing_disk # Create differencing disk instead of cloning whole VHD [Boolean]
attr_accessor :auto_start_action #action on automatic start of VM. Values: Nothing, StartIfRunning, Start [String] attr_accessor :auto_start_action #action on automatic start of VM. Values: Nothing, StartIfRunning, Start
attr_accessor :auto_stop_action #action on automatic stop of VM. Values: ShutDown, TurnOff, Save [String] attr_accessor :auto_stop_action #action on automatic stop of VM. Values: ShutDown, TurnOff, Save
attr_accessor :enable_virtualization_extensions # Enable virtualization extensions (nested virtualization). Values: true, false
attr_accessor :vm_integration_services # Options for VMServiceIntegration [Hash] attr_accessor :vm_integration_services # Options for VMServiceIntegration [Hash]
def initialize def initialize
@ -26,6 +27,7 @@ module VagrantPlugins
@differencing_disk = UNSET_VALUE @differencing_disk = UNSET_VALUE
@auto_start_action = UNSET_VALUE @auto_start_action = UNSET_VALUE
@auto_stop_action = UNSET_VALUE @auto_stop_action = UNSET_VALUE
@enable_virtualization_extensions = UNSET_VALUE
@vm_integration_services = { @vm_integration_services = {
guest_service_interface: UNSET_VALUE, guest_service_interface: UNSET_VALUE,
heartbeat: UNSET_VALUE, heartbeat: UNSET_VALUE,
@ -49,6 +51,7 @@ module VagrantPlugins
@differencing_disk = false if @differencing_disk == UNSET_VALUE @differencing_disk = false if @differencing_disk == UNSET_VALUE
@auto_start_action = nil if @auto_start_action == UNSET_VALUE @auto_start_action = nil if @auto_start_action == UNSET_VALUE
@auto_stop_action = nil if @auto_stop_action == UNSET_VALUE @auto_stop_action = nil if @auto_stop_action == UNSET_VALUE
@enable_virtualization_extensions = false if @enable_virtualization_extensions == UNSET_VALUE # TODO will this work?
@vm_integration_services.each { |key, value| @vm_integration_services.each { |key, value|
@vm_integration_services[key] = nil if value == UNSET_VALUE @vm_integration_services[key] = nil if value == UNSET_VALUE

View File

@ -10,7 +10,8 @@ Param(
[string]$cpus=$null, [string]$cpus=$null,
[string]$vmname=$null, [string]$vmname=$null,
[string]$auto_start_action=$null, [string]$auto_start_action=$null,
[string]$auto_stop_action=$null [string]$auto_stop_action=$null,
[string]$enable_virtualization_extensions=$False
) )
# Include the following modules # Include the following modules
@ -170,6 +171,11 @@ if ($generation -ne 1) {
} }
} }
# Enable nested virtualization if configured
if ($enable_virtualization_extensions) {
Set-VMProcessor -VM $vm -ExposeVirtualizationExtensions $true
}
# A regular expression pattern to pull the number from controllers # A regular expression pattern to pull the number from controllers
[regex]$rx="\d" [regex]$rx="\d"

View File

@ -6,7 +6,7 @@ module VagrantPlugins
# Driver for VirtualBox 5.1.x # Driver for VirtualBox 5.1.x
class Version_5_1 < Version_5_0 class Version_5_1 < Version_5_0
def initialize(uuid) def initialize(uuid)
super() super
@logger = Log4r::Logger.new("vagrant::provider::virtualbox_5_1") @logger = Log4r::Logger.new("vagrant::provider::virtualbox_5_1")
end end

View File

@ -5,6 +5,7 @@ module VagrantPlugins
module DockerInstalled module DockerInstalled
def self.docker_installed(machine) def self.docker_installed(machine)
paths = [ paths = [
"/bin/docker",
"/usr/bin/docker", "/usr/bin/docker",
"/usr/local/bin/docker", "/usr/local/bin/docker",
"/usr/sbin/docker", "/usr/sbin/docker",

View File

@ -73,6 +73,12 @@ module VagrantPlugins
return result return result
end end
include Vagrant::Util::CommandDeprecation::Complete
def deprecation_command_name
"push (atlas strategy)"
end
end end
end end
end end

View File

@ -33,37 +33,35 @@ describe VagrantPlugins::CommandPush::Command do
allow(env).to receive(:push) allow(env).to receive(:push)
end end
# NOTE: Disabled due to deprecation it "validates the pushes" do
# expect(subject).to receive(:validate_pushes!).once
# it "validates the pushes" do subject.execute
# expect(subject).to receive(:validate_pushes!).once end
# subject.execute
# end
# it "delegates to Environment#push" do it "delegates to Environment#push" do
# expect(env).to receive(:push).once expect(env).to receive(:push).once
# subject.execute subject.execute
# end end
# it "validates the configuration" do it "validates the configuration" do
# iso_env.vagrantfile <<-EOH iso_env.vagrantfile <<-EOH
# Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
# config.vm.box = "hashicorp/precise64" config.vm.box = "hashicorp/precise64"
# config.push.define "noop" do |push| config.push.define "noop" do |push|
# push.bad = "ham" push.bad = "ham"
# end end
# end end
# EOH EOH
# subject = described_class.new(argv, iso_env.create_vagrant_env) subject = described_class.new(argv, iso_env.create_vagrant_env)
# allow(subject).to receive(:validate_pushes!) allow(subject).to receive(:validate_pushes!)
# .and_return(:noop) .and_return(:noop)
# expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err| expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err|
# expect(err.message).to include("The following settings shouldn't exist: bad") expect(err.message).to include("The following settings shouldn't exist: bad")
# } }
# end end
end end
describe "#validate_pushes!" do describe "#validate_pushes!" do

View File

@ -27,154 +27,155 @@ describe VagrantPlugins::AtlasPush::Push do
allow(Vagrant::Util::SafeExec).to receive(:exec) allow(Vagrant::Util::SafeExec).to receive(:exec)
end end
describe "#push" do # DEPRECATED
it "pushes with the uploader" do # describe "#push" do
allow(subject).to receive(:uploader_path).and_return("foo") # it "pushes with the uploader" do
# allow(subject).to receive(:uploader_path).and_return("foo")
expect(subject).to receive(:execute).with("foo") # expect(subject).to receive(:execute).with("foo")
subject.push # subject.push
end # end
it "raises an exception if the uploader couldn't be found" do # it "raises an exception if the uploader couldn't be found" do
expect(subject).to receive(:uploader_path).and_return(nil) # expect(subject).to receive(:uploader_path).and_return(nil)
expect { subject.push }.to raise_error( # expect { subject.push }.to raise_error(
VagrantPlugins::AtlasPush::Errors::UploaderNotFound) # VagrantPlugins::AtlasPush::Errors::UploaderNotFound)
end # end
end # end
describe "#execute" do # describe "#execute" do
let(:app) { "foo/bar" } # let(:app) { "foo/bar" }
before do # before do
config.app = app # config.app = app
end # end
it "sends the basic flags" do # it "sends the basic flags" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", app, env.root_path.to_s) # with("foo", "-vcs", app, env.root_path.to_s)
subject.execute("foo") # subject.execute("foo")
end # end
it "doesn't send VCS if disabled" do # it "doesn't send VCS if disabled" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", app, env.root_path.to_s) # with("foo", app, env.root_path.to_s)
config.vcs = false # config.vcs = false
subject.execute("foo") # subject.execute("foo")
end # end
it "sends includes" do # it "sends includes" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", "-include", "foo", "-include", # with("foo", "-vcs", "-include", "foo", "-include",
"bar", app, env.root_path.to_s) # "bar", app, env.root_path.to_s)
config.includes = ["foo", "bar"] # config.includes = ["foo", "bar"]
subject.execute("foo") # subject.execute("foo")
end # end
it "sends excludes" do # it "sends excludes" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", "-exclude", "foo", "-exclude", # with("foo", "-vcs", "-exclude", "foo", "-exclude",
"bar", app, env.root_path.to_s) # "bar", app, env.root_path.to_s)
config.excludes = ["foo", "bar"] # config.excludes = ["foo", "bar"]
subject.execute("foo") # subject.execute("foo")
end # end
it "sends custom server address" do # it "sends custom server address" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s) # with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s)
config.address = "foo" # config.address = "foo"
subject.execute("foo") # subject.execute("foo")
end # end
it "sends custom token" do # it "sends custom token" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s) # with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s)
config.token = "atlas_token" # config.token = "atlas_token"
subject.execute("foo") # subject.execute("foo")
end # end
context "when metadata is available" do # context "when metadata is available" do
let(:env) do # let(:env) do
iso_env = isolated_environment # iso_env = isolated_environment
iso_env.vagrantfile <<-EOH # iso_env.vagrantfile <<-EOH
Vagrant.configure("2") do |config| # Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64" # config.vm.box = "hashicorp/precise64"
config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64" # config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64"
end # end
EOH # EOH
iso_env.create_vagrant_env # iso_env.create_vagrant_env
end # end
it "sends the metadata" do # it "sends the metadata" do
expect(Vagrant::Util::SafeExec).to receive(:exec). # expect(Vagrant::Util::SafeExec).to receive(:exec).
with("foo", "-vcs", "-metadata", "box=hashicorp/precise64", # with("foo", "-vcs", "-metadata", "box=hashicorp/precise64",
"-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64", # "-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64",
"-token", "atlas_token", app, env.root_path.to_s) # "-token", "atlas_token", app, env.root_path.to_s)
config.token = "atlas_token" # config.token = "atlas_token"
subject.execute("foo") # subject.execute("foo")
end # end
end # end
end # end
describe "#uploader_path" do # describe "#uploader_path" do
let(:scratch) do # let(:scratch) do
Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path")) # Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path"))
end # end
after do # after do
FileUtils.rm_rf(scratch) # FileUtils.rm_rf(scratch)
end # end
it "should return the configured path if set" do # it "should return the configured path if set" do
config.uploader_path = "foo" # config.uploader_path = "foo"
expect(subject.uploader_path).to eq("foo") # expect(subject.uploader_path).to eq("foo")
end # end
it "should look up the uploader via PATH if not set" do # it "should look up the uploader via PATH if not set" do
allow(Vagrant).to receive(:in_installer?).and_return(false) # allow(Vagrant).to receive(:in_installer?).and_return(false)
expect(Vagrant::Util::Which).to receive(:which). # expect(Vagrant::Util::Which).to receive(:which).
with(described_class.const_get(:UPLOADER_BIN)). # with(described_class.const_get(:UPLOADER_BIN)).
and_return("bar") # and_return("bar")
expect(subject.uploader_path).to eq("bar") # expect(subject.uploader_path).to eq("bar")
end # end
it "should look up the uploader in the embedded dir if installer" do # it "should look up the uploader in the embedded dir if installer" do
allow(Vagrant).to receive(:in_installer?).and_return(true) # allow(Vagrant).to receive(:in_installer?).and_return(true)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s) # allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
bin_path = scratch.join("bin", bin) # bin_path = scratch.join("bin", bin)
bin_path.dirname.mkpath # bin_path.dirname.mkpath
bin_path.open("w+") { |f| f.write("hi") } # bin_path.open("w+") { |f| f.write("hi") }
expect(subject.uploader_path).to eq(bin_path.to_s) # expect(subject.uploader_path).to eq(bin_path.to_s)
end # end
it "should look up the uploader in the PATH if not in the installer" do # it "should look up the uploader in the PATH if not in the installer" do
allow(Vagrant).to receive(:in_installer?).and_return(true) # allow(Vagrant).to receive(:in_installer?).and_return(true)
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s) # allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
expect(Vagrant::Util::Which).to receive(:which). # expect(Vagrant::Util::Which).to receive(:which).
with(described_class.const_get(:UPLOADER_BIN)). # with(described_class.const_get(:UPLOADER_BIN)).
and_return("bar") # and_return("bar")
expect(subject.uploader_path).to eq("bar") # expect(subject.uploader_path).to eq("bar")
end # end
it "should return nil if its not found anywhere" do # it "should return nil if its not found anywhere" do
allow(Vagrant).to receive(:in_installer?).and_return(false) # allow(Vagrant).to receive(:in_installer?).and_return(false)
allow(Vagrant::Util::Which).to receive(:which).and_return(nil) # allow(Vagrant::Util::Which).to receive(:which).and_return(nil)
expect(subject.uploader_path).to be_nil # expect(subject.uploader_path).to be_nil
end # end
end # end
end end

View File

@ -0,0 +1,208 @@
require File.expand_path("../../../../base", __FILE__)
require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
describe Vagrant::Action::Builtin::Provision do
include_context "unit"
let(:app) { lambda { |env| } }
let(:env) {
{ machine: machine, ui: ui, hook: hook, provision_ignore_sentinel: false }
}
let(:hook){ double("hook") }
let(:machine) do
double("machine").tap do |machine|
allow(machine).to receive(:id).and_return('machine-id')
allow(machine).to receive(:data_dir).and_return(data_dir)
allow(machine).to receive(:config).and_return(machine_config)
allow(machine).to receive(:env).and_return(machine_env)
end
end
let(:machine_config) do
double("machine_config").tap do |config|
config.stub(vm: vm_config)
end
end
let(:data_dir){ temporary_dir }
let(:machine_env) do
isolated_environment.tap do |i_env|
allow(i_env).to receive(:data_dir).and_return(data_dir)
allow(i_env).to receive(:lock).and_yield
end
end
let(:vm_config) do
double("machine_vm_config").tap do |config|
allow(config).to receive(:provisioners).and_return([])
end
end
let(:ui) do
double("ui").tap do |result|
allow(result).to receive(:info)
end
end
let(:instance){ described_class.new(app, env) }
describe "#call" do
context "with no provisioners defined" do
it "should process empty set of provisioners" do
expect(instance.call(env)).to eq([])
end
context "with provisioning disabled" do
before{ env[:provision_enabled] = false }
after{ env.delete(:provision_enabled) }
it "should not process any provisioners" do
expect(instance.call(env)).to be_nil
end
end
end
context "with single provisioner defined" do
let(:provisioner) do
prov = VagrantPlugins::Kernel_V2::VagrantConfigProvisioner.new("spec-test", :shell)
prov.config = provisioner_config
prov
end
let(:provisioner_config){ {} }
before{ expect(vm_config).to receive(:provisioners).and_return([provisioner]) }
it "should call the defined provisioner" do
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
context "with provisioning disabled" do
before{ env[:provision_enabled] = false }
after{ env.delete(:provision_enabled) }
it "should not process any provisioners" do
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
expect(instance.call(env)).to be_nil
end
end
context "with provisioner configured to run once" do
before{ provisioner.run = :once }
it "should run if machine is not provisioned" do
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if machine is provisioned" do
File.open(File.join(data_dir.to_s, "action_provision"), "w") do |file|
file.write("1.5:machine-id")
end
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if provision types are set and provisioner is not included" do
env[:provision_types] = ["other-provisioner", "other-test"]
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner name" do
env[:provision_types] = ["spec-test"]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner type" do
env[:provision_types] = [:shell]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
end
context "with provisioner configured to run always" do
before{ provisioner.run = :always }
it "should run if machine is not provisioned" do
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if machine is provisioned" do
File.open(File.join(data_dir.to_s, "action_provision"), "w") do |file|
file.write("1.5:machine-id")
end
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if provision types are set and provisioner is not included" do
env[:provision_types] = ["other-provisioner", "other-test"]
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner name" do
env[:provision_types] = ["spec-test"]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner type" do
env[:provision_types] = [:shell]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
end
context "with provisioner configured to never run" do
before{ provisioner.run = :never }
it "should not run if machine is not provisioned" do
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if machine is provisioned" do
File.open(File.join(data_dir.to_s, "action_provision"), "w") do |file|
file.write("1.5:machine-id")
end
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if provision types are set and provisioner is not included" do
env[:provision_types] = ["other-provisioner", "other-test"]
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner name" do
env[:provision_types] = ["spec-test"]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should run if provision types are set and include provisioner name and machine is provisioned" do
File.open(File.join(data_dir.to_s, "action_provision"), "w") do |file|
file.write("1.5:machine-id")
end
env[:provision_types] = ["spec-test"]
expect(hook).to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
it "should not run if provision types are set and include provisioner type" do
env[:provision_types] = [:shell]
expect(hook).not_to receive(:call).with(:provisioner_run, anything)
instance.call(env)
end
end
end
end
end

View File

@ -56,11 +56,11 @@ Vagrant.configure(2) do |global_config|
vmware.vmx['vhv.allow'] = 'TRUE' vmware.vmx['vhv.allow'] = 'TRUE'
end end
config.vm.provision :shell, path: "./scripts/#{platform}-setup.#{provider_name}.sh", run: "once" config.vm.provision :shell, path: "./scripts/#{platform}-setup.#{provider_name}.sh", run: "once"
GUEST_BOXES.each_with_index do |box_info, idx| guest_boxes.each_with_index do |box_info, idx|
guest_box, box_version = box_info guest_box, box_version = box_info
spec_cmd_args = ENV["VAGRANT_SPEC_ARGS"] spec_cmd_args = ENV["VAGRANT_SPEC_ARGS"]
if idx != 0 if idx != 0
spec_cmd_args = "#{spec_cmd_args} --without-component 'cli/*'".strip spec_cmd_args = "#{spec_cmd_args} --without-component cli/*".strip
end end
config.vm.provision( config.vm.provision(
:shell, :shell,

View File

@ -0,0 +1,8 @@
#!/bin/bash
set -x
export VAGRANT_SPEC_BOX="${VAGRANT_SPEC_BOX}"
vagrant vagrant-spec ${VAGRANT_SPEC_ARGS} /vagrant/test/vagrant-spec/configs/vagrant-spec.config.virtualbox.rb
result=$?
exit $result

View File

@ -0,0 +1,14 @@
#!/bin/bash
set -xe
curl -Lo /etc/yum.repos.d/virtualbox.repo http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
yum groupinstall -y "Development Tools"
yum install -y kernel-devel
yum install -y VirtualBox-${VAGRANT_CENTOS_VIRTUALBOX_VERSION:-5.1}
pushd /vagrant
rpm -ivh ./pkg/dist/vagrant_*_x86_64.rpm
vagrant plugin install ./vagrant-spec.gem
popd

View File

@ -1 +1 @@
1.9.3.dev 1.9.4.dev

View File

@ -2,7 +2,7 @@ set :base_url, "https://www.vagrantup.com/"
activate :hashicorp do |h| activate :hashicorp do |h|
h.name = "vagrant" h.name = "vagrant"
h.version = "1.9.2" h.version = "1.9.3"
h.github_slug = "mitchellh/vagrant" h.github_slug = "mitchellh/vagrant"
end end

View File

@ -29,6 +29,9 @@ you may set. A complete reference is shown below:
virtual machine to report an IP address. This defaults to 120 seconds. virtual machine to report an IP address. This defaults to 120 seconds.
This may have to be increased if your VM takes longer to boot. This may have to be increased if your VM takes longer to boot.
* `differencing_disk` (boolean) - Switch to use differencing disk intead of cloning whole VHD. * `differencing_disk` (boolean) - Switch to use differencing disk intead of cloning whole VHD.
* `enable_virtualization_extensions` (boolean) - Enable virtualization extensions for the virtual CPUs.
This allows Hyper-V to be nested and run inside another Hyper-VM VM. It requires Windows 10 - 1511 (build 10586) or newer.
Default is not defined. This will be disabled if not set.
* `vm_integration_services` (Hash) - Hash to set the state of integration services. * `vm_integration_services` (Hash) - Hash to set the state of integration services.
Example: Example:

View File

@ -14,7 +14,7 @@ Vagrant comes with support out of the box for [Hyper-V](https://en.wikipedia.org
a native hypervisor written by Microsoft. Hyper-V is available by default for a native hypervisor written by Microsoft. Hyper-V is available by default for
almost all Windows 8.1 installs. almost all Windows 8.1 installs.
The Hyper-V provider is compatible with Windows 8.1 only. Prior versions The Hyper-V provider is compatible with Windows 8.1 and later only. Prior versions
of Hyper-V do not include the necessary APIs for Vagrant to work. of Hyper-V do not include the necessary APIs for Vagrant to work.
Hyper-V must be enabled prior to using the provider. Most Windows installations Hyper-V must be enabled prior to using the provider. Most Windows installations