From aa5a3ef7f74f0029f89f594e6c12cefe324c416d Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 17 Oct 2019 15:24:27 -0700 Subject: [PATCH 01/57] Add initial disk management config class --- plugins/kernel_v2/config/disk.rb | 79 ++++++++++++++++++++++++++++++++ plugins/kernel_v2/config/vm.rb | 24 ++++++++++ 2 files changed, 103 insertions(+) create mode 100644 plugins/kernel_v2/config/disk.rb diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb new file mode 100644 index 000000000..427a5f1b5 --- /dev/null +++ b/plugins/kernel_v2/config/disk.rb @@ -0,0 +1,79 @@ +require "log4r" +require "securerandom" + +module VagrantPlugins + module Kernel_V2 + class VagrantConfigDisk < Vagrant.plugin("2", :config) + #------------------------------------------------------------------- + # Config class for a given Disk + #------------------------------------------------------------------- + + # Note: This value is for internal use only + # + # @return [String] + attr_reader :id + + # Name for the given Disk. Defaults to nil. + # + # TODO: Should probably default to a string+short integer id + # + # @return [String] + attr_accessor :name + + # Type of disk to create + # + # @return [Symbol] + attr_accessor :type + + # Size of disk to create + # + # @return [Integer] + attr_accessor :size + + # Provider specific options + # + # TODO: INTERNAL?? + # + # @return [Hash] + attr_accessor :options + + def initialize(type) + @logger = Log4r::Logger.new("vagrant::config::vm::trigger::config") + + @name = UNSET_VALUE + @type = UNSET_VALUE + @size = UNSET_VALUE + @options = UNSET_VALUE + + # Internal options + @id = SecureRandom.uuid + end + + def finalize! + # Ensure all config options are set to nil or default value if untouched + # by user + @name = nil if @name == UNSET_VALUE + @type = nil if @type == UNSET_VALUE + @size = nil if @size == UNSET_VALUE + + @options = nil if @options == UNSET_VALUE + end + + # @return [Array] array of strings of error messages from config option validation + def validate(machine) + errors = _detected_errors + + # validate type with list of known disk types + + errors + end + + # The String representation of this Disk. + # + # @return [String] + def to_s + "disk config" + end + end + end +end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index b80bda8ca..b2d110fa8 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -11,6 +11,7 @@ require "vagrant/util/experimental" require File.expand_path("../vm_provisioner", __FILE__) require File.expand_path("../vm_subvm", __FILE__) +require File.expand_path("../disk", __FILE__) module VagrantPlugins module Kernel_V2 @@ -79,6 +80,7 @@ module VagrantPlugins @__compiled_provider_configs = {} @__defined_vm_keys = [] @__defined_vms = {} + @__drives = {} @__finalized = false @__networks = {} @__providers = {} @@ -123,6 +125,11 @@ module VagrantPlugins end end + # Merge defined drives + # TODO: Actually write this + other_drives = other.instance_variable_get(:@__drives) + new_drives = @__drives.dup + # Merge the providers by prepending any configuration blocks we # have for providers onto the new configuration. other_providers = other.instance_variable_get(:@__providers) @@ -185,6 +192,7 @@ module VagrantPlugins result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys) result.instance_variable_set(:@__defined_vms, new_defined_vms) + result.instance_variable_set(:@__drives, new_drives) result.instance_variable_set(:@__providers, new_providers) result.instance_variable_set(:@__provider_order, new_order) result.instance_variable_set(:@__provider_overrides, new_overrides) @@ -384,6 +392,17 @@ module VagrantPlugins @__defined_vms[name].config_procs << [options[:config_version], block] if block end + def disk(type, &block) + disk = VagrantConfigDisk.new(type) + if block.is_a?(Hash) + disk.set_options(block) + else + block.call(disk, VagrantConfigDisk) + end + + @__drives[disk[:id]] = disk + end + #------------------------------------------------------------------- # Internal methods, don't call these. #------------------------------------------------------------------- @@ -547,6 +566,11 @@ module VagrantPlugins end end + # TODO: This might need to be more complicated + @__drives.each do |d| + d.finalize! + end + if !current_dir_shared && !@__synced_folders["/vagrant"] synced_folder(".", "/vagrant") end From e361900d3ab2096da3a15d0ad564308f287e75a8 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 17 Oct 2019 15:31:04 -0700 Subject: [PATCH 02/57] Update doc string for name attribute --- plugins/kernel_v2/config/disk.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 427a5f1b5..86fca0490 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -13,9 +13,9 @@ module VagrantPlugins # @return [String] attr_reader :id - # Name for the given Disk. Defaults to nil. + # File name for the given disk. Defaults to nil. # - # TODO: Should probably default to a string+short integer id + # TODO: Should probably default to a string+short integer id in the finalize method # # @return [String] attr_accessor :name From 1a21782bd5f2063e7d627bb304bc582d94ddd875 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 17 Oct 2019 15:36:21 -0700 Subject: [PATCH 03/57] Add note about disk name --- plugins/kernel_v2/config/disk.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 86fca0490..603df7a37 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -17,6 +17,15 @@ module VagrantPlugins # # TODO: Should probably default to a string+short integer id in the finalize method # + # Sometihng like: + # + # - `vagrant_short_id` + # + # Where short_id is calculated from the disks ID + # + # Finalize method in `Config#VM` might need to ensure there aren't colliding disk names? + # It might also depend on the provider + # # @return [String] attr_accessor :name From abcc3349002e17d6a0d2ae5ae3ba13121eaf6752 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 17 Oct 2019 15:39:58 -0700 Subject: [PATCH 04/57] Add note about disk options value --- plugins/kernel_v2/config/disk.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 603df7a37..8400d59df 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -41,7 +41,13 @@ module VagrantPlugins # Provider specific options # - # TODO: INTERNAL?? + # This should work similar to how a "Provisioner" class works: + # + # - This class is the base class where as this options value is actually a + # provider specific class for the given options for that provider, if required + # + # - Hopefully in general the top-scope disk options are enough for the general + # case that most people won't need provider specific options except for very specific cases # # @return [Hash] attr_accessor :options From 98a2d0f72330d2bf170f2d4b43ebaf28b389583e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 18 Oct 2019 09:10:26 -0700 Subject: [PATCH 05/57] Update internal drives state to be array instead of hash --- plugins/kernel_v2/config/vm.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index b2d110fa8..6e972a9d4 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -80,7 +80,7 @@ module VagrantPlugins @__compiled_provider_configs = {} @__defined_vm_keys = [] @__defined_vms = {} - @__drives = {} + @__drives = [] @__finalized = false @__networks = {} @__providers = {} @@ -400,7 +400,7 @@ module VagrantPlugins block.call(disk, VagrantConfigDisk) end - @__drives[disk[:id]] = disk + @__drives << disk end #------------------------------------------------------------------- From 34673fe5f949a4ad082ffb6cc21896bee8e88473 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 18 Oct 2019 09:39:31 -0700 Subject: [PATCH 06/57] Add disk class function for provider layers --- plugins/kernel_v2/config/disk.rb | 36 ++++++++++++++++++++++++++++---- plugins/kernel_v2/config/vm.rb | 5 ++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 8400d59df..95483c05d 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -49,19 +49,47 @@ module VagrantPlugins # - Hopefully in general the top-scope disk options are enough for the general # case that most people won't need provider specific options except for very specific cases # - # @return [Hash] - attr_accessor :options + # @return [Object] + attr_accessor :config def initialize(type) @logger = Log4r::Logger.new("vagrant::config::vm::trigger::config") @name = UNSET_VALUE @type = UNSET_VALUE + @provider_type = UNSET_VALUE @size = UNSET_VALUE - @options = UNSET_VALUE + @config = nil + @invalid = false # Internal options @id = SecureRandom.uuid + + # find disk provider plugin + @config_class = nil + # @invalid = true if provider not found + if !@config_class + @logger.info( + "Disk config for '#{@provider_type}' not found. Ignoring config.") + @config_class = Vagrant::Config::V2::DummyConfig + end + end + + def add_config(**options, &block) + return if invalid? + + current = @config_class.new + current.set_options(options) if options + block.call(current) if block + current = @config.merge(current) if @config + @config = current + end + + # Returns true or false if disk provider is found + # + # @return [Bool] + def invalid? + @invalid end def finalize! @@ -71,7 +99,7 @@ module VagrantPlugins @type = nil if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE - @options = nil if @options == UNSET_VALUE + @config = nil if @options == UNSET_VALUE end # @return [Array] array of strings of error messages from config option validation diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 6e972a9d4..879a4f466 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -392,7 +392,7 @@ module VagrantPlugins @__defined_vms[name].config_procs << [options[:config_version], block] if block end - def disk(type, &block) + def disk(type, **options, &block) disk = VagrantConfigDisk.new(type) if block.is_a?(Hash) disk.set_options(block) @@ -400,7 +400,10 @@ module VagrantPlugins block.call(disk, VagrantConfigDisk) end + disk.add_config(options, block) + @__drives << disk + end #------------------------------------------------------------------- From ee388d82934169d0e4b28b133f77d24980d3812b Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 18 Oct 2019 11:03:55 -0700 Subject: [PATCH 07/57] Ensure config is renamed to options --- plugins/kernel_v2/config/disk.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 95483c05d..7570ac076 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -66,6 +66,7 @@ module VagrantPlugins @id = SecureRandom.uuid # find disk provider plugin + # Need to pass in provider or figure out provider here @config_class = nil # @invalid = true if provider not found if !@config_class @@ -99,7 +100,7 @@ module VagrantPlugins @type = nil if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE - @config = nil if @options == UNSET_VALUE + @config = nil if @config == UNSET_VALUE end # @return [Array] array of strings of error messages from config option validation From 28d339eac59fe925d3fb2d6b0f3b0eab9ef89f47 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 18 Oct 2019 11:27:46 -0700 Subject: [PATCH 08/57] Ensure block is properly passed through to add_config --- plugins/kernel_v2/config/vm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 879a4f466..7ec7942aa 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -400,7 +400,7 @@ module VagrantPlugins block.call(disk, VagrantConfigDisk) end - disk.add_config(options, block) + disk.add_config(options, &block) @__drives << disk From 393ce9eb1b3337b1532ac814da862ce046100a3b Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 13:41:30 -0700 Subject: [PATCH 09/57] Rename drives to disks to match class, and properly merge configs --- plugins/kernel_v2/config/vm.rb | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 7ec7942aa..5734cebae 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -80,7 +80,7 @@ module VagrantPlugins @__compiled_provider_configs = {} @__defined_vm_keys = [] @__defined_vms = {} - @__drives = [] + @__disks = [] @__finalized = false @__networks = {} @__providers = {} @@ -125,10 +125,22 @@ module VagrantPlugins end end - # Merge defined drives - # TODO: Actually write this - other_drives = other.instance_variable_get(:@__drives) - new_drives = @__drives.dup + # Merge defined disks + other_disks = other.instance_variable_get(:@__disks) + new_disks = @__disks.dup + @__disks.each do |d| + other_d = other_disks.find { |o| d.id == o.id } + if other_d + # There is an override. Take it. + other_d.config = d.config.merge(other_p.config) + end + + # There is an override, merge it into the + new_disks << d.dup + end + other_disks.each do |d| + new_disks << d.dup + end # Merge the providers by prepending any configuration blocks we # have for providers onto the new configuration. @@ -192,7 +204,7 @@ module VagrantPlugins result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys) result.instance_variable_set(:@__defined_vms, new_defined_vms) - result.instance_variable_set(:@__drives, new_drives) + result.instance_variable_set(:@__disks, new_disks) result.instance_variable_set(:@__providers, new_providers) result.instance_variable_set(:@__provider_order, new_order) result.instance_variable_set(:@__provider_overrides, new_overrides) @@ -402,8 +414,7 @@ module VagrantPlugins disk.add_config(options, &block) - @__drives << disk - + @__disks << disk end #------------------------------------------------------------------- @@ -570,7 +581,7 @@ module VagrantPlugins end # TODO: This might need to be more complicated - @__drives.each do |d| + @__disks.each do |d| d.finalize! end From a18ce4f7328ca9e6a50e6a0be58a10fcf67c8243 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 13:41:50 -0700 Subject: [PATCH 10/57] Add primary config option for disk --- plugins/kernel_v2/config/disk.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 7570ac076..f903cd366 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -39,6 +39,11 @@ module VagrantPlugins # @return [Integer] attr_accessor :size + # Determines if this disk is the _main_ disk, or an attachment. Defaults to true + # + # @return [Boolean] + attr_accessor :primary + # Provider specific options # # This should work similar to how a "Provisioner" class works: @@ -59,6 +64,7 @@ module VagrantPlugins @type = UNSET_VALUE @provider_type = UNSET_VALUE @size = UNSET_VALUE + @primary = UNSET_VALUE @config = nil @invalid = false @@ -99,6 +105,7 @@ module VagrantPlugins @name = nil if @name == UNSET_VALUE @type = nil if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE + @primary = true if @primary == UNSET_VALUE @config = nil if @config == UNSET_VALUE end From 995c4bbc604a056473811a71b3f26cff2713f1b7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 14:07:40 -0700 Subject: [PATCH 11/57] Add validation for disk configs --- plugins/kernel_v2/config/disk.rb | 27 ++++++++++++++++++++++----- plugins/kernel_v2/config/vm.rb | 12 +++++++++++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index f903cd366..7c0386cdf 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -8,6 +8,8 @@ module VagrantPlugins # Config class for a given Disk #------------------------------------------------------------------- + DEFAULT_DISK_TYPES = [:disk, :dvd, :floppy].freeze + # Note: This value is for internal use only # # @return [String] @@ -29,17 +31,20 @@ module VagrantPlugins # @return [String] attr_accessor :name - # Type of disk to create + # Type of disk to create. Defaults to `:disk` # # @return [Symbol] attr_accessor :type # Size of disk to create # + # TODO: Should we have shortcuts for GB??? + # # @return [Integer] attr_accessor :size - # Determines if this disk is the _main_ disk, or an attachment. Defaults to true + # Determines if this disk is the _main_ disk, or an attachment. + # Defaults to true. # # @return [Boolean] attr_accessor :primary @@ -60,8 +65,9 @@ module VagrantPlugins def initialize(type) @logger = Log4r::Logger.new("vagrant::config::vm::trigger::config") + @type = type + @name = UNSET_VALUE - @type = UNSET_VALUE @provider_type = UNSET_VALUE @size = UNSET_VALUE @primary = UNSET_VALUE @@ -102,11 +108,13 @@ module VagrantPlugins def finalize! # Ensure all config options are set to nil or default value if untouched # by user - @name = nil if @name == UNSET_VALUE - @type = nil if @type == UNSET_VALUE + @type = :disk if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE @primary = true if @primary == UNSET_VALUE + # generate name instead of nil if unset_value + @name = nil if @name == UNSET_VALUE + @config = nil if @config == UNSET_VALUE end @@ -116,6 +124,15 @@ module VagrantPlugins # validate type with list of known disk types + if !DEFAULT_DISK_TYPES.include?(@type) + errors << "Disk type '#{@type}' is not a valid type. Please pick one of the following supported disk types: #{DEFAULT_DISK_TYPES.join(', ')}" + end + + # TODO: Convert a string to int here? + if !@size.is_a?(Integer) + errors << "Config option size for disk is not an integer" + end + errors end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 5734cebae..69aab52f2 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -580,7 +580,6 @@ module VagrantPlugins end end - # TODO: This might need to be more complicated @__disks.each do |d| d.finalize! end @@ -786,6 +785,17 @@ module VagrantPlugins end end + # Validate disks + # Check if there is more than one primrary disk defined and throw an error + if @__disks.select { |d| d.primary && d.type == :disk }.size > 1 + errors << "There is more than one disk defined for guest '#{machine.name}'. Please pick a `primary` disk." + end + + @__disks.each do |d| + error = d.validate(machine) + errors.concat error if !error.empty? + end + # We're done with VM level errors so prepare the section errors = { "vm" => errors } From ee751ca6e18ef9c6b7e68ada0604422401c51f06 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 14:14:38 -0700 Subject: [PATCH 12/57] Add disk name for disk config --- plugins/kernel_v2/config/disk.rb | 5 +++-- plugins/kernel_v2/config/vm.rb | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 7c0386cdf..ae8f7ad24 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -112,8 +112,9 @@ module VagrantPlugins @size = nil if @size == UNSET_VALUE @primary = true if @primary == UNSET_VALUE - # generate name instead of nil if unset_value - @name = nil if @name == UNSET_VALUE + # Give the disk a default name if unset + # TODO: Name not required if primray? + @name = "vagrant_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE @config = nil if @config == UNSET_VALUE end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 69aab52f2..3bb7d41e1 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -791,6 +791,8 @@ module VagrantPlugins errors << "There is more than one disk defined for guest '#{machine.name}'. Please pick a `primary` disk." end + # TODO: Check for duplicate disk names? + @__disks.each do |d| error = d.validate(machine) errors.concat error if !error.empty? From 7cfccb5cfd272a98227dc225b6db9625ad9bf868 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 14:17:07 -0700 Subject: [PATCH 13/57] Update variable docs for disk name --- plugins/kernel_v2/config/disk.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index ae8f7ad24..25fb42261 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -15,18 +15,9 @@ module VagrantPlugins # @return [String] attr_reader :id - # File name for the given disk. Defaults to nil. + # File name for the given disk. Defaults to a generated name that is: # - # TODO: Should probably default to a string+short integer id in the finalize method - # - # Sometihng like: - # - # - `vagrant_short_id` - # - # Where short_id is calculated from the disks ID - # - # Finalize method in `Config#VM` might need to ensure there aren't colliding disk names? - # It might also depend on the provider + # vagrant__ # # @return [String] attr_accessor :name From ad73969010c5cb96c85c5fa55e9e207acbc929db Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 14:45:34 -0700 Subject: [PATCH 14/57] Fixup disk config parsing to allow hash and block --- plugins/kernel_v2/config/disk.rb | 4 ++-- plugins/kernel_v2/config/vm.rb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 25fb42261..b372d24ed 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -84,7 +84,7 @@ module VagrantPlugins current = @config_class.new current.set_options(options) if options - block.call(current) if block + block.call(current) if block_given? current = @config.merge(current) if @config @config = current end @@ -121,7 +121,7 @@ module VagrantPlugins end # TODO: Convert a string to int here? - if !@size.is_a?(Integer) + if @size && !@size.is_a?(Integer) errors << "Config option size for disk is not an integer" end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 3bb7d41e1..4a8906d02 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -406,12 +406,14 @@ module VagrantPlugins def disk(type, **options, &block) disk = VagrantConfigDisk.new(type) - if block.is_a?(Hash) - disk.set_options(block) - else + + disk.set_options(options) + + if block_given? block.call(disk, VagrantConfigDisk) end + # Add provider config disk.add_config(options, &block) @__disks << disk From c18f36e51638e00402c4b1b111db1439a65c128c Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 14:52:24 -0700 Subject: [PATCH 15/57] Fix code comment typo --- plugins/kernel_v2/config/disk.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index b372d24ed..1d6959676 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -104,7 +104,7 @@ module VagrantPlugins @primary = true if @primary == UNSET_VALUE # Give the disk a default name if unset - # TODO: Name not required if primray? + # TODO: Name not required if primary? @name = "vagrant_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE @config = nil if @config == UNSET_VALUE From 8adffc830a02f285a5e73c2c067d0d8d4c71cfd5 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 15:05:32 -0700 Subject: [PATCH 16/57] Add builtin disk action --- lib/vagrant/action/builtin/disk.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/vagrant/action/builtin/disk.rb diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb new file mode 100644 index 000000000..c0d4738cd --- /dev/null +++ b/lib/vagrant/action/builtin/disk.rb @@ -0,0 +1,19 @@ +module Vagrant + module Action + module Builtin + class Disk + def initialize(app, env) + @app = app + @logger = Log4r::Logger.new("vagrant::action::builtin::disk") + end + + def call(env) + machine = env[:machine] + + # Continue On + @app.call(env) + end + end + end + end +end From a55e3d2b910867d22f6256cdab15ee17b1458498 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 15:31:24 -0700 Subject: [PATCH 17/57] Make config.vm.disks accessible instead of internal --- plugins/kernel_v2/config/vm.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 4a8906d02..cb3d63e50 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -44,6 +44,7 @@ module VagrantPlugins attr_accessor :post_up_message attr_accessor :usable_port_range attr_reader :provisioners + attr_reader :disks # This is an experimental feature that isn't public yet. attr_accessor :clone @@ -74,13 +75,13 @@ module VagrantPlugins @hostname = UNSET_VALUE @post_up_message = UNSET_VALUE @provisioners = [] + @disks = [] @usable_port_range = UNSET_VALUE # Internal state @__compiled_provider_configs = {} @__defined_vm_keys = [] @__defined_vms = {} - @__disks = [] @__finalized = false @__networks = {} @__providers = {} @@ -126,9 +127,9 @@ module VagrantPlugins end # Merge defined disks - other_disks = other.instance_variable_get(:@__disks) - new_disks = @__disks.dup - @__disks.each do |d| + other_disks = other.instance_variable_get(:@disks) + new_disks = @disks.dup + @disks.each do |d| other_d = other_disks.find { |o| d.id == o.id } if other_d # There is an override. Take it. @@ -204,7 +205,7 @@ module VagrantPlugins result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys) result.instance_variable_set(:@__defined_vms, new_defined_vms) - result.instance_variable_set(:@__disks, new_disks) + result.instance_variable_set(:@disks, new_disks) result.instance_variable_set(:@__providers, new_providers) result.instance_variable_set(:@__provider_order, new_order) result.instance_variable_set(:@__provider_overrides, new_overrides) @@ -416,7 +417,7 @@ module VagrantPlugins # Add provider config disk.add_config(options, &block) - @__disks << disk + @disks << disk end #------------------------------------------------------------------- @@ -582,7 +583,7 @@ module VagrantPlugins end end - @__disks.each do |d| + @disks.each do |d| d.finalize! end @@ -789,13 +790,13 @@ module VagrantPlugins # Validate disks # Check if there is more than one primrary disk defined and throw an error - if @__disks.select { |d| d.primary && d.type == :disk }.size > 1 + if @disks.select { |d| d.primary && d.type == :disk }.size > 1 errors << "There is more than one disk defined for guest '#{machine.name}'. Please pick a `primary` disk." end # TODO: Check for duplicate disk names? - @__disks.each do |d| + @disks.each do |d| error = d.validate(machine) errors.concat error if !error.empty? end From cef1bd47b3408c704c74e9ca0c471712ceb67753 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 15:31:51 -0700 Subject: [PATCH 18/57] Add initial disk builtin action --- lib/vagrant/action.rb | 1 + lib/vagrant/action/builtin/disk.rb | 15 +++++++++++++++ plugins/providers/virtualbox/action.rb | 1 + 3 files changed, 17 insertions(+) diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 4b37c69f1..c0eaffcc8 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -15,6 +15,7 @@ module Vagrant autoload :Confirm, "vagrant/action/builtin/confirm" autoload :ConfigValidate, "vagrant/action/builtin/config_validate" autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm" + autoload :Disk, "vagrant/action/builtin/disk" autoload :EnvSet, "vagrant/action/builtin/env_set" autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt" autoload :HandleBox, "vagrant/action/builtin/handle_box" diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index c0d4738cd..54977e76b 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -9,10 +9,25 @@ module Vagrant def call(env) machine = env[:machine] + defined_disks = get_disks(machine, env) + + # Check that provider plugin is installed for disk + # If not, log warning or error to user that disks won't be managed # Continue On @app.call(env) end + + def get_disks(machine, env) + return @_disks if @_disks + + @_disks = [] + @_disks = machine.config.vm.disks.map do |disk| + # initialize the disk provider?? + end + + @_disks + end end end end diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index bb4e677af..edfbbcbe0 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -79,6 +79,7 @@ module VagrantPlugins b.use ForwardPorts b.use SetHostname b.use SaneDefaults + b.use Disk b.use Customize, "pre-boot" b.use Boot b.use Customize, "post-boot" From 499e39dd1093e3f47a81cc6b9bf92abdfed4d3c7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 23 Oct 2019 15:32:04 -0700 Subject: [PATCH 19/57] Ensure primary is true or false --- plugins/kernel_v2/config/disk.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 1d6959676..3b5f351b6 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -101,7 +101,12 @@ module VagrantPlugins # by user @type = :disk if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE - @primary = true if @primary == UNSET_VALUE + + if @primary == UNSET_VALUE + @primary = true + else + @primary = false + end # Give the disk a default name if unset # TODO: Name not required if primary? From d6df83103e8e45410a17e41b95c4ff8e4af596d9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 28 Oct 2019 13:21:16 -0700 Subject: [PATCH 20/57] Add todo for attaching and configuring disk for a given provider --- lib/vagrant/action/builtin/disk.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index 54977e76b..31dca1177 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -14,6 +14,8 @@ module Vagrant # Check that provider plugin is installed for disk # If not, log warning or error to user that disks won't be managed + # TODO: configure and attach disks for the machines providers implementation + # Continue On @app.call(env) end From 93828508ec11e6330ff044aea87dfa49cc904c8e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 10:20:44 -0700 Subject: [PATCH 21/57] Update config/vm with tests for disk config --- plugins/kernel_v2/config/vm.rb | 33 +++++++++------- test/unit/plugins/kernel_v2/config/vm_test.rb | 38 +++++++++++++++++++ 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index cb3d63e50..8a9de6d38 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -128,20 +128,27 @@ module VagrantPlugins # Merge defined disks other_disks = other.instance_variable_get(:@disks) - new_disks = @disks.dup - @disks.each do |d| - other_d = other_disks.find { |o| d.id == o.id } - if other_d - # There is an override. Take it. - other_d.config = d.config.merge(other_p.config) + new_disks = [] + @disks.each do |p| + other_p = other_disks.find { |o| p.id == o.id } + if other_p + # there is an override. take it. + other_p.config = p.config.merge(other_p.config) + #other_p.run ||= p.run + #next if !other_p.preserve_order + + # we're preserving order, delete from other + p = other_p + other_disks.delete(other_p) end - # There is an override, merge it into the - new_disks << d.dup + # there is an override, merge it into the + new_disks << p.dup end - other_disks.each do |d| - new_disks << d.dup + other_disks.each do |p| + new_disks << p.dup end + result.instance_variable_set(:@disks, new_disks) # Merge the providers by prepending any configuration blocks we # have for providers onto the new configuration. @@ -173,17 +180,17 @@ module VagrantPlugins @provisioners.each do |p| other_p = other_provs.find { |o| p.id == o.id } if other_p - # There is an override. Take it. + # there is an override. take it. other_p.config = p.config.merge(other_p.config) other_p.run ||= p.run next if !other_p.preserve_order - # We're preserving order, delete from other + # we're preserving order, delete from other p = other_p other_provs.delete(other_p) end - # There is an override, merge it into the + # there is an override, merge it into the new_provs << p.dup end other_provs.each do |p| diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 00576cbb3..92f7d7e3c 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -549,6 +549,44 @@ describe VagrantPlugins::Kernel_V2::VMConfig do end end + describe "#disk" do + it "stores the disks" do + subject.disk("disk", size: 100) + subject.disk("disk", size: 1000, primary: false, name: "storage") + subject.finalize! + + d = subject.disks + expect(d.length).to eql(2) + expect(d[0].size).to eql(100) + expect(d[1].size).to eql(1000) + expect(d[1].name).to eql("storage") + end + + it "does not merge duplicate disks" do + subject.disk("disk", size: 1000, primary: false, name: "storage") + subject.disk("disk", size: 1000, primary: false, name: "backup") + + merged = subject.merge(subject) + merged_disks = merged.disks + + expect(merged_disks.length).to eql(2) + end + + it "ignores non-overriding runs" do + subject.disk("disk", name: "foo") + + other = described_class.new + other.disk("disk", name: "bar", primary: false) + + merged = subject.merge(other) + merged_disks = merged.disks + + expect(merged_disks.length).to eql(2) + expect(merged_disks[0].name).to eq("foo") + expect(merged_disks[1].name).to eq("bar") + end + end + describe "#synced_folder(s)" do it "defaults to sharing the current directory" do subject.finalize! From 87366cf4f351cec80ade437087cc835c15144992 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 10:28:18 -0700 Subject: [PATCH 22/57] Add basic disk config unit tests --- .../plugins/kernel_v2/config/disk_test.rb | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/unit/plugins/kernel_v2/config/disk_test.rb diff --git a/test/unit/plugins/kernel_v2/config/disk_test.rb b/test/unit/plugins/kernel_v2/config/disk_test.rb new file mode 100644 index 000000000..d88f78e24 --- /dev/null +++ b/test/unit/plugins/kernel_v2/config/disk_test.rb @@ -0,0 +1,56 @@ +require File.expand_path("../../../../base", __FILE__) + +require Vagrant.source_root.join("plugins/kernel_v2/config/disk") + +describe VagrantPlugins::Kernel_V2::VagrantConfigDisk do + include_context "unit" + + let(:type) { :disk } + + subject { described_class.new(type) } + + let(:machine) { double("machine") } + + def assert_invalid + errors = subject.validate(machine) + if !errors.empty? { |v| !v.empty? } + raise "No errors: #{errors.inspect}" + end + end + + def assert_valid + errors = subject.validate(machine) + if !errors.empty? { |v| v.empty? } + raise "Errors: #{errors.inspect}" + end + end + + before do + env = double("env") + + subject.name = "foo" + subject.size = 100 + end + + describe "with defaults" do + it "is valid with test defaults" do + subject.finalize! + assert_valid + end + + it "sets a command" do + subject.finalize! + expect(subject.type).to eq(type) + end + + it "defaults to primray disk" do + subject.finalize! + expect(subject.primary).to eq(true) + end + end + + describe "defining a new config that needs to match internal restraints" do + before do + end + end +end From 9c1d05113f8d39e49fa3b8ac67421ed51ddeb118 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 10:33:29 -0700 Subject: [PATCH 23/57] Update merge comment for disk config --- plugins/kernel_v2/config/vm.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 8a9de6d38..c65fbd963 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -134,10 +134,8 @@ module VagrantPlugins if other_p # there is an override. take it. other_p.config = p.config.merge(other_p.config) - #other_p.run ||= p.run - #next if !other_p.preserve_order - # we're preserving order, delete from other + # Remove duplicate disk config from other p = other_p other_disks.delete(other_p) end From 35f113e759bce9bcb427bbfdf207476bffe2ca6e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 10:34:29 -0700 Subject: [PATCH 24/57] Put back accidental case switching for comments on provisioner --- plugins/kernel_v2/config/vm.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index c65fbd963..e550734c0 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -178,17 +178,17 @@ module VagrantPlugins @provisioners.each do |p| other_p = other_provs.find { |o| p.id == o.id } if other_p - # there is an override. take it. + # There is an override. Take it. other_p.config = p.config.merge(other_p.config) other_p.run ||= p.run next if !other_p.preserve_order - # we're preserving order, delete from other + # We're preserving order, delete from other p = other_p other_provs.delete(other_p) end - # there is an override, merge it into the + # There is an override, merge it into the new_provs << p.dup end other_provs.each do |p| From 71ad0f7abab345db093d73f30b939a9026ae3f16 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 10:36:25 -0700 Subject: [PATCH 25/57] Remove duplicate setting of disks variable --- plugins/kernel_v2/config/vm.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index e550734c0..067832e76 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -210,7 +210,6 @@ module VagrantPlugins result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys) result.instance_variable_set(:@__defined_vms, new_defined_vms) - result.instance_variable_set(:@disks, new_disks) result.instance_variable_set(:@__providers, new_providers) result.instance_variable_set(:@__provider_order, new_order) result.instance_variable_set(:@__provider_overrides, new_overrides) From f01c90e676d2eb6f01ec61fa6c87bdad1631685f Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 29 Oct 2019 11:01:50 -0700 Subject: [PATCH 26/57] Rename rspec test name --- test/unit/plugins/kernel_v2/config/disk_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/plugins/kernel_v2/config/disk_test.rb b/test/unit/plugins/kernel_v2/config/disk_test.rb index d88f78e24..dccfd14b6 100644 --- a/test/unit/plugins/kernel_v2/config/disk_test.rb +++ b/test/unit/plugins/kernel_v2/config/disk_test.rb @@ -38,7 +38,7 @@ describe VagrantPlugins::Kernel_V2::VagrantConfigDisk do assert_valid end - it "sets a command" do + it "sets a disk type" do subject.finalize! expect(subject.type).to eq(type) end From d54e870752dc0c45c89c1f59b6dbfd92a0159367 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 30 Oct 2019 13:35:21 -0700 Subject: [PATCH 27/57] Add file option to disk config --- plugins/kernel_v2/config/disk.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 3b5f351b6..a26ec8ada 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -34,6 +34,12 @@ module VagrantPlugins # @return [Integer] attr_accessor :size + # Path to the location of the disk file (Optional) + # + # @return [String] + attr_accessor :file + + # Determines if this disk is the _main_ disk, or an attachment. # Defaults to true. # @@ -64,6 +70,7 @@ module VagrantPlugins @primary = UNSET_VALUE @config = nil @invalid = false + @file = UNSET_VALUE # Internal options @id = SecureRandom.uuid @@ -101,6 +108,7 @@ module VagrantPlugins # by user @type = :disk if @type == UNSET_VALUE @size = nil if @size == UNSET_VALUE + @file = nil if @file == UNSET_VALUE if @primary == UNSET_VALUE @primary = true @@ -130,6 +138,14 @@ module VagrantPlugins errors << "Config option size for disk is not an integer" end + if @file + if !@file.is_a?(String) + errors << "Config option `file` for #{machine.name} disk config is not a string" + else + # Validate that file exists + end + end + errors end From 6c54bf6ad92f9054a6119421b503268599f5e191 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 30 Oct 2019 15:37:01 -0700 Subject: [PATCH 28/57] Fix logger namespace typo --- plugins/kernel_v2/config/disk.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index a26ec8ada..13cecc63f 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -60,7 +60,7 @@ module VagrantPlugins attr_accessor :config def initialize(type) - @logger = Log4r::Logger.new("vagrant::config::vm::trigger::config") + @logger = Log4r::Logger.new("vagrant::config::vm::disk") @type = type From e598007237160210d6f1aa890f0f78fbd5c38399 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 31 Oct 2019 11:41:51 -0700 Subject: [PATCH 29/57] Add provider specific disk options under provider_config hash --- plugins/kernel_v2/config/disk.rb | 54 ++++++++++---------------------- plugins/kernel_v2/config/vm.rb | 22 ++++++++----- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 13cecc63f..1ba152c68 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -48,59 +48,39 @@ module VagrantPlugins # Provider specific options # - # This should work similar to how a "Provisioner" class works: - # - # - This class is the base class where as this options value is actually a - # provider specific class for the given options for that provider, if required - # - # - Hopefully in general the top-scope disk options are enough for the general - # case that most people won't need provider specific options except for very specific cases - # - # @return [Object] - attr_accessor :config + # @return [Hash] + attr_accessor :provider_config def initialize(type) @logger = Log4r::Logger.new("vagrant::config::vm::disk") @type = type + @provider_config = {} @name = UNSET_VALUE @provider_type = UNSET_VALUE @size = UNSET_VALUE @primary = UNSET_VALUE - @config = nil - @invalid = false @file = UNSET_VALUE # Internal options @id = SecureRandom.uuid + end - # find disk provider plugin - # Need to pass in provider or figure out provider here - @config_class = nil - # @invalid = true if provider not found - if !@config_class - @logger.info( - "Disk config for '#{@provider_type}' not found. Ignoring config.") - @config_class = Vagrant::Config::V2::DummyConfig + def add_provider_config(**options, &block) + current = {} + options.each do |k,v| + opts = k.to_s.split("__") + if opts.size == 2 + current[opts[0]] = opts[1] + else + @logger.warn("Disk option '#{k}' found that does not match expected schema") + end end - end - def add_config(**options, &block) - return if invalid? - - current = @config_class.new - current.set_options(options) if options - block.call(current) if block_given? - current = @config.merge(current) if @config - @config = current - end - - # Returns true or false if disk provider is found - # - # @return [Bool] - def invalid? - @invalid + #block.call(current) if block + current = @provider_config.merge(current) if !@provider_config.empty? + @provider_config = current end def finalize! @@ -120,7 +100,7 @@ module VagrantPlugins # TODO: Name not required if primary? @name = "vagrant_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE - @config = nil if @config == UNSET_VALUE + @provider_config = nil if @provider_config == {} end # @return [Array] array of strings of error messages from config option validation diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 067832e76..7a4a46b72 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -410,18 +410,26 @@ module VagrantPlugins end def disk(type, **options, &block) - disk = VagrantConfigDisk.new(type) + disk_config = VagrantConfigDisk.new(type) - disk.set_options(options) + # Remove provider__option options before set_options, otherwise will + # show up as missing setting + # + # We can probably combine this into a single method call...? + provider_options = options.select { |k,v| k.to_s.include?("__") } + options.delete_if { |k,v| k.to_s.include?("__") } - if block_given? - block.call(disk, VagrantConfigDisk) - end + disk_config.set_options(options) + + # Can't use blocks if we use provider__option + #if block_given? + # block.call(disk, VagrantConfigDisk) + #end # Add provider config - disk.add_config(options, &block) + disk_config.add_provider_config(provider_options, &block) - @disks << disk + @disks << disk_config end #------------------------------------------------------------------- From 83fea21ff18d6c97af52895b88cb49391e20e1c8 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 31 Oct 2019 14:46:16 -0700 Subject: [PATCH 30/57] Simplify builtin disk action --- lib/vagrant/action/builtin/disk.rb | 9 ++------- plugins/kernel_v2/config/disk.rb | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index 31dca1177..d896abae0 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -11,10 +11,7 @@ module Vagrant machine = env[:machine] defined_disks = get_disks(machine, env) - # Check that provider plugin is installed for disk - # If not, log warning or error to user that disks won't be managed - - # TODO: configure and attach disks for the machines providers implementation + # Call into providers machine implementation for disk management # Continue On @app.call(env) @@ -24,9 +21,7 @@ module Vagrant return @_disks if @_disks @_disks = [] - @_disks = machine.config.vm.disks.map do |disk| - # initialize the disk provider?? - end + @_disks = machine.config.vm.disks @_disks end diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 1ba152c68..eec9b686c 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -39,7 +39,6 @@ module VagrantPlugins # @return [String] attr_accessor :file - # Determines if this disk is the _main_ disk, or an attachment. # Defaults to true. # From a51e9b1fa1e4695ac80e235a09c6adf430b3821d Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 6 Nov 2019 13:53:54 -0800 Subject: [PATCH 31/57] Support both kinds of provider config options for disk config --- plugins/kernel_v2/config/disk.rb | 18 +++++++++++++++--- plugins/kernel_v2/config/vm.rb | 22 +++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index eec9b686c..0f84633c5 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -66,18 +66,30 @@ module VagrantPlugins @id = SecureRandom.uuid end + # Helper method for storing provider specific config options + # + # Expected format is: + # + # - `provider__diskoption: value` + # - `{provider: {diskoption: value, otherdiskoption: value, ...}` + # + # Duplicates will be overriden + # + # @param [Hash] options def add_provider_config(**options, &block) current = {} options.each do |k,v| opts = k.to_s.split("__") + if opts.size == 2 - current[opts[0]] = opts[1] + current[opts[0].to_sym] = {opts[1].to_sym => v} + elsif v.is_a?(Hash) + current[k] = v else - @logger.warn("Disk option '#{k}' found that does not match expected schema") + @logger.warn("Disk option '#{k}' found that does not match expected provider disk config schema.") end end - #block.call(current) if block current = @provider_config.merge(current) if !@provider_config.empty? @provider_config = current end diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 7a4a46b72..cc96581ae 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -409,23 +409,27 @@ module VagrantPlugins @__defined_vms[name].config_procs << [options[:config_version], block] if block end + # Stores disk config options from Vagrantfile + # + # @param [Symbol] type + # @param [Hash] options + # @param [Block] block def disk(type, **options, &block) disk_config = VagrantConfigDisk.new(type) # Remove provider__option options before set_options, otherwise will # show up as missing setting - # - # We can probably combine this into a single method call...? - provider_options = options.select { |k,v| k.to_s.include?("__") } - options.delete_if { |k,v| k.to_s.include?("__") } + # Extract provider hash options as well + provider_options = {} + options.delete_if do |p,o| + if o.is_a?(Hash) || p.to_s.include?("__") + provider_options[p] = o + true + end + end disk_config.set_options(options) - # Can't use blocks if we use provider__option - #if block_given? - # block.call(disk, VagrantConfigDisk) - #end - # Add provider config disk_config.add_provider_config(provider_options, &block) From a457dee8b021fd2ff5b2a6638c576953532e7fbf Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 11:29:46 -0800 Subject: [PATCH 32/57] Set default disk to non-primary --- plugins/kernel_v2/config/disk.rb | 4 ++-- test/unit/plugins/kernel_v2/config/disk_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 0f84633c5..afdcfdc7c 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -102,9 +102,9 @@ module VagrantPlugins @file = nil if @file == UNSET_VALUE if @primary == UNSET_VALUE - @primary = true - else @primary = false + else + @primary = true end # Give the disk a default name if unset diff --git a/test/unit/plugins/kernel_v2/config/disk_test.rb b/test/unit/plugins/kernel_v2/config/disk_test.rb index dccfd14b6..88640d274 100644 --- a/test/unit/plugins/kernel_v2/config/disk_test.rb +++ b/test/unit/plugins/kernel_v2/config/disk_test.rb @@ -43,9 +43,9 @@ describe VagrantPlugins::Kernel_V2::VagrantConfigDisk do expect(subject.type).to eq(type) end - it "defaults to primray disk" do + it "defaults to non-primray disk" do subject.finalize! - expect(subject.primary).to eq(true) + expect(subject.primary).to eq(false) end end From 54c3e28a451fc76b629e0242f9fff317fbb79e54 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 13:25:00 -0800 Subject: [PATCH 33/57] Add comment for potential hook into provider configuring disk --- lib/vagrant/action/builtin/disk.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index d896abae0..6767b01bb 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -12,6 +12,8 @@ module Vagrant defined_disks = get_disks(machine, env) # Call into providers machine implementation for disk management + # + # machine.provider.configure_disks(defined_disks) # Continue On @app.call(env) From 1a02c52852f3d4a2d5354e6c25ed6596bfadd02e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 13:58:02 -0800 Subject: [PATCH 34/57] Add beginning of disk management docs for vagrant website --- .../source/docs/disks/configuration.html.md | 24 +++++++++++++++++++ website/source/docs/disks/index.html.md | 14 +++++++++++ website/source/docs/disks/usage.html.md | 13 ++++++++++ website/source/layouts/docs.erb | 8 +++++++ 4 files changed, 59 insertions(+) create mode 100644 website/source/docs/disks/configuration.html.md create mode 100644 website/source/docs/disks/index.html.md create mode 100644 website/source/docs/disks/usage.html.md diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md new file mode 100644 index 000000000..33b9c8d69 --- /dev/null +++ b/website/source/docs/disks/configuration.html.md @@ -0,0 +1,24 @@ +--- +layout: "docs" +page_title: "Vagrant Disks Configuration" +sidebar_current: "disks-configuration" +description: |- + Documentation of various configuration options for Vagrant Disks +--- + +# Configuration + +Vagrant Disks has several options that allow users to define and attach disks to guests. + +## Disk Options + +* `name` (string) - Optional argument to give the disk a name +* `type` (symbol) - The type of disk to manage. This option defaults to `:disk`. Please read the provider specific documentation for supported types. +* `file` (string) - Optional argument that defines a path on disk pointing to the location of a disk file. +* `primary` (boolean) - Optional argument that configures a given disk to be the "primary" disk to manage on the guest. There can only be one `primary` disk per guest. +* `provider_config` (hash) - Additional provider specific options for managing a given disk. + + **Note:** The `provider_config` option will depend on the provider you are using. Please read the provider specific documentation for disk management to learn about what options are available to use. + +## Disk Types + diff --git a/website/source/docs/disks/index.html.md b/website/source/docs/disks/index.html.md new file mode 100644 index 000000000..a3ffe1ccb --- /dev/null +++ b/website/source/docs/disks/index.html.md @@ -0,0 +1,14 @@ +--- +layout: "docs" +page_title: "Vagrant Disks" +sidebar_current: "disks" +description: |- + Introduction to Vagrant Disks +--- + +# Vagrant Disks + +As of version 2.3.0, Vagrant is capable managing what disks are available for a given guest. + +For more information about what options are available for configuring disks, see the +[configuration section](/docs/disks/configuration.html). diff --git a/website/source/docs/disks/usage.html.md b/website/source/docs/disks/usage.html.md new file mode 100644 index 000000000..09175f80c --- /dev/null +++ b/website/source/docs/disks/usage.html.md @@ -0,0 +1,13 @@ +--- +layout: "docs" +page_title: "Vagrant Disk Usage" +sidebar_current: "disk-usage" +description: |- + Various Vagrant Disk examples +--- + +# Basic Usage + +Below are some very simple examples of how to use Vagrant Disks. + +## Examples diff --git a/website/source/layouts/docs.erb b/website/source/layouts/docs.erb index d95ba8666..ff84ad238 100644 --- a/website/source/layouts/docs.erb +++ b/website/source/layouts/docs.erb @@ -128,6 +128,14 @@ + > + Disks + + + > Multi-Machine From 97db5d5da3f1595bbf9d31301d4f0d369c78d22c Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 14:19:02 -0800 Subject: [PATCH 35/57] Add todo for disk management overview --- website/source/docs/disks/index.html.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/source/docs/disks/index.html.md b/website/source/docs/disks/index.html.md index a3ffe1ccb..9cf53dfb5 100644 --- a/website/source/docs/disks/index.html.md +++ b/website/source/docs/disks/index.html.md @@ -10,5 +10,7 @@ description: |- As of version 2.3.0, Vagrant is capable managing what disks are available for a given guest. +TODO: GIVE A HIGH LEVEL OVERVIEW HERE + For more information about what options are available for configuring disks, see the [configuration section](/docs/disks/configuration.html). From 9190f4b2e640bd73947f041fe74ad9fe6106cc2a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 14:19:14 -0800 Subject: [PATCH 36/57] Fix nav sidebar view for disk page --- website/source/docs/disks/usage.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/disks/usage.html.md b/website/source/docs/disks/usage.html.md index 09175f80c..c160a7111 100644 --- a/website/source/docs/disks/usage.html.md +++ b/website/source/docs/disks/usage.html.md @@ -1,7 +1,7 @@ --- layout: "docs" page_title: "Vagrant Disk Usage" -sidebar_current: "disk-usage" +sidebar_current: "disks-usage" description: |- Various Vagrant Disk examples --- From f51805e91025b6d989555d21aa80de10aee6206a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 14:19:22 -0800 Subject: [PATCH 37/57] Add list of examples to write up for disk feature --- website/source/docs/disks/usage.html.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/source/docs/disks/usage.html.md b/website/source/docs/disks/usage.html.md index c160a7111..b09121c6a 100644 --- a/website/source/docs/disks/usage.html.md +++ b/website/source/docs/disks/usage.html.md @@ -11,3 +11,8 @@ description: |- Below are some very simple examples of how to use Vagrant Disks. ## Examples + +- Resizing a disk (primary) +- Attaching a new disk +- Using provider specific options +- ??? From 7feee7a87fe387c35e1141c37903da347d037bab Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 15:44:52 -0800 Subject: [PATCH 38/57] Add locale for primary disk validation error --- plugins/kernel_v2/config/vm.rb | 6 ++++-- templates/locales/en.yml | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index cc96581ae..e4fff571c 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -806,8 +806,10 @@ module VagrantPlugins # Validate disks # Check if there is more than one primrary disk defined and throw an error - if @disks.select { |d| d.primary && d.type == :disk }.size > 1 - errors << "There is more than one disk defined for guest '#{machine.name}'. Please pick a `primary` disk." + primary_disks = @disks.select { |d| d.primary && d.type == :disk } + if primary_disks.size > 1 + errors << I18n.t("vagrant.config.vm.multiple_primary_disks_error", + name: machine.name) end # TODO: Check for duplicate disk names? diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4d045e32b..2e78e01a6 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1892,6 +1892,8 @@ en: hyphens or dots. It cannot start with a hyphen or dot. ignore_provider_config: |- Ignoring provider config for validation... + multiple_primary_disks_error: |- + There are more than one primary disks defined for guest '%{name}'. Please ensure that only one disk has been defined as a primary disk. name_invalid: |- The sub-VM name '%{name}' is invalid. Please don't use special characters. network_ip_ends_in_one: |- From b0f4d43663253ab4ae1d7908403ccf2ec4259946 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 16:36:24 -0800 Subject: [PATCH 39/57] Add docs around various ways to define provider specific options for disk configs --- website/source/docs/disks/configuration.html.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md index 33b9c8d69..e249719de 100644 --- a/website/source/docs/disks/configuration.html.md +++ b/website/source/docs/disks/configuration.html.md @@ -18,7 +18,14 @@ Vagrant Disks has several options that allow users to define and attach disks to * `primary` (boolean) - Optional argument that configures a given disk to be the "primary" disk to manage on the guest. There can only be one `primary` disk per guest. * `provider_config` (hash) - Additional provider specific options for managing a given disk. - **Note:** The `provider_config` option will depend on the provider you are using. Please read the provider specific documentation for disk management to learn about what options are available to use. + Generally, the disk option accepts two kinds of ways to define a provider config: + + + `providername__diskoption = value` + - The provider name followed by a double underscore, and then the provider specific option for that disk + + `{providername: {diskoption: value}, otherprovidername: {diskoption: value}` + - A hash where the top level key(s) are one or more providers, and each provider keys values are a hash of options and their values. + + **Note:** More specific examples of these can be found under the provider specific disk page. The `provider_config` option will depend on the provider you are using. Please read the provider specific documentation for disk management to learn about what options are available to use. ## Disk Types From 63b35ad909b8d45b78dbeb734b576b7057871132 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 16:43:49 -0800 Subject: [PATCH 40/57] Begin to add short guide for plugin authors and the disk config object --- website/source/docs/disks/configuration.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md index e249719de..8afc347fb 100644 --- a/website/source/docs/disks/configuration.html.md +++ b/website/source/docs/disks/configuration.html.md @@ -29,3 +29,6 @@ Vagrant Disks has several options that allow users to define and attach disks to ## Disk Types +## Provider Author Guide + +If you are a vagrant plugin author who maintains a provider for Vagrant, this short guide will hopefully give some information on how to use the internal disk config object. From 17f8fbe65e5b1c925d82d658b9475a3911da2b9d Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Wed, 13 Nov 2019 16:54:28 -0800 Subject: [PATCH 41/57] Fix how double underscore options are shown in docs --- website/source/docs/disks/configuration.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md index 8afc347fb..9e150614e 100644 --- a/website/source/docs/disks/configuration.html.md +++ b/website/source/docs/disks/configuration.html.md @@ -20,7 +20,7 @@ Vagrant Disks has several options that allow users to define and attach disks to Generally, the disk option accepts two kinds of ways to define a provider config: - + `providername__diskoption = value` + + `providername__diskoption: value` - The provider name followed by a double underscore, and then the provider specific option for that disk + `{providername: {diskoption: value}, otherprovidername: {diskoption: value}` - A hash where the top level key(s) are one or more providers, and each provider keys values are a hash of options and their values. From 8031ebe9d184f1544b2582ea05a85605dd12f2e7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 14 Nov 2019 11:29:35 -0800 Subject: [PATCH 42/57] Add some todos for the disk website docs --- website/source/docs/disks/configuration.html.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md index 9e150614e..afbccaf35 100644 --- a/website/source/docs/disks/configuration.html.md +++ b/website/source/docs/disks/configuration.html.md @@ -32,3 +32,9 @@ Vagrant Disks has several options that allow users to define and attach disks to ## Provider Author Guide If you are a vagrant plugin author who maintains a provider for Vagrant, this short guide will hopefully give some information on how to use the internal disk config object. + +TODO: Fill out these main points + +- Entry level builtin action `disk` and how to use it as a provider author +- `id` is unique to each disk config object +- `provider_config` and how to its structured and how to use/validate it From 271cf8a60344b06f84c4a09c8566682e1304a7bf Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 14 Nov 2019 14:09:14 -0800 Subject: [PATCH 43/57] Begin to add Numeric class helper for converting size strings --- lib/vagrant/util/numeric.rb | 37 ++++++++++++++++++++++++++++++++ plugins/kernel_v2/config/disk.rb | 9 ++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 lib/vagrant/util/numeric.rb diff --git a/lib/vagrant/util/numeric.rb b/lib/vagrant/util/numeric.rb new file mode 100644 index 000000000..05d029218 --- /dev/null +++ b/lib/vagrant/util/numeric.rb @@ -0,0 +1,37 @@ +module Vagrant + module Util + class Numeric + # Authors Note: This class has borrowed some code from the ActiveSupport Numeric class + + # Conversion helper constants + KILOBYTE = 1024 + MEGABYTE = KILOBYTE * 1024 + GIGABYTE = MEGABYTE * 1024 + TERABYTE = GIGABYTE * 1024 + PETABYTE = TERABYTE * 1024 + EXABYTE = PETABYTE * 1024 + + class << self + + # A helper that converts a shortcut string to its bytes representation. + # The expected format of `str` is essentially: "XX" + # Where `XX` is shorthand for KB, MB, GB, TB, PB, or EB. For example, 50 megabytes: + # + # str = "50MB" + # + # @param [String] - str + # @return [Integer] - bytes + def string_to_bytes(str) + str = str.to_s.strip + end + + # @private + # Reset the cached values for platform. This is not considered a public + # API and should only be used for testing. + def reset! + instance_variables.each(&method(:remove_instance_variable)) + end + end + end + end +end diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index afdcfdc7c..85f67106d 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -1,6 +1,8 @@ require "log4r" require "securerandom" +require "vagrant/util/numeric" + module VagrantPlugins module Kernel_V2 class VagrantConfigDisk < Vagrant.plugin("2", :config) @@ -124,9 +126,12 @@ module VagrantPlugins errors << "Disk type '#{@type}' is not a valid type. Please pick one of the following supported disk types: #{DEFAULT_DISK_TYPES.join(', ')}" end - # TODO: Convert a string to int here? if @size && !@size.is_a?(Integer) - errors << "Config option size for disk is not an integer" + if @size.is_a?(String) + @size = Vagrant::Util::Numeric.string_to_bytes(@size) + else + errors << "Config option size for disk is not an integer" + end end if @file From 2e324a4971bc3c5fc2f57df8c662eb939208d522 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 15 Nov 2019 15:21:43 -0800 Subject: [PATCH 44/57] Add conversion method for shortcut size in disk config --- lib/vagrant/util/numeric.rb | 28 ++++++++++++++++++++++++++-- plugins/kernel_v2/config/disk.rb | 4 +--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/util/numeric.rb b/lib/vagrant/util/numeric.rb index 05d029218..3a2989d97 100644 --- a/lib/vagrant/util/numeric.rb +++ b/lib/vagrant/util/numeric.rb @@ -1,8 +1,10 @@ +require "log4r" + module Vagrant module Util class Numeric - # Authors Note: This class has borrowed some code from the ActiveSupport Numeric class + # Authors Note: This conversion has been borrowed from the ActiveSupport Numeric class # Conversion helper constants KILOBYTE = 1024 MEGABYTE = KILOBYTE * 1024 @@ -11,7 +13,14 @@ module Vagrant PETABYTE = TERABYTE * 1024 EXABYTE = PETABYTE * 1024 + BYTES_CONVERSION_MAP = {KB: KILOBYTE, MB: MEGABYTE, GB: GIGABYTE, TB: TERABYTE, + PB: PETABYTE, EB: EXABYTE} + + # Regex borrowed from the vagrant-disksize config class + SHORTHAND_MATCH_REGEX = /^(?[0-9]+)\s?(?KB|MB|GB|TB)?$/ + class << self + LOGGER = Log4r::Logger.new("vagrant::util::numeric") # A helper that converts a shortcut string to its bytes representation. # The expected format of `str` is essentially: "XX" @@ -20,9 +29,24 @@ module Vagrant # str = "50MB" # # @param [String] - str - # @return [Integer] - bytes + # @return [Integer,nil] - bytes - returns nil if method fails to convert to bytes def string_to_bytes(str) + bytes = nil + str = str.to_s.strip + matches = SHORTHAND_MATCH_REGEX.match(str) + if matches + number = matches[:number].to_i + unit = matches[:unit].to_sym + + if BYTES_CONVERSION_MAP.key?(unit) + bytes = number * BYTES_CONVERSION_MAP[unit] + else + LOGGER.error("An invalid unit or format was given, string_to_bytes cannot convert #{str}") + end + end + + bytes end # @private diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 85f67106d..82398daf4 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -31,9 +31,7 @@ module VagrantPlugins # Size of disk to create # - # TODO: Should we have shortcuts for GB??? - # - # @return [Integer] + # @return [Integer,String] attr_accessor :size # Path to the location of the disk file (Optional) From cd98a8bf64806b08ecd603cf48844255b407f7b4 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 15 Nov 2019 15:26:17 -0800 Subject: [PATCH 45/57] Include unit test for numeric class --- test/unit/vagrant/util/numeric_test.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/unit/vagrant/util/numeric_test.rb diff --git a/test/unit/vagrant/util/numeric_test.rb b/test/unit/vagrant/util/numeric_test.rb new file mode 100644 index 000000000..b13e4f9eb --- /dev/null +++ b/test/unit/vagrant/util/numeric_test.rb @@ -0,0 +1,21 @@ +require File.expand_path("../../../base", __FILE__) + +require "vagrant/util/numeric" + +describe Vagrant::Util::Numeric do + include_context "unit" + before(:each) { described_class.reset! } + subject { described_class } + + describe "#string_to_bytes" do + it "converts a string to the proper bytes" do + bytes = subject.string_to_bytes("10KB") + expect(bytes).to eq(10240) + end + + it "returns nil if the given string is the wrong format" do + bytes = subject.string_to_bytes("10 Kilobytes") + expect(bytes).to eq(nil) + end + end +end From 3a2b4ddef20b15fa5e151e5c5663277bef331a91 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 19 Nov 2019 13:14:12 -0800 Subject: [PATCH 46/57] Validate that disk file exists in disk config validate --- plugins/kernel_v2/config/disk.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 82398daf4..6bf9a1098 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -135,8 +135,8 @@ module VagrantPlugins if @file if !@file.is_a?(String) errors << "Config option `file` for #{machine.name} disk config is not a string" - else - # Validate that file exists + elsif !File.file?(@file) + errors << "Disk file '#{@file}' for disk '#{@name}' on machine '#{machine.name}' does not exist." end end From 57fd731fbf09aa0dd89e0b7526f22b18238a48b5 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 19 Nov 2019 13:33:04 -0800 Subject: [PATCH 47/57] Add warning if machines provider was not found in disk provider config opts --- plugins/kernel_v2/config/disk.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index 6bf9a1098..ec4a57f92 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -140,6 +140,12 @@ module VagrantPlugins end end + if @provider_config + if !@provider_config.keys.include?(machine.provider_name) + machine.env.ui.warn("Guest '#{machine.name}' using provider '#{machine.provider_name}' has provider specific config options for a provider other than '#{machine.provider_name}'. These provider config options will be ignored for this guest") + end + end + errors end From ea7a230cb63d259f6dd452ccf80c3afb4d4199d0 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 19 Nov 2019 13:48:29 -0800 Subject: [PATCH 48/57] Move disk config validation messages to locales file --- plugins/kernel_v2/config/disk.rb | 18 ++++++++++++------ templates/locales/en.yml | 11 +++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index ec4a57f92..fd33e7d12 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -121,28 +121,34 @@ module VagrantPlugins # validate type with list of known disk types if !DEFAULT_DISK_TYPES.include?(@type) - errors << "Disk type '#{@type}' is not a valid type. Please pick one of the following supported disk types: #{DEFAULT_DISK_TYPES.join(', ')}" + errors << I18n.t("vagrant.config.disk.invalid_type", type: @type, + types: DEFAULT_DISK_TYPES.join(', ')) end if @size && !@size.is_a?(Integer) if @size.is_a?(String) @size = Vagrant::Util::Numeric.string_to_bytes(@size) - else - errors << "Config option size for disk is not an integer" + end + + if !@size + errors << I18n.t("vagrant.config.disk.invalid_size", name: @name, machine: machine.name) end end if @file if !@file.is_a?(String) - errors << "Config option `file` for #{machine.name} disk config is not a string" + errors << I18n.t("vagrant.config.disk.invalid_file_type", file: @file, machine: machine.name) elsif !File.file?(@file) - errors << "Disk file '#{@file}' for disk '#{@name}' on machine '#{machine.name}' does not exist." + errors << I18n.t("vagrant.config.disk.missing_file", file_path: @file, + name: @name, machine: machine.name) end end if @provider_config if !@provider_config.keys.include?(machine.provider_name) - machine.env.ui.warn("Guest '#{machine.name}' using provider '#{machine.provider_name}' has provider specific config options for a provider other than '#{machine.provider_name}'. These provider config options will be ignored for this guest") + machine.env.ui.warn(I18n.t("vagrant.config.disk.missing_provider", + machine: machine.name, + provider_name: machine.provider_name)) end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 2e78e01a6..3fa21f19a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1792,6 +1792,17 @@ en: # Translations for config validation errors #------------------------------------------------------------------------------- config: + disk: + invalid_type: |- + Disk type '%{type}' is not a valid type. Please pick one of the following supported disk types: %{types} + invalid_size: |- + Config option 'size' for disk '%{name}' on guest '%{machine}' is not an integer + invalid_file_type: |- + Disk config option 'file' for '%{machine}' is not a string. + missing_file: |- + Disk file '%{file_path}' for disk '%{name}' on machine '%{machine}' does not exist. + missing_provider: |- + Guest '%{machine}' using provider '%{provider_name}' has provider specific config options for a provider other than '%{provider_name}'. These provider config options will be ignored for this guest common: bad_field: "The following settings shouldn't exist: %{fields}" chef: From b5b59a4eee4fdd9f7a6a5f91b31e97fd9c062a76 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 12:10:34 -0800 Subject: [PATCH 49/57] Base name for disk is vagrant_primary if primary --- plugins/kernel_v2/config/disk.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index fd33e7d12..c5407edae 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -109,7 +109,13 @@ module VagrantPlugins # Give the disk a default name if unset # TODO: Name not required if primary? - @name = "vagrant_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE + if @primary + base_name = "vagrant_primary" + else + base_name = "vagrant" + end + + @name = "#{base_name}_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE @provider_config = nil if @provider_config == {} end From 734aad1ede74cfcfb0588b2f94552ddd69309d01 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 12:32:51 -0800 Subject: [PATCH 50/57] Enforce unique names for disk config objects --- plugins/kernel_v2/config/vm.rb | 6 +++++- test/unit/plugins/kernel_v2/config/vm_test.rb | 21 +++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index e4fff571c..595cdff54 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -812,7 +812,11 @@ module VagrantPlugins name: machine.name) end - # TODO: Check for duplicate disk names? + disk_names = @disks.map { |d| d.name } + duplicate_names = disk_names.detect{ |d| disk_names.count(d) > 1 } + if duplicate_names && duplicate_names.size + errors << "Duplicate disk names found: #{duplicate_names}. Please use unique names" + end @disks.each do |d| error = d.validate(machine) diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 92f7d7e3c..43cb2fcfc 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -551,10 +551,12 @@ describe VagrantPlugins::Kernel_V2::VMConfig do describe "#disk" do it "stores the disks" do - subject.disk("disk", size: 100) - subject.disk("disk", size: 1000, primary: false, name: "storage") + subject.disk(:disk, size: 100) + subject.disk(:disk, size: 1000, primary: false, name: "storage") subject.finalize! + assert_valid + d = subject.disks expect(d.length).to eql(2) expect(d[0].size).to eql(100) @@ -562,9 +564,16 @@ describe VagrantPlugins::Kernel_V2::VMConfig do expect(d[1].name).to eql("storage") end + it "raises an error with duplicate names" do + subject.disk(:disk, size: 100, name: "foo") + subject.disk(:disk, size: 1000, name: "foo", primary: false) + subject.finalize! + assert_invalid + end + it "does not merge duplicate disks" do - subject.disk("disk", size: 1000, primary: false, name: "storage") - subject.disk("disk", size: 1000, primary: false, name: "backup") + subject.disk(:disk, size: 1000, primary: false, name: "storage") + subject.disk(:disk, size: 1000, primary: false, name: "backup") merged = subject.merge(subject) merged_disks = merged.disks @@ -573,10 +582,10 @@ describe VagrantPlugins::Kernel_V2::VMConfig do end it "ignores non-overriding runs" do - subject.disk("disk", name: "foo") + subject.disk(:disk, name: "foo") other = described_class.new - other.disk("disk", name: "bar", primary: false) + other.disk(:disk, name: "bar", primary: false) merged = subject.merge(other) merged_disks = merged.disks From 3e177d380f91f96a807aed253f27dd114a3879ed Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 13:05:43 -0800 Subject: [PATCH 51/57] Update disk docs in website for experimental feature banner --- .../source/docs/disks/configuration.html.md | 38 ++++++++++++++++++- website/source/docs/disks/index.html.md | 22 ++++++++++- website/source/docs/disks/usage.html.md | 18 ++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/website/source/docs/disks/configuration.html.md b/website/source/docs/disks/configuration.html.md index afbccaf35..f9c05cecc 100644 --- a/website/source/docs/disks/configuration.html.md +++ b/website/source/docs/disks/configuration.html.md @@ -8,6 +8,23 @@ description: |- # Configuration +
+ Warning! This feature is experimental and may break or + change in between releases. Use at your own risk. It currently is not officially + supported or functional. + + This feature currently reqiures the experimental flag to be used. To explicitly enable this feature, you can set the experimental flag to: + + ``` + VAGRANT_EXPERIMENTAL="disk_base_config" + ``` + + Please note that `VAGRANT_EXPERIMENTAL` is an environment variable. For more + information about this flag visit the [Experimental docs page](/docs/experimental/) + for more info. Without this flag enabled, triggers with the `:type` option + will be ignored. +
+ Vagrant Disks has several options that allow users to define and attach disks to guests. ## Disk Options @@ -29,12 +46,31 @@ Vagrant Disks has several options that allow users to define and attach disks to ## Disk Types +The disk config currently accepts three kinds of disk types: + +* `disk` (symbol) +* `dvd` (symbol) +* `floppy` (symbol) + +You can set a disk type with the first argument of a disk config in your Vagrantfile: + +```ruby +config.vm.disk :disk, name: "backup", size: "10GB" +config.vm.disk :floppy, name: "cool_files" +``` + ## Provider Author Guide If you are a vagrant plugin author who maintains a provider for Vagrant, this short guide will hopefully give some information on how to use the internal disk config object. -TODO: Fill out these main points +
+ Warning! This guide is still being written as we develop this + new feature for Vagrant. Some points below are what we plan on covering once this + feature is more fully developed in Vagrant. +
- Entry level builtin action `disk` and how to use it as a provider author - `id` is unique to each disk config object - `provider_config` and how to its structured and how to use/validate it + +More information should be coming once the disk feature is more functional. diff --git a/website/source/docs/disks/index.html.md b/website/source/docs/disks/index.html.md index 9cf53dfb5..6c4f6b3f5 100644 --- a/website/source/docs/disks/index.html.md +++ b/website/source/docs/disks/index.html.md @@ -8,9 +8,27 @@ description: |- # Vagrant Disks -As of version 2.3.0, Vagrant is capable managing what disks are available for a given guest. +
+ Warning! This feature is experimental and may break or + change in between releases. Use at your own risk. It currently is not officially + supported or functional. -TODO: GIVE A HIGH LEVEL OVERVIEW HERE + This feature currently reqiures the experimental flag to be used. To explicitly enable this feature, you can set the experimental flag to: + + ``` + VAGRANT_EXPERIMENTAL="disk_base_config" + ``` + + Please note that `VAGRANT_EXPERIMENTAL` is an environment variable. For more + information about this flag visit the [Experimental docs page](/docs/experimental/) + for more info. Without this flag enabled, triggers with the `:type` option + will be ignored. + + NOTE: Vagrant disks is currently a future feature for Vagrant that is not yet supported. + Some documentation exists here for future reference, however the Disk feature is + not yet functional. Please be patient for us to develop this new feature, and stay + tuned for a future release of Vagrant with this new functionality! +
For more information about what options are available for configuring disks, see the [configuration section](/docs/disks/configuration.html). diff --git a/website/source/docs/disks/usage.html.md b/website/source/docs/disks/usage.html.md index b09121c6a..a5e001cdb 100644 --- a/website/source/docs/disks/usage.html.md +++ b/website/source/docs/disks/usage.html.md @@ -8,6 +8,23 @@ description: |- # Basic Usage +
+ Warning! This feature is experimental and may break or + change in between releases. Use at your own risk. It currently is not officially + supported or functional. + + This feature currently reqiures the experimental flag to be used. To explicitly enable this feature, you can set the experimental flag to: + + ``` + VAGRANT_EXPERIMENTAL="disk_base_config" + ``` + + Please note that `VAGRANT_EXPERIMENTAL` is an environment variable. For more + information about this flag visit the [Experimental docs page](/docs/experimental/) + for more info. Without this flag enabled, triggers with the `:type` option + will be ignored. +
+ Below are some very simple examples of how to use Vagrant Disks. ## Examples @@ -15,4 +32,3 @@ Below are some very simple examples of how to use Vagrant Disks. - Resizing a disk (primary) - Attaching a new disk - Using provider specific options -- ??? From 86f924376280eab763dc91e939491a4dad86a8d3 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 13:50:29 -0800 Subject: [PATCH 52/57] Move validation message to locales --- plugins/kernel_v2/config/vm.rb | 3 ++- templates/locales/en.yml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 595cdff54..7baaca319 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -815,7 +815,8 @@ module VagrantPlugins disk_names = @disks.map { |d| d.name } duplicate_names = disk_names.detect{ |d| disk_names.count(d) > 1 } if duplicate_names && duplicate_names.size - errors << "Duplicate disk names found: #{duplicate_names}. Please use unique names" + errors << I18n.t("vagrant.config.vm.multiple_disk_names_error", + name: duplicate_names) end @disks.each do |d| diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 3fa21f19a..439c22581 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1905,6 +1905,8 @@ en: Ignoring provider config for validation... multiple_primary_disks_error: |- There are more than one primary disks defined for guest '%{name}'. Please ensure that only one disk has been defined as a primary disk. + multiple_disk_names_error: |- + Duplicate disk names defined: '%{name}'. Disk names must be unique. name_invalid: |- The sub-VM name '%{name}' is invalid. Please don't use special characters. network_ip_ends_in_one: |- From f55aca091c3d4061932caef29553affe21c6d7a5 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 13:50:41 -0800 Subject: [PATCH 53/57] Wrap disk feature in experimental flag --- plugins/kernel_v2/config/vm.rb | 5 +++++ test/unit/plugins/kernel_v2/config/vm_test.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 7baaca319..7c0e4e423 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -433,6 +433,11 @@ module VagrantPlugins # Add provider config disk_config.add_provider_config(provider_options, &block) + if !Vagrant::Util::Experimental.feature_enabled?("disk_base_config") + @logger.warn("Disk config defined, but experimental feature is not enabled. To use this feature, enable it with the experimental flag `disk_base_config`. Disk will not be added to internal config, and will be ignored.") + return + end + @disks << disk_config end diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 43cb2fcfc..20775ce75 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -550,6 +550,11 @@ describe VagrantPlugins::Kernel_V2::VMConfig do end describe "#disk" do + before(:each) do + allow(Vagrant::Util::Experimental).to receive(:feature_enabled?). + with("disk_base_config").and_return("true") + end + it "stores the disks" do subject.disk(:disk, size: 100) subject.disk(:disk, size: 1000, primary: false, name: "storage") From 8ad810b5b6f6f9e5c9aeac6e34c99f052a290a36 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 14:13:50 -0800 Subject: [PATCH 54/57] Check and call into provider capability `:configure_disks` --- lib/vagrant/action/builtin/disk.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index 6767b01bb..00df51a19 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -12,8 +12,11 @@ module Vagrant defined_disks = get_disks(machine, env) # Call into providers machine implementation for disk management - # - # machine.provider.configure_disks(defined_disks) + if machine.provider.capability?(:configure_disks) + machine.provider.capability(:configure_disks, defined_disks) + else + @logger.warn(":configure_disks capability not defined for provider, cannot configure disks") + end # Continue On @app.call(env) From b56dede6274b57c6440ff7872d27e6ca019811e7 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 14:14:14 -0800 Subject: [PATCH 55/57] Do not set primary option if it's not UNSET or false --- plugins/kernel_v2/config/disk.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index c5407edae..d4ba309cd 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -103,8 +103,6 @@ module VagrantPlugins if @primary == UNSET_VALUE @primary = false - else - @primary = true end # Give the disk a default name if unset From f8449063b62bd83af7bae56d697e47bd7bf0d173 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 14:14:38 -0800 Subject: [PATCH 56/57] Have default names for primary and non-primary disks --- plugins/kernel_v2/config/disk.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/kernel_v2/config/disk.rb b/plugins/kernel_v2/config/disk.rb index d4ba309cd..219a74aed 100644 --- a/plugins/kernel_v2/config/disk.rb +++ b/plugins/kernel_v2/config/disk.rb @@ -105,16 +105,14 @@ module VagrantPlugins @primary = false end - # Give the disk a default name if unset - # TODO: Name not required if primary? - if @primary - base_name = "vagrant_primary" - else - base_name = "vagrant" + if @name == UNSET_VALUE + if @primary + @name = "vagrant_primary" + else + @name = "name_#{@type.to_s}_#{@id.split("-").last}" + end end - @name = "#{base_name}_#{@type.to_s}_#{@id.split("-").last}" if @name == UNSET_VALUE - @provider_config = nil if @provider_config == {} end From f979d40436e3e7a1241da7cab55eb38048718122 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 22 Nov 2019 14:38:42 -0800 Subject: [PATCH 57/57] Add warning if machines provider does not support disk configuration --- lib/vagrant/action/builtin/disk.rb | 3 ++- templates/locales/en.yml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/builtin/disk.rb b/lib/vagrant/action/builtin/disk.rb index 00df51a19..a1abe7289 100644 --- a/lib/vagrant/action/builtin/disk.rb +++ b/lib/vagrant/action/builtin/disk.rb @@ -15,7 +15,8 @@ module Vagrant if machine.provider.capability?(:configure_disks) machine.provider.capability(:configure_disks, defined_disks) else - @logger.warn(":configure_disks capability not defined for provider, cannot configure disks") + env[:ui].warn(I18n.t("vagrant.actions.disk.provider_unsupported", + provider: machine.provider_name)) end # Continue On diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 439c22581..333addb8a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -2153,6 +2153,9 @@ en: runner: waiting_cleanup: "Waiting for cleanup before exiting..." exit_immediately: "Exiting immediately, without cleanup!" + disk: + provider_unsupported: |- + Guest provider '%{provider}' does not support the disk feature, and will not use the disk configuration defined. vm: boot: booting: Booting VM...