diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 5a219570e..52fc1a897 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -940,6 +940,10 @@ module Vagrant error_key(:virtualbox_disks_primary_not_found) end + class VirtualBoxDisksUnsupportedController < VagrantError + error_key(:virtualbox_disks_unsupported_controller) + end + class VirtualBoxGuestPropertyNotFound < VagrantError error_key(:virtualbox_guest_property_not_found) end diff --git a/plugins/providers/virtualbox/cap/configure_disks.rb b/plugins/providers/virtualbox/cap/configure_disks.rb index b5792d19b..d420ca91e 100644 --- a/plugins/providers/virtualbox/cap/configure_disks.rb +++ b/plugins/providers/virtualbox/cap/configure_disks.rb @@ -221,7 +221,7 @@ module VagrantPlugins dsk_info[:port] = next_available_port.to_s dsk_info[:device] = "0" - else + elsif controller.storage_bus == 'IDE' # IDE Controllers have primary/secondary devices, so find the first port # with an empty device (0..(controller.maxportcount-1)).each do |port| @@ -238,6 +238,8 @@ module VagrantPlugins dsk_info[:device] = "0" end end + else + raise Vagrant::Errors::VirtualBoxDisksUnsupportedController, controller_name: controller.name end if dsk_info[:port].to_s.empty? diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 1218d9a56..5c1421f5f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1683,16 +1683,19 @@ en: '%{storage_bus}', but no such controller was found. Please add the proper controller to your guest using provider-specific customizations. - virtualbox_disks_primary_not_found: |- - Vagrant was not able to detect a primary disk attached to the SATA - controller. Vagrant Disks requires that the primary disk be attached - to the first port of the SATA controller in order to manage it. virtualbox_disks_defined_exceed_limit: |- VirtualBox only allows up to %{limit} disks to be attached to a single guest using the %{storage_bus} controller, including the primary disk. Please ensure only up to %{limit} disks of type '%{type}' are configured for your guest. + virtualbox_disks_primary_not_found: |- + Vagrant was not able to detect a primary disk attached to the SATA + controller. Vagrant Disks requires that the primary disk be attached + to the first port of the SATA controller in order to manage it. + virtualbox_disks_unsupported_controller: |- + An disk operation was attempted on the controller '%{controller_name}', + but Vagrant doesn't support this type of disk controller. virtualbox_guest_property_not_found: |- Could not find a required VirtualBox guest property: %{guest_property} diff --git a/test/unit/plugins/providers/virtualbox/cap/configure_disks_test.rb b/test/unit/plugins/providers/virtualbox/cap/configure_disks_test.rb index 334893541..78a1d3436 100644 --- a/test/unit/plugins/providers/virtualbox/cap/configure_disks_test.rb +++ b/test/unit/plugins/providers/virtualbox/cap/configure_disks_test.rb @@ -348,6 +348,15 @@ describe VagrantPlugins::ProviderVirtualBox::Cap::ConfigureDisks do end end end + + context "unsupported storage controller" do + let(:controller) { double("controller", name: "Adaptec ACB-4000A", storage_bus: "SASI") } + + it "raises an error" do + expect { subject.get_next_port(machine, controller) } + .to raise_error(Vagrant::Errors::VirtualBoxDisksUnsupportedController) + end + end end describe "#resize_disk" do