lib/kitchen/driver/vagrant.rb in kitchen-vagrant-1.2.1 vs lib/kitchen/driver/vagrant.rb in kitchen-vagrant-1.3.0
- old
+ new
@@ -20,10 +20,11 @@
require "fileutils"
require "rubygems/version"
require "kitchen"
require "kitchen/driver/vagrant_version"
+require "kitchen/driver/helpers"
module Kitchen
module Driver
@@ -31,10 +32,11 @@
#
# @author Fletcher Nichol <fnichol@nichol.ca>
class Vagrant < Kitchen::Driver::Base
include ShellOut
+ include Kitchen::Driver::HypervHelpers
kitchen_driver_api_version 2
plugin_version Kitchen::Driver::VAGRANT_VERSION
@@ -167,10 +169,11 @@
super
finalize_vm_hostname!
finalize_pre_create_command!
finalize_synced_folders!
finalize_ca_cert!
+ finalize_network!
self
end
# Performs whatever tests that may be required to ensure that this driver
# will be able to function in the current environment. This may involve
@@ -206,11 +209,11 @@
end
end
protected
- WEBSITE = "http://www.vagrantup.com/downloads.html".freeze
+ WEBSITE = "https://www.vagrantup.com/downloads.html".freeze
MIN_VER = "1.1.0".freeze
class << self
# @return [true,false] whether or not the vagrant-winrm plugin is
@@ -238,10 +241,11 @@
# by matching against a whitelist of bento boxes
# @return [TrueClass,FalseClass] whether or not the box shoud work with
# shared folders
# @api private
def safe_share?(box)
+ return false if config[:provider] =~ /(hyperv|libvirt)/
box =~ /^bento\/(centos|debian|fedora|opensuse|ubuntu|oracle)-/
end
# Return true if we found the criteria to enable the cache_directory
# functionality
@@ -337,9 +341,22 @@
def finalize_vm_hostname!
string = config[:vm_hostname]
if windows_os? && string.is_a?(String) && string.size >= 12
config[:vm_hostname] = "#{string[0...10]}-#{string[-1]}"
+ end
+ end
+
+ # If Hyper-V and no network configuration
+ # check KITCHEN_HYPERV_SWITCH and fallback to helper method
+ # to select the best switch
+ # @api private
+ def finalize_network!
+ if config[:provider] == "hyperv" && config[:network].empty?
+ config[:network].push([
+ "public_network",
+ "bridge: #{hyperv_switch}",
+ ])
end
end
# Loads any required third party Ruby libraries or runs any shell out
# commands to prepare the plugin. This method will be called in the