From 6900fc39045dbedef85d26c42c8acdb4d8b6bb4c Mon Sep 17 00:00:00 2001 From: Patrick Lang Date: Wed, 17 Aug 2016 22:41:32 -0700 Subject: [PATCH 01/15] Starting support for Hyper-V nested virtualization --- plugins/providers/hyperv/action/import.rb | 3 +++ plugins/providers/hyperv/config.rb | 2 ++ plugins/providers/hyperv/scripts/import_vm_xml.ps1 | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index d841242ff..226d99061 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -21,10 +21,12 @@ module VagrantPlugins differencing_disk = env[:machine].provider_config.differencing_disk auto_start_action = env[:machine].provider_config.auto_start_action auto_stop_action = env[:machine].provider_config.auto_stop_action + enable_virtualization_extensions = env[:machine].provider_config.enable_virtualization_extensions 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 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 differencing disk instead of cloning") if differencing_disk env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action @@ -145,6 +147,7 @@ module VagrantPlugins options[:auto_start_action] = auto_start_action if auto_start_action options[:auto_stop_action] = auto_stop_action if auto_stop_action options[:differencing_disk] = differencing_disk if differencing_disk + options[:enable_virtualization_extensions] = enable_virtualization_extensions if enable_virtualization_extensions env[:ui].detail("Creating and registering the VM...") server = env[:machine].provider.driver.import(options) diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index 1726bd45f..e4b40bb1f 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -26,6 +26,7 @@ module VagrantPlugins @differencing_disk = UNSET_VALUE @auto_start_action = UNSET_VALUE @auto_stop_action = UNSET_VALUE + @enable_virtualization_extensions = UNSET_VALUE end def finalize! @@ -41,6 +42,7 @@ module VagrantPlugins @differencing_disk = false if @differencing_disk == UNSET_VALUE @auto_start_action = nil if @auto_start_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? end def validate(machine) diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 index 16055e135..9622ea067 100644 --- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 @@ -10,7 +10,8 @@ Param( [string]$cpus=$null, [string]$vmname=$null, [string]$auto_start_action=$null, - [string]$auto_stop_action=$null + [string]$auto_stop_action=$null, + [bool]$enable_virtualization_extensions=$False ) # 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 [regex]$rx="\d" From 8cf2240383cded5bd6e3a4541193c16e42dffff3 Mon Sep 17 00:00:00 2001 From: Patrick Lang Date: Thu, 18 Aug 2016 23:45:44 -0700 Subject: [PATCH 02/15] Finish hooking up hv.enable_virtualization_extensions --- plugins/providers/hyperv/action/import.rb | 2 +- plugins/providers/hyperv/config.rb | 1 + plugins/providers/hyperv/scripts/import_vm_xml.ps1 | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index 226d99061..6c11a2105 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -147,7 +147,7 @@ module VagrantPlugins options[:auto_start_action] = auto_start_action if auto_start_action options[:auto_stop_action] = auto_stop_action if auto_stop_action options[:differencing_disk] = differencing_disk if differencing_disk - options[:enable_virtualization_extensions] = enable_virtualization_extensions if enable_virtualization_extensions + options[:enable_virtualization_extensions] = "$True" if enable_virtualization_extensions and enable_virtualization_extensions == true env[:ui].detail("Creating and registering the VM...") server = env[:machine].provider.driver.import(options) diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index e4b40bb1f..eec67d1b3 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -14,6 +14,7 @@ module VagrantPlugins 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 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 def initialize @ip_address_timeout = UNSET_VALUE diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 index 9622ea067..c7aca6b34 100644 --- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1 @@ -11,7 +11,7 @@ Param( [string]$vmname=$null, [string]$auto_start_action=$null, [string]$auto_stop_action=$null, - [bool]$enable_virtualization_extensions=$False + [string]$enable_virtualization_extensions=$False ) # Include the following modules From 06a0866d72ac899180b181a544f290e1d5b6ef32 Mon Sep 17 00:00:00 2001 From: Patrick Lang Date: Fri, 19 Aug 2016 09:32:16 -0700 Subject: [PATCH 03/15] Update hyperv config and OS version requirements --- website/source/docs/hyperv/configuration.html.md | 3 +++ website/source/docs/hyperv/index.html.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/website/source/docs/hyperv/configuration.html.md b/website/source/docs/hyperv/configuration.html.md index c6002ec34..59f12e54c 100644 --- a/website/source/docs/hyperv/configuration.html.md +++ b/website/source/docs/hyperv/configuration.html.md @@ -29,3 +29,6 @@ you may set. A complete reference is shown below: 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. * `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. \ No newline at end of file diff --git a/website/source/docs/hyperv/index.html.md b/website/source/docs/hyperv/index.html.md index 02f12b2bc..b847b9ab2 100644 --- a/website/source/docs/hyperv/index.html.md +++ b/website/source/docs/hyperv/index.html.md @@ -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 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. Hyper-V must be enabled prior to using the provider. Most Windows installations From eed7b859ca65ea4ca803cfb20a675a5b1f06d247 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 13 Mar 2017 13:53:31 -0700 Subject: [PATCH 04/15] Fix provision action for provisioners set to never. This updates the behavior of the provision action to never run a provisioner that is specified to "never" run unless it has been explicitly requested. Also adds test coverage to the provision action. --- lib/vagrant/action/builtin/provision.rb | 15 +- .../vagrant/action/builtin/provision_test.rb | 208 ++++++++++++++++++ 2 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 test/unit/vagrant/action/builtin/provision_test.rb diff --git a/lib/vagrant/action/builtin/provision.rb b/lib/vagrant/action/builtin/provision.rb index 02868c735..6c26121b7 100644 --- a/lib/vagrant/action/builtin/provision.rb +++ b/lib/vagrant/action/builtin/provision.rb @@ -102,12 +102,17 @@ module Vagrant type_map = provisioner_type_map(env) provisioner_instances(env).each do |p, options| 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 - next if !provision_enabled && options[:run] != :always + if options[:run] == :never + 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 if options[:name] diff --git a/test/unit/vagrant/action/builtin/provision_test.rb b/test/unit/vagrant/action/builtin/provision_test.rb new file mode 100644 index 000000000..031b87f1d --- /dev/null +++ b/test/unit/vagrant/action/builtin/provision_test.rb @@ -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 From e7ecfa8109df9c37906cf127eb2bb02aff5329f4 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 15 Mar 2017 11:02:31 -0700 Subject: [PATCH 05/15] Use guest boxes variable, not constant. Remove option value quotes. --- test/vagrant-spec/Vagrantfile.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vagrant-spec/Vagrantfile.spec b/test/vagrant-spec/Vagrantfile.spec index 554e8cf4f..5fbef713c 100644 --- a/test/vagrant-spec/Vagrantfile.spec +++ b/test/vagrant-spec/Vagrantfile.spec @@ -56,11 +56,11 @@ Vagrant.configure(2) do |global_config| vmware.vmx['vhv.allow'] = 'TRUE' end 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 spec_cmd_args = ENV["VAGRANT_SPEC_ARGS"] if idx != 0 - spec_cmd_args = "#{spec_cmd_args} --without-component 'cli/*'".strip + spec_cmd_args = "#{spec_cmd_args} --without-component cli/*".strip end config.vm.provision( :shell, From 7be5266e202b044e87ec9293280cd451e7017f09 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Mar 2017 14:18:14 -0700 Subject: [PATCH 06/15] Add spec support scripts for centos --- test/vagrant-spec/scripts/centos-run.virtualbox.sh | 8 ++++++++ .../scripts/centos-setup.virtualbox.sh | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/vagrant-spec/scripts/centos-run.virtualbox.sh create mode 100644 test/vagrant-spec/scripts/centos-setup.virtualbox.sh diff --git a/test/vagrant-spec/scripts/centos-run.virtualbox.sh b/test/vagrant-spec/scripts/centos-run.virtualbox.sh new file mode 100644 index 000000000..35f993609 --- /dev/null +++ b/test/vagrant-spec/scripts/centos-run.virtualbox.sh @@ -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 diff --git a/test/vagrant-spec/scripts/centos-setup.virtualbox.sh b/test/vagrant-spec/scripts/centos-setup.virtualbox.sh new file mode 100644 index 000000000..e670bf2a3 --- /dev/null +++ b/test/vagrant-spec/scripts/centos-setup.virtualbox.sh @@ -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 From a5234bd13f018151ef78c820216f0fa7852c5b9f Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Mar 2017 14:21:32 -0700 Subject: [PATCH 07/15] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eff347aa7..876623f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ IMPROVEMENTS: - core: Support host_ip for forwarded ports [GH-7035, GH-8350] - core: Include disk space hint in box install failure message [GH-8089] - core/bundler: Allow vagrant constraint matching in prerelease mode [GH-8341] + - provider/hyperv: Support enabling Hyper-V nested virtualization [GH-8325, GH-7738] BUG FIXES: From a082f4ae2b985652e3a1e85a6ca9367291ac743f Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Mar 2017 14:32:44 -0700 Subject: [PATCH 08/15] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 876623f65..efaccb85f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ BUG FIXES: - contrib/bash: Handle path spaces in bash completion [GH-8337] - core: Fix box sorting on find and list [GH-7956, GH-8334] - core/bundler: Force path as preferred source on install [GH-8327] + - core/provision: Update "never" behavior to match documentation [GH-8366, GH-8016] - plugins/synced_folders: Give UID/GID precedence if found within mount options [GH-8122, GH-8064, GH-7859] From a0761eb2ea6577375c3d834214df1421fa27579f Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Sun, 19 Mar 2017 07:35:46 -0700 Subject: [PATCH 09/15] Allow initialization argument to be used in parent --- plugins/providers/virtualbox/driver/version_5_1.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/providers/virtualbox/driver/version_5_1.rb b/plugins/providers/virtualbox/driver/version_5_1.rb index 51c2e4004..cd2e6df40 100644 --- a/plugins/providers/virtualbox/driver/version_5_1.rb +++ b/plugins/providers/virtualbox/driver/version_5_1.rb @@ -6,7 +6,7 @@ module VagrantPlugins # Driver for VirtualBox 5.1.x class Version_5_1 < Version_5_0 def initialize(uuid) - super() + super @logger = Log4r::Logger.new("vagrant::provider::virtualbox_5_1") end From 7a03c6e0131e3e592e1a7c7ea041217e8bc56bff Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 20 Mar 2017 11:38:44 -0700 Subject: [PATCH 10/15] Add /bin/docker to path list for installation verification --- plugins/provisioners/docker/cap/linux/docker_installed.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/provisioners/docker/cap/linux/docker_installed.rb b/plugins/provisioners/docker/cap/linux/docker_installed.rb index 11acdac5a..59e95b2fa 100644 --- a/plugins/provisioners/docker/cap/linux/docker_installed.rb +++ b/plugins/provisioners/docker/cap/linux/docker_installed.rb @@ -5,6 +5,7 @@ module VagrantPlugins module DockerInstalled def self.docker_installed(machine) paths = [ + "/bin/docker", "/usr/bin/docker", "/usr/local/bin/docker", "/usr/sbin/docker", From e0b9a6fabdd0acd2faf2ca0330217c46dbbdd1ce Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 20 Mar 2017 12:14:31 -0700 Subject: [PATCH 11/15] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index efaccb85f..c81306684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ IMPROVEMENTS: - core: Support host_ip for forwarded ports [GH-7035, GH-8350] - core: Include disk space hint in box install failure message [GH-8089] - 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: From 72d0eb497d1bd915a898ae714b30802f3c20bb6a Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 21 Mar 2017 14:50:12 -0700 Subject: [PATCH 12/15] Isolate push deprecation to atlas strategy only --- lib/vagrant/util/command_deprecation.rb | 6 +- plugins/commands/push/command.rb | 2 - plugins/pushes/atlas/push.rb | 6 + .../plugins/commands/push/command_test.rb | 50 ++-- test/unit/plugins/pushes/atlas/push_test.rb | 231 +++++++++--------- 5 files changed, 149 insertions(+), 146 deletions(-) diff --git a/lib/vagrant/util/command_deprecation.rb b/lib/vagrant/util/command_deprecation.rb index 62b1a1e54..a0d8b09ac 100644 --- a/lib/vagrant/util/command_deprecation.rb +++ b/lib/vagrant/util/command_deprecation.rb @@ -29,11 +29,11 @@ module Vagrant end alias_method :non_deprecated_execute, :execute - def execute + def execute(*args, &block) @env[:ui].warn(I18n.t("vagrant.commands.deprecated", name: deprecation_command_name ) + "\n") - non_deprecated_execute + non_deprecated_execute(*args, &block) end end end @@ -44,7 +44,7 @@ module Vagrant def self.included(klass) klass.include(CommandDeprecation) klass.class_eval do - def execute + def execute(*_) raise Vagrant::Errors::CommandDeprecated, name: deprecation_command_name end diff --git a/plugins/commands/push/command.rb b/plugins/commands/push/command.rb index 0b1793bcb..902a0c946 100644 --- a/plugins/commands/push/command.rb +++ b/plugins/commands/push/command.rb @@ -70,8 +70,6 @@ module VagrantPlugins return name end - - include Vagrant::Util::CommandDeprecation::Complete end end end diff --git a/plugins/pushes/atlas/push.rb b/plugins/pushes/atlas/push.rb index 73ec117b9..1cbc18d55 100644 --- a/plugins/pushes/atlas/push.rb +++ b/plugins/pushes/atlas/push.rb @@ -73,6 +73,12 @@ module VagrantPlugins return result end + + include Vagrant::Util::CommandDeprecation::Complete + + def deprecation_command_name + "push (atlas strategy)" + end end end end diff --git a/test/unit/plugins/commands/push/command_test.rb b/test/unit/plugins/commands/push/command_test.rb index 923a39e12..a97f4caba 100644 --- a/test/unit/plugins/commands/push/command_test.rb +++ b/test/unit/plugins/commands/push/command_test.rb @@ -33,37 +33,35 @@ describe VagrantPlugins::CommandPush::Command do allow(env).to receive(:push) end - # NOTE: Disabled due to deprecation - # - # it "validates the pushes" do - # expect(subject).to receive(:validate_pushes!).once - # subject.execute - # end + it "validates the pushes" do + expect(subject).to receive(:validate_pushes!).once + subject.execute + end - # it "delegates to Environment#push" do - # expect(env).to receive(:push).once - # subject.execute - # end + it "delegates to Environment#push" do + expect(env).to receive(:push).once + subject.execute + end - # it "validates the configuration" do - # iso_env.vagrantfile <<-EOH - # Vagrant.configure("2") do |config| - # config.vm.box = "hashicorp/precise64" + it "validates the configuration" do + iso_env.vagrantfile <<-EOH + Vagrant.configure("2") do |config| + config.vm.box = "hashicorp/precise64" - # config.push.define "noop" do |push| - # push.bad = "ham" - # end - # end - # EOH + config.push.define "noop" do |push| + push.bad = "ham" + end + end + EOH - # subject = described_class.new(argv, iso_env.create_vagrant_env) - # allow(subject).to receive(:validate_pushes!) - # .and_return(:noop) + subject = described_class.new(argv, iso_env.create_vagrant_env) + allow(subject).to receive(:validate_pushes!) + .and_return(:noop) - # expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err| - # expect(err.message).to include("The following settings shouldn't exist: bad") - # } - # end + expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err| + expect(err.message).to include("The following settings shouldn't exist: bad") + } + end end describe "#validate_pushes!" do diff --git a/test/unit/plugins/pushes/atlas/push_test.rb b/test/unit/plugins/pushes/atlas/push_test.rb index 9c2465177..6dbaccd93 100644 --- a/test/unit/plugins/pushes/atlas/push_test.rb +++ b/test/unit/plugins/pushes/atlas/push_test.rb @@ -27,154 +27,155 @@ describe VagrantPlugins::AtlasPush::Push do allow(Vagrant::Util::SafeExec).to receive(:exec) end - describe "#push" do - it "pushes with the uploader" do - allow(subject).to receive(:uploader_path).and_return("foo") + # DEPRECATED + # describe "#push" do + # 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 - end + # subject.push + # end - it "raises an exception if the uploader couldn't be found" do - expect(subject).to receive(:uploader_path).and_return(nil) + # it "raises an exception if the uploader couldn't be found" do + # expect(subject).to receive(:uploader_path).and_return(nil) - expect { subject.push }.to raise_error( - VagrantPlugins::AtlasPush::Errors::UploaderNotFound) - end - end + # expect { subject.push }.to raise_error( + # VagrantPlugins::AtlasPush::Errors::UploaderNotFound) + # end + # end - describe "#execute" do - let(:app) { "foo/bar" } + # describe "#execute" do + # let(:app) { "foo/bar" } - before do - config.app = app - end + # before do + # config.app = app + # end - it "sends the basic flags" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", app, env.root_path.to_s) + # it "sends the basic flags" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", app, env.root_path.to_s) - subject.execute("foo") - end + # subject.execute("foo") + # end - it "doesn't send VCS if disabled" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", app, env.root_path.to_s) + # it "doesn't send VCS if disabled" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", app, env.root_path.to_s) - config.vcs = false - subject.execute("foo") - end + # config.vcs = false + # subject.execute("foo") + # end - it "sends includes" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", "-include", "foo", "-include", - "bar", app, env.root_path.to_s) + # it "sends includes" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", "-include", "foo", "-include", + # "bar", app, env.root_path.to_s) - config.includes = ["foo", "bar"] - subject.execute("foo") - end + # config.includes = ["foo", "bar"] + # subject.execute("foo") + # end - it "sends excludes" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", "-exclude", "foo", "-exclude", - "bar", app, env.root_path.to_s) + # it "sends excludes" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", "-exclude", "foo", "-exclude", + # "bar", app, env.root_path.to_s) - config.excludes = ["foo", "bar"] - subject.execute("foo") - end + # config.excludes = ["foo", "bar"] + # subject.execute("foo") + # end - it "sends custom server address" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s) + # it "sends custom server address" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s) - config.address = "foo" - subject.execute("foo") - end + # config.address = "foo" + # subject.execute("foo") + # end - it "sends custom token" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s) + # it "sends custom token" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s) - config.token = "atlas_token" - subject.execute("foo") - end + # config.token = "atlas_token" + # subject.execute("foo") + # end - context "when metadata is available" do - let(:env) do - iso_env = isolated_environment - iso_env.vagrantfile <<-EOH - Vagrant.configure("2") do |config| - config.vm.box = "hashicorp/precise64" - config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64" - end - EOH - iso_env.create_vagrant_env - end + # context "when metadata is available" do + # let(:env) do + # iso_env = isolated_environment + # iso_env.vagrantfile <<-EOH + # Vagrant.configure("2") do |config| + # config.vm.box = "hashicorp/precise64" + # config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64" + # end + # EOH + # iso_env.create_vagrant_env + # end - it "sends the metadata" do - expect(Vagrant::Util::SafeExec).to receive(:exec). - with("foo", "-vcs", "-metadata", "box=hashicorp/precise64", - "-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64", - "-token", "atlas_token", app, env.root_path.to_s) + # it "sends the metadata" do + # expect(Vagrant::Util::SafeExec).to receive(:exec). + # with("foo", "-vcs", "-metadata", "box=hashicorp/precise64", + # "-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64", + # "-token", "atlas_token", app, env.root_path.to_s) - config.token = "atlas_token" - subject.execute("foo") - end - end - end + # config.token = "atlas_token" + # subject.execute("foo") + # end + # end + # end - describe "#uploader_path" do - let(:scratch) do - Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path")) - end + # describe "#uploader_path" do + # let(:scratch) do + # Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path")) + # end - after do - FileUtils.rm_rf(scratch) - end + # after do + # FileUtils.rm_rf(scratch) + # end - it "should return the configured path if set" do - config.uploader_path = "foo" - expect(subject.uploader_path).to eq("foo") - end + # it "should return the configured path if set" do + # config.uploader_path = "foo" + # expect(subject.uploader_path).to eq("foo") + # end - it "should look up the uploader via PATH if not set" do - allow(Vagrant).to receive(:in_installer?).and_return(false) + # it "should look up the uploader via PATH if not set" do + # allow(Vagrant).to receive(:in_installer?).and_return(false) - expect(Vagrant::Util::Which).to receive(:which). - with(described_class.const_get(:UPLOADER_BIN)). - and_return("bar") + # expect(Vagrant::Util::Which).to receive(:which). + # with(described_class.const_get(:UPLOADER_BIN)). + # and_return("bar") - expect(subject.uploader_path).to eq("bar") - end + # expect(subject.uploader_path).to eq("bar") + # end - 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(:installer_embedded_dir).and_return(scratch.to_s) + # 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(:installer_embedded_dir).and_return(scratch.to_s) - bin_path = scratch.join("bin", bin) - bin_path.dirname.mkpath - bin_path.open("w+") { |f| f.write("hi") } + # bin_path = scratch.join("bin", bin) + # bin_path.dirname.mkpath + # bin_path.open("w+") { |f| f.write("hi") } - expect(subject.uploader_path).to eq(bin_path.to_s) - end + # expect(subject.uploader_path).to eq(bin_path.to_s) + # end - 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(:installer_embedded_dir).and_return(scratch.to_s) + # 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(:installer_embedded_dir).and_return(scratch.to_s) - expect(Vagrant::Util::Which).to receive(:which). - with(described_class.const_get(:UPLOADER_BIN)). - and_return("bar") + # expect(Vagrant::Util::Which).to receive(:which). + # with(described_class.const_get(:UPLOADER_BIN)). + # and_return("bar") - expect(subject.uploader_path).to eq("bar") - end + # expect(subject.uploader_path).to eq("bar") + # end - it "should return nil if its not found anywhere" do - allow(Vagrant).to receive(:in_installer?).and_return(false) - allow(Vagrant::Util::Which).to receive(:which).and_return(nil) + # it "should return nil if its not found anywhere" do + # allow(Vagrant).to receive(:in_installer?).and_return(false) + # allow(Vagrant::Util::Which).to receive(:which).and_return(nil) - expect(subject.uploader_path).to be_nil - end - end + # expect(subject.uploader_path).to be_nil + # end + # end end From b8a9fbb1c309fb65e1e71768f3c345b5613150f6 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 21 Mar 2017 16:34:39 -0700 Subject: [PATCH 13/15] Release v1.9.3 --- CHANGELOG.md | 5 ++--- version.txt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c81306684..f4fd006e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,4 @@ -## Next version (Unreleased) - -FEATURES: +## 1.9.3 (March 21, 2017) IMPROVEMENTS: @@ -18,6 +16,7 @@ BUG FIXES: - core: Fix box sorting on find and list [GH-7956, GH-8334] - 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 [GH-8122, GH-8064, GH-7859] diff --git a/version.txt b/version.txt index a0d911970..77fee73a8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.3.dev +1.9.3 From 6f5597620c370e9405662893152a85d75ac6589e Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 21 Mar 2017 17:35:09 -0700 Subject: [PATCH 14/15] Update download version to 1.9.3 --- website/config.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/config.rb b/website/config.rb index 6b38823d6..c27859c60 100644 --- a/website/config.rb +++ b/website/config.rb @@ -2,7 +2,7 @@ set :base_url, "https://www.vagrantup.com/" activate :hashicorp do |h| h.name = "vagrant" - h.version = "1.9.2" + h.version = "1.9.3" h.github_slug = "mitchellh/vagrant" end From b90ba95804207b166cf58513b2aad963f0d7f4c8 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 21 Mar 2017 17:36:10 -0700 Subject: [PATCH 15/15] Bump version for new development --- CHANGELOG.md | 9 +++++++++ version.txt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4fd006e5..dbc7015a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## Next version (Unreleased) + +FEATURES: + +IMPROVEMENTS: + +BUG FIXES: + + ## 1.9.3 (March 21, 2017) IMPROVEMENTS: diff --git a/version.txt b/version.txt index 77fee73a8..afaf01fd8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.3 +1.9.4.dev