vagrant-unbundled 2.2.9.0 → 2.2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -0
  3. data/README.md +5 -5
  4. data/contrib/README.md +1 -0
  5. data/contrib/sudoers/linux-suse +2 -2
  6. data/contrib/zsh/_vagrant +736 -0
  7. data/contrib/zsh/generate_zsh_completion.rb +166 -0
  8. data/lib/vagrant/action.rb +3 -0
  9. data/lib/vagrant/action/builder.rb +52 -18
  10. data/lib/vagrant/action/builtin/box_add.rb +6 -5
  11. data/lib/vagrant/action/builtin/cloud_init_setup.rb +127 -0
  12. data/lib/vagrant/action/builtin/cloud_init_wait.rb +30 -0
  13. data/lib/vagrant/action/builtin/handle_box.rb +1 -1
  14. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +13 -13
  15. data/lib/vagrant/action/builtin/has_provisioner.rb +36 -0
  16. data/lib/vagrant/action/builtin/mixin_provisioners.rb +1 -0
  17. data/lib/vagrant/action/builtin/mixin_synced_folders.rb +20 -21
  18. data/lib/vagrant/action/builtin/set_hostname.rb +5 -1
  19. data/lib/vagrant/action/builtin/synced_folders.rb +10 -0
  20. data/lib/vagrant/action/builtin/trigger.rb +3 -2
  21. data/lib/vagrant/action/hook.rb +59 -24
  22. data/lib/vagrant/action/warden.rb +25 -5
  23. data/lib/vagrant/box.rb +5 -4
  24. data/lib/vagrant/bundler.rb +6 -1
  25. data/lib/vagrant/errors.rb +37 -1
  26. data/lib/vagrant/machine.rb +47 -0
  27. data/lib/vagrant/machine_index.rb +27 -1
  28. data/lib/vagrant/plugin/v2/command.rb +5 -1
  29. data/lib/vagrant/plugin/v2/components.rb +6 -0
  30. data/lib/vagrant/plugin/v2/manager.rb +14 -0
  31. data/lib/vagrant/plugin/v2/plugin.rb +12 -0
  32. data/lib/vagrant/plugin/v2/synced_folder.rb +50 -0
  33. data/lib/vagrant/plugin/v2/trigger.rb +6 -5
  34. data/lib/vagrant/ui.rb +1 -1
  35. data/lib/vagrant/util/ansi_escape_code_remover.rb +1 -1
  36. data/lib/vagrant/util/caps.rb +48 -0
  37. data/lib/vagrant/util/credential_scrubber.rb +1 -1
  38. data/lib/vagrant/util/directory.rb +19 -0
  39. data/lib/vagrant/util/downloader.rb +3 -3
  40. data/lib/vagrant/util/guest_hosts.rb +68 -0
  41. data/lib/vagrant/util/install_cli_autocomplete.rb +118 -0
  42. data/lib/vagrant/util/ipv4_interfaces.rb +15 -0
  43. data/lib/vagrant/util/is_port_open.rb +8 -19
  44. data/lib/vagrant/util/network_ip.rb +11 -1
  45. data/lib/vagrant/util/powershell.rb +1 -1
  46. data/lib/vagrant/util/subprocess.rb +9 -1
  47. data/lib/vagrant/vagrantfile.rb +1 -1
  48. data/plugins/commands/autocomplete/command/install.rb +49 -0
  49. data/plugins/commands/autocomplete/command/root.rb +64 -0
  50. data/plugins/commands/autocomplete/plugin.rb +18 -0
  51. data/plugins/commands/destroy/command.rb +6 -2
  52. data/plugins/communicators/ssh/communicator.rb +7 -1
  53. data/plugins/communicators/winrm/helper.rb +1 -1
  54. data/plugins/communicators/winssh/communicator.rb +1 -1
  55. data/plugins/guests/alpine/cap/change_host_name.rb +10 -11
  56. data/plugins/guests/alt/cap/change_host_name.rb +40 -53
  57. data/plugins/guests/arch/cap/change_host_name.rb +5 -14
  58. data/plugins/guests/arch/cap/configure_networks.rb +27 -10
  59. data/plugins/guests/atomic/cap/change_host_name.rb +5 -14
  60. data/plugins/guests/darwin/cap/change_host_name.rb +10 -6
  61. data/plugins/guests/debian/cap/change_host_name.rb +11 -11
  62. data/plugins/guests/esxi/cap/public_key.rb +3 -1
  63. data/plugins/guests/freebsd/cap/change_host_name.rb +10 -6
  64. data/plugins/guests/gentoo/cap/change_host_name.rb +14 -22
  65. data/plugins/guests/haiku/cap/rsync.rb +19 -0
  66. data/plugins/guests/haiku/plugin.rb +15 -0
  67. data/plugins/guests/linux/cap/change_host_name.rb +46 -0
  68. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +4 -11
  69. data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +62 -0
  70. data/plugins/guests/linux/plugin.rb +10 -0
  71. data/plugins/guests/omnios/cap/change_host_name.rb +10 -16
  72. data/plugins/guests/openbsd/cap/change_host_name.rb +10 -6
  73. data/plugins/guests/photon/cap/change_host_name.rb +9 -15
  74. data/plugins/guests/pld/cap/change_host_name.rb +11 -17
  75. data/plugins/guests/redhat/cap/change_host_name.rb +10 -5
  76. data/plugins/guests/slackware/cap/change_host_name.rb +11 -17
  77. data/plugins/guests/solaris11/plugin.rb +5 -0
  78. data/plugins/guests/suse/cap/change_host_name.rb +12 -11
  79. data/plugins/hosts/darwin/cap/fs_iso.rb +49 -0
  80. data/plugins/hosts/darwin/plugin.rb +10 -0
  81. data/plugins/hosts/linux/cap/fs_iso.rb +49 -0
  82. data/plugins/hosts/linux/cap/rdp.rb +1 -1
  83. data/plugins/hosts/linux/plugin.rb +10 -0
  84. data/plugins/hosts/windows/cap/fs_iso.rb +48 -0
  85. data/plugins/hosts/windows/cap/rdp.rb +1 -1
  86. data/plugins/hosts/windows/plugin.rb +15 -0
  87. data/plugins/kernel_v2/config/cloud_init.rb +126 -0
  88. data/plugins/kernel_v2/config/disk.rb +40 -18
  89. data/plugins/kernel_v2/config/vm.rb +122 -13
  90. data/plugins/kernel_v2/config/vm_provisioner.rb +13 -2
  91. data/plugins/kernel_v2/config/vm_trigger.rb +5 -1
  92. data/plugins/providers/docker/action.rb +8 -17
  93. data/plugins/providers/docker/action/forwarded_ports.rb +2 -0
  94. data/plugins/providers/docker/action/prepare_forwarded_port_collision_params.rb +61 -0
  95. data/plugins/providers/docker/cap/has_communicator.rb +11 -0
  96. data/plugins/providers/docker/communicator.rb +1 -1
  97. data/plugins/providers/docker/driver.rb +35 -0
  98. data/plugins/providers/docker/plugin.rb +5 -0
  99. data/plugins/providers/hyperv/action.rb +2 -0
  100. data/plugins/providers/hyperv/action/configure.rb +8 -0
  101. data/plugins/providers/hyperv/cap/cleanup_disks.rb +54 -0
  102. data/plugins/providers/hyperv/cap/configure_disks.rb +200 -0
  103. data/plugins/providers/hyperv/cap/validate_disk_ext.rb +34 -0
  104. data/plugins/providers/hyperv/config.rb +5 -0
  105. data/plugins/providers/hyperv/driver.rb +80 -0
  106. data/plugins/providers/hyperv/plugin.rb +25 -0
  107. data/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 +28 -0
  108. data/plugins/providers/hyperv/scripts/dismount_vhd.ps1 +13 -0
  109. data/plugins/providers/hyperv/scripts/get_vhd.ps1 +16 -0
  110. data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +1 -1
  111. data/plugins/providers/hyperv/scripts/list_hdds.ps1 +17 -0
  112. data/plugins/providers/hyperv/scripts/new_vhd.ps1 +31 -0
  113. data/plugins/providers/hyperv/scripts/remove_disk_drive.ps1 +25 -0
  114. data/plugins/providers/hyperv/scripts/resize_disk_drive.ps1 +18 -0
  115. data/plugins/providers/hyperv/scripts/set_enhanced_session_transport_type.ps1 +24 -0
  116. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +8 -0
  117. data/plugins/providers/virtualbox/action.rb +12 -1
  118. data/plugins/providers/virtualbox/action/forward_ports.rb +2 -2
  119. data/plugins/providers/virtualbox/cap/cleanup_disks.rb +40 -9
  120. data/plugins/providers/virtualbox/cap/configure_disks.rb +230 -77
  121. data/plugins/providers/virtualbox/cap/mount_options.rb +35 -0
  122. data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +10 -3
  123. data/plugins/providers/virtualbox/driver/meta.rb +3 -0
  124. data/plugins/providers/virtualbox/driver/version_5_0.rb +96 -21
  125. data/plugins/providers/virtualbox/model/storage_controller.rb +135 -0
  126. data/plugins/providers/virtualbox/model/storage_controller_array.rb +100 -0
  127. data/plugins/providers/virtualbox/plugin.rb +18 -1
  128. data/plugins/providers/virtualbox/synced_folder.rb +1 -0
  129. data/plugins/provisioners/container/client.rb +1 -1
  130. data/plugins/provisioners/shell/provisioner.rb +15 -9
  131. data/plugins/synced_folders/nfs/synced_folder.rb +3 -1
  132. data/plugins/synced_folders/smb/cap/default_fstab_modification.rb +11 -0
  133. data/plugins/synced_folders/smb/cap/mount_options.rb +36 -0
  134. data/plugins/synced_folders/smb/plugin.rb +10 -0
  135. data/plugins/synced_folders/smb/synced_folder.rb +1 -1
  136. data/plugins/synced_folders/unix_mount_helpers.rb +14 -0
  137. data/templates/guests/arch/{network_dhcp.erb → default_network/network_dhcp.erb} +0 -0
  138. data/templates/guests/arch/{network_static.erb → default_network/network_static.erb} +0 -0
  139. data/templates/guests/arch/{network_static6.erb → default_network/network_static6.erb} +0 -0
  140. data/templates/guests/arch/systemd_networkd/network_dhcp.erb +6 -0
  141. data/templates/guests/arch/systemd_networkd/network_static.erb +9 -0
  142. data/templates/guests/arch/systemd_networkd/network_static6.erb +9 -0
  143. data/templates/guests/linux/etc_fstab.erb +6 -0
  144. data/templates/locales/en.yml +121 -11
  145. data/templates/locales/providers_docker.yml +4 -0
  146. data/vagrant.gemspec +8 -7
  147. data/version.txt +1 -1
  148. metadata +1492 -1309
@@ -227,7 +227,7 @@ module Vagrant
227
227
 
228
228
  # This method handles actually outputting a message of a given type
229
229
  # to the console.
230
- def say(type, message, **opts)
230
+ def say(type, message, opts={})
231
231
  defaults = { new_line: true, prefix: true }
232
232
  opts = defaults.merge(@opts).merge(opts)
233
233
 
@@ -19,7 +19,7 @@ module Vagrant
19
19
  /\e\[\?[1-9][hl]/, # Matches \e[?2h
20
20
  /\e\[20[hl]/, # Matches \e[20l]
21
21
  /\e[DME78H]/, # Matches \eD, \eH, etc.
22
- /\e\[[0-2]?[JK]/, # Matches \e[0J, \e[K, etc.
22
+ /\e\[[0-3]?[JK]/, # Matches \e[0J, \e[K, etc.
23
23
  ]
24
24
 
25
25
  # Take each matcher and replace it with emptiness.
@@ -0,0 +1,48 @@
1
+ require "tempfile"
2
+ require "fileutils"
3
+ require "pathname"
4
+ require "vagrant/util/directory"
5
+ require "vagrant/util/subprocess"
6
+
7
+ module Vagrant
8
+ module Util
9
+ module Caps
10
+ module BuildISO
11
+
12
+ # Builds an iso given a compatible iso_command
13
+ #
14
+ # @param [List<String>] command to build iso
15
+ # @param [Pathname] input directory for iso build
16
+ # @param [Pathname] output file for iso build
17
+ def build_iso(iso_command, source_directory, file_destination)
18
+ FileUtils.mkdir_p(file_destination.dirname)
19
+ if !file_destination.exist? || Vagrant::Util::Directory.directory_changed?(source_directory, file_destination.mtime)
20
+ result = Vagrant::Util::Subprocess.execute(*iso_command)
21
+ if result.exit_code != 0
22
+ raise Vagrant::Errors::ISOBuildFailed, cmd: iso_command.join(" "), stdout: result.stdout, stderr: result.stderr
23
+ end
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def ensure_output_iso(file_destination)
30
+ if file_destination.nil?
31
+ tmpfile = Tempfile.new(["vagrant", ".iso"])
32
+ file_destination = Pathname.new(tmpfile.path)
33
+ tmpfile.close
34
+ tmpfile.unlink
35
+ else
36
+ file_destination = Pathname.new(file_destination.to_s)
37
+ # If the file destination path is a folder, target the output to a randomly named
38
+ # file in that dir
39
+ if file_destination.extname != ".iso"
40
+ file_destination = file_destination.join("#{SecureRandom.hex(3)}_vagrant.iso")
41
+ end
42
+ end
43
+ file_destination
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -32,7 +32,7 @@ module Vagrant
32
32
  def self.desensitize(string)
33
33
  string = string.to_s.dup
34
34
  sensitive_strings.each do |remove|
35
- string.gsub!(remove, REPLACEMENT_TEXT)
35
+ string.gsub!(/(\W|^)#{Regexp.escape(remove)}(\W|$)/, "\\1#{REPLACEMENT_TEXT}\\2")
36
36
  end
37
37
  string
38
38
  end
@@ -0,0 +1,19 @@
1
+ require 'pathname'
2
+
3
+ module Vagrant
4
+ module Util
5
+ class Directory
6
+ # Check if directory has any new updates
7
+ #
8
+ # @param [Pathname, String] Path to directory
9
+ # @param [Time] time to compare to eg. has any file in dir_path
10
+ # changed since this time
11
+ # @return [Boolean]
12
+ def self.directory_changed?(dir_path, threshold_time)
13
+ Dir.glob(Pathname.new(dir_path).join("**", "*")).any? do |path|
14
+ Pathname.new(path).mtime > threshold_time
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,4 @@
1
+ require "cgi"
1
2
  require "uri"
2
3
 
3
4
  require "log4r"
@@ -9,7 +10,6 @@ require "vagrant/util/platform"
9
10
  require "vagrant/util/subprocess"
10
11
  require "vagrant/util/curl_helper"
11
12
  require "vagrant/util/file_checksum"
12
- require "vagrant/util/map_command_options"
13
13
 
14
14
  module Vagrant
15
15
  module Util
@@ -42,8 +42,8 @@ module Vagrant
42
42
  begin
43
43
  url = URI.parse(@source)
44
44
  if url.scheme && url.scheme.start_with?("http") && url.user
45
- auth = "#{URI.unescape(url.user)}"
46
- auth += ":#{URI.unescape(url.password)}" if url.password
45
+ auth = "#{CGI.unescape(url.user)}"
46
+ auth += ":#{CGI.unescape(url.password)}" if url.password
47
47
  url.user = nil
48
48
  url.password = nil
49
49
  options[:auth] ||= auth
@@ -0,0 +1,68 @@
1
+ module Vagrant
2
+ module Util
3
+ # Helper methods for modfiying guests /etc/hosts file
4
+ module GuestHosts
5
+
6
+ module Unix
7
+ DEAFAULT_LOOPBACK_CHECK_LIMIT = 5.freeze
8
+
9
+ # Add hostname to a loopback address on /etc/hosts if not already there
10
+ # Will insert name at the first free address of the form 127.0.X.1, up to
11
+ # the loop_bound
12
+ #
13
+ # @param [Communicator]
14
+ # @param [String] full hostanme
15
+ # @param [int] (option) defines the upper bound for searching for an available loopback address
16
+ def add_hostname_to_loopback_interface(comm, name, loop_bound=DEAFAULT_LOOPBACK_CHECK_LIMIT)
17
+ basename = name.split(".", 2)[0]
18
+ comm.sudo <<-EOH.gsub(/^ {14}/, '')
19
+ grep -w '#{name}' /etc/hosts || {
20
+ for i in {1..#{loop_bound}}; do
21
+ grep -w "127.0.${i}.1" /etc/hosts || {
22
+ echo "127.0.${i}.1 #{name} #{basename}" >> /etc/hosts
23
+ break
24
+ }
25
+ done
26
+ }
27
+ EOH
28
+ end
29
+ end
30
+
31
+ # Linux specific inspection helpers
32
+ module Linux
33
+ include Unix
34
+ # Remove any line in /etc/hosts that contains hostname,
35
+ # then add hostname with associated ip
36
+ #
37
+ # @param [Communicator]
38
+ # @param [String] full hostanme
39
+ # @param [String] target ip
40
+ def replace_host(comm, name, ip)
41
+ basename = name.split(".", 2)[0]
42
+ comm.sudo <<-EOH.gsub(/^ {14}/, '')
43
+ sed -i '/#{name}/d' /etc/hosts
44
+ sed -i'' '1i '#{ip}'\\t#{name}\\t#{basename}' /etc/hosts
45
+ EOH
46
+ end
47
+ end
48
+
49
+ # BSD specific inspection helpers
50
+ module BSD
51
+ include Unix
52
+ # Remove any line in /etc/hosts that contains hostname,
53
+ # then add hostname with associated ip
54
+ #
55
+ # @param [Communicator]
56
+ # @param [String] full hostanme
57
+ # @param [String] target ip
58
+ def replace_host(comm, name, ip)
59
+ basename = name.split(".", 2)[0]
60
+ comm.sudo <<-EOH.gsub(/^ {14}/, '')
61
+ sed -i.bak '/#{name}/d' /etc/hosts
62
+ sed -i.bak '1i\\\n#{ip}\t#{name}\t#{basename}\n' /etc/hosts
63
+ EOH
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,118 @@
1
+ module Vagrant
2
+ module Util
3
+ # Generic installation of content to shell config file
4
+ class InstallShellConfig
5
+
6
+ PERPEND_STRING = "# >>>> Vagrant command completion (start)".freeze
7
+ APPEND_STRING = "# <<<< Vagrant command completion (end)".freeze
8
+
9
+ attr_accessor :prepend_string
10
+ attr_accessor :string_insert
11
+ attr_accessor :append_string
12
+ attr_accessor :config_paths
13
+
14
+ def initialize(string_insert, config_paths)
15
+ @prepend_string = PERPEND_STRING
16
+ @string_insert = string_insert
17
+ @append_string = APPEND_STRING
18
+ @config_paths = config_paths
19
+ @logger = Log4r::Logger.new("vagrant::util::install_shell_config")
20
+ end
21
+
22
+ # Searches a users home dir for a shell config file based on a
23
+ # given home dir and a configured set of config paths. If there
24
+ # are multiple config paths, it will return the first match.
25
+ #
26
+ # @param [string] path to users home dir
27
+ # @return [string] path to shell config file if exists
28
+ def shell_installed(home)
29
+ @logger.info("Searching for config in home #{home}")
30
+ @config_paths.each do |path|
31
+ config_file = File.join(home, path)
32
+ if File.exists?(config_file)
33
+ @logger.info("Found config file #{config_file}")
34
+ return config_file
35
+ end
36
+ end
37
+ return nil
38
+ end
39
+
40
+ # Searches a given file for the existence of a set prepend string.
41
+ # This can be used to find if vagrant has inserted some strings to a file
42
+ #
43
+ # @param [string] path to a file (config file)
44
+ # @return [boolean] true if the prepend string is found in the file
45
+ def is_installed(path)
46
+ File.foreach(path) do |line|
47
+ if line.include?(@prepend_string)
48
+ @logger.info("Found completion already installed in #{path}")
49
+ return true
50
+ end
51
+ end
52
+ return false
53
+ end
54
+
55
+ # Given a path to the users home dir, will install some given strings
56
+ # marked by a prepend and append string
57
+ #
58
+ # @param [string] path to users home dir
59
+ # @return [string] path to shell config file that was modified if exists
60
+ def install(home)
61
+ path = shell_installed(home)
62
+ if path && !is_installed(path)
63
+ File.open(path, "a") do |f|
64
+ f.write("\n")
65
+ f.write(@prepend_string)
66
+ f.write("\n")
67
+ f.write(@string_insert)
68
+ f.write("\n")
69
+ f.write(@append_string)
70
+ f.write("\n")
71
+ end
72
+ end
73
+ return path
74
+ end
75
+ end
76
+
77
+ # Install autocomplete script to zsh config located as .zshrc
78
+ class InstallZSHShellConfig < InstallShellConfig
79
+ def initialize
80
+ string_insert = """fpath=(#{File.join(Vagrant.source_root, "contrib", "zsh")} $fpath)\ncompinit""".freeze
81
+ config_paths = [".zshrc".freeze].freeze
82
+ super(string_insert, config_paths)
83
+ end
84
+ end
85
+
86
+ # Install autocomplete script to bash config located as .bashrc or .bash_profile
87
+ class InstallBashShellConfig < InstallShellConfig
88
+ def initialize
89
+ string_insert = ". #{File.join(Vagrant.source_root, 'contrib', 'bash', 'completion.sh')}".freeze
90
+ config_paths = [".bashrc".freeze, ".bash_profile".freeze].freeze
91
+ super(string_insert, config_paths)
92
+ end
93
+ end
94
+
95
+ # Install autocomplete script for supported shells
96
+ class InstallCLIAutocomplete
97
+ SUPPORTED_SHELLS = {
98
+ "zsh" => Vagrant::Util::InstallZSHShellConfig.new(),
99
+ "bash" => Vagrant::Util::InstallBashShellConfig.new()
100
+ }
101
+
102
+ def self.install(shells=[])
103
+ shells = SUPPORTED_SHELLS.keys() if shells.empty?
104
+ home = Dir.home
105
+ written_paths = []
106
+
107
+ shells.map do |shell|
108
+ if SUPPORTED_SHELLS[shell]
109
+ written_paths.push(SUPPORTED_SHELLS[shell].install(home))
110
+ else
111
+ raise ArgumentError, "shell must be in #{SUPPORTED_SHELLS.keys()}"
112
+ end
113
+ end.compact
114
+ return written_paths
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,15 @@
1
+ module Vagrant
2
+ module Util
3
+ module IPv4Interfaces
4
+ def ipv4_interfaces
5
+ Socket.getifaddrs.select do |ifaddr|
6
+ ifaddr.addr && ifaddr.addr.ipv4?
7
+ end.map do |ifaddr|
8
+ [ifaddr.name, ifaddr.addr.ip_address]
9
+ end
10
+ end
11
+
12
+ extend IPv4Interfaces
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,4 @@
1
1
  require "socket"
2
- require "timeout"
3
2
 
4
3
  module Vagrant
5
4
  module Util
@@ -14,26 +13,16 @@ module Vagrant
14
13
  # @return [Boolean] `true` if the port is open (listening), `false`
15
14
  # otherwise.
16
15
  def is_port_open?(host, port)
17
- # We wrap this in a timeout because once in awhile the TCPSocket
18
- # _will_ hang, but this signals that the port is closed.
19
- Timeout.timeout(1) do
20
- # Attempt to make a connection
21
- s = TCPSocket.new(host, port)
22
-
23
- # A connection was made! Properly clean up the socket, not caring
24
- # at all if any exception is raised, because we already know the
25
- # result.
26
- s.close rescue nil
27
-
28
- # The port is open if we reached this point, since we were able
29
- # to connect.
30
- return true
16
+ begin
17
+ Socket.tcp(host, port, connect_timeout: 0.1).close
18
+ true
19
+ rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \
20
+ Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
21
+ false
31
22
  end
32
- rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \
33
- Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
34
- # Any of the above exceptions signal that the port is closed.
35
- return false
36
23
  end
24
+
25
+ extend IsPortOpen
37
26
  end
38
27
  end
39
28
  end
@@ -3,11 +3,21 @@ require "ipaddr"
3
3
  module Vagrant
4
4
  module Util
5
5
  module NetworkIP
6
+
7
+ DEFAULT_MASK = "255.255.255.0".freeze
8
+
9
+ LOGGER = Log4r::Logger.new("vagrant::util::NetworkIP")
10
+
6
11
  # Returns the network address of the given IP and subnet.
7
12
  #
8
13
  # @return [String]
9
14
  def network_address(ip, subnet)
10
- IPAddr.new(ip).mask(subnet).to_s
15
+ begin
16
+ IPAddr.new(ip).mask(subnet).to_s
17
+ rescue IPAddr::InvalidPrefixError
18
+ LOGGER.warn("Provided mask '#{subnet}' is invalid. Falling back to using mask '#{DEFAULT_MASK}'")
19
+ IPAddr.new(ip).mask(DEFAULT_MASK).to_s
20
+ end
11
21
  end
12
22
  end
13
23
  end
@@ -231,7 +231,7 @@ module Vagrant
231
231
  "-PassThru -WindowStyle Hidden -Wait -Verb RunAs; if($p){ exit $p.ExitCode; }else{ exit 1 }"
232
232
 
233
233
  cmd = [
234
- "powershell",
234
+ executable,
235
235
  "-NoLogo",
236
236
  "-NoProfile",
237
237
  "-NonInteractive",
@@ -90,6 +90,8 @@ module Vagrant
90
90
  process.io.stdout = stdout_writer
91
91
  process.io.stderr = stderr_writer
92
92
  process.duplex = true
93
+ process.leader = true if @options[:detach]
94
+ process.detach = true if @options[:detach]
93
95
 
94
96
  # Special installer-related things
95
97
  if Vagrant.in_installer?
@@ -158,6 +160,12 @@ module Vagrant
158
160
  raise LaunchError.new(ex.message)
159
161
  end
160
162
 
163
+ # If running with the detach option, no need to capture IO or
164
+ # ensure program exists.
165
+ if @options[:detach]
166
+ return
167
+ end
168
+
161
169
  # Make sure the stdin does not buffer
162
170
  process.io.stdin.sync = true
163
171
 
@@ -261,7 +269,7 @@ module Vagrant
261
269
  # Return an exit status container
262
270
  return Result.new(process.exit_code, io_data[:stdout], io_data[:stderr])
263
271
  ensure
264
- if process && process.alive?
272
+ if process && process.alive? && !@options[:detach]
265
273
  # Make sure no matter what happens, the process exits
266
274
  process.stop(2)
267
275
  end
@@ -197,7 +197,7 @@ module Vagrant
197
197
  local_keys = keys.dup
198
198
 
199
199
  # Load the box Vagrantfile, if there is one
200
- if config.vm.box && boxes
200
+ if !config.vm.box.to_s.empty? && boxes
201
201
  box = boxes.find(config.vm.box, box_formats, config.vm.box_version)
202
202
  if box
203
203
  box_vagrantfile = find_vagrantfile(box.directory)
@@ -0,0 +1,49 @@
1
+ require 'optparse'
2
+
3
+ require 'vagrant/util/install_cli_autocomplete'
4
+
5
+ module VagrantPlugins
6
+ module CommandAutocomplete
7
+ module Command
8
+ class Install < Vagrant.plugin("2", :command)
9
+ def execute
10
+ options = {
11
+ shells: []
12
+ }
13
+
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant autocomplete install [-h] [shell name]"
16
+ o.separator ""
17
+ o.separator "Available shells: #{Vagrant::Util::InstallCLIAutocomplete::SUPPORTED_SHELLS.keys.join(' ')}"
18
+ o.separator ""
19
+ o.separator "Options:"
20
+ o.separator ""
21
+
22
+ o.on("-b", "--bash", "Install bash autocomplete") do |c|
23
+ options[:shells].append("bash")
24
+ end
25
+
26
+ o.on("-z", "--zsh", "Install zsh autocomplete") do |c|
27
+ options[:shells].append("zsh")
28
+ end
29
+ end
30
+
31
+ # Parse the options
32
+ argv = parse_options(opts)
33
+ return if !argv
34
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
35
+
36
+ written_paths = Vagrant::Util::InstallCLIAutocomplete.install(options[:shells])
37
+ if written_paths && written_paths.length > 0
38
+ @env.ui.info(I18n.t("vagrant.autocomplete.installed", paths: written_paths.join("\n- ")))
39
+ else
40
+ @env.ui.info(I18n.t("vagrant.autocomplete.not_installed"))
41
+ end
42
+
43
+ # Success, exit status 0
44
+ 0
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end