Error on unsupported storage controller type

This commit is contained in:
Jeff Bonhag 2020-06-05 18:00:18 -04:00
parent c9be89718d
commit c9bdcb6839
No known key found for this signature in database
GPG Key ID: 32966F3FB5AC1129
4 changed files with 23 additions and 5 deletions

View File

@ -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

View File

@ -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?

View File

@ -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}

View File

@ -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