Hook into ValidateDiskExt capability

This commit is contained in:
Jeff Bonhag 2020-07-01 12:12:39 -04:00
parent 883e45cc49
commit 21954c29af
No known key found for this signature in database
GPG Key ID: 32966F3FB5AC1129
2 changed files with 9 additions and 6 deletions

View File

@ -294,7 +294,7 @@ module VagrantPlugins
dsk_info[:port] = port.to_s
# Check for a free device
if port_attachments.detect { |a| a[:device] == "0" }
if port_attachments.any? { |a| a[:device] == "0" }
dsk_info[:device] = "1"
else
dsk_info[:device] = "0"

View File

@ -1,12 +1,11 @@
require_relative "../cap/validate_disk_ext"
module VagrantPlugins
module ProviderVirtualBox
module Model
# A collection of storage controllers. Includes finder methods to look
# up a storage controller by given attributes.
class StorageControllerArray < Array
# TODO: hook into ValidateDiskExt capability
DEFAULT_DISK_EXT = [".vdi", ".vmdk", ".vhd"].map(&:freeze).freeze
# Returns a storage controller with the given name. Raises an
# exception if a matching controller can't be found.
#
@ -86,8 +85,12 @@ module VagrantPlugins
# @param [Hash] attachment - Attachment information
# @return [Boolean]
def hdd?(attachment)
ext = File.extname(attachment[:location].to_s).downcase
DEFAULT_DISK_EXT.include?(ext)
if !attachment
false
else
ext = File.extname(attachment[:location].to_s).downcase.split('.').last
VagrantPlugins::ProviderVirtualBox::Cap::ValidateDiskExt.validate_disk_ext(nil, ext)
end
end
end
end