Merge pull request #11867 from marxarelli/fix/storage-controller-array-sort
Avoid sorting of controllers with nil boot_priority
This commit is contained in:
commit
7103be62b9
@ -27,10 +27,8 @@ module VagrantPlugins
|
|||||||
#
|
#
|
||||||
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
||||||
def get_primary_controller
|
def get_primary_controller
|
||||||
ordered = sort { |a, b| a.boot_priority <=> b.boot_priority }
|
ordered = find_all(&:supported?).sort_by(&:boot_priority)
|
||||||
controller = ordered.detect do |c|
|
controller = ordered.detect { |c| c.attachments.any? { |a| hdd?(a) } }
|
||||||
c.supported? && c.attachments.any? { |a| hdd?(a) }
|
|
||||||
end
|
|
||||||
|
|
||||||
if !controller
|
if !controller
|
||||||
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
||||||
@ -62,8 +60,8 @@ module VagrantPlugins
|
|||||||
#
|
#
|
||||||
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
# @return [VagrantPlugins::ProviderVirtualBox::Model::StorageController]
|
||||||
def get_dvd_controller
|
def get_dvd_controller
|
||||||
ordered = sort { |a, b| a.boot_priority <=> b.boot_priority }
|
ordered = find_all(&:supported?).sort_by(&:boot_priority)
|
||||||
controller = ordered.detect { |c| c.supported? }
|
controller = ordered.first
|
||||||
if !controller
|
if !controller
|
||||||
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
raise Vagrant::Errors::VirtualBoxDisksNoSupportedControllers,
|
||||||
supported_types: supported_types.join(" ,")
|
supported_types: supported_types.join(" ,")
|
||||||
|
|||||||
@ -91,7 +91,7 @@ describe VagrantPlugins::ProviderVirtualBox::Model::StorageControllerArray do
|
|||||||
|
|
||||||
describe "#get_dvd_controller" do
|
describe "#get_dvd_controller" do
|
||||||
context "with one controller" do
|
context "with one controller" do
|
||||||
let(:controller) { double("controller", supported?: true) }
|
let(:controller) { double("controller", supported?: true, boot_priority: 1) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.replace([controller])
|
subject.replace([controller])
|
||||||
@ -111,9 +111,10 @@ describe VagrantPlugins::ProviderVirtualBox::Model::StorageControllerArray do
|
|||||||
context "with multiple controllers" do
|
context "with multiple controllers" do
|
||||||
let(:controller1) { double("controller", supported?: true, boot_priority: 2) }
|
let(:controller1) { double("controller", supported?: true, boot_priority: 2) }
|
||||||
let(:controller2) { double("controller", supported?: true, boot_priority: 1) }
|
let(:controller2) { double("controller", supported?: true, boot_priority: 1) }
|
||||||
|
let(:controller3) { double("controller", supported?: false, boot_priority: nil) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.replace([controller1, controller2])
|
subject.replace([controller1, controller2, controller3])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the first supported controller" do
|
it "returns the first supported controller" do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user