vagrant-unbundled 2.3.2.0 → 2.3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +57 -0
  4. data/Gemfile.lock +40 -40
  5. data/LICENSE +1 -3
  6. data/Makefile +53 -9
  7. data/contrib/bash/completion.sh +15 -0
  8. data/go.mod +1 -1
  9. data/go.sum +2 -10
  10. data/lib/vagrant/action/builtin/box_add.rb +16 -6
  11. data/lib/vagrant/environment.rb +1 -1
  12. data/lib/vagrant/errors.rb +12 -0
  13. data/lib/vagrant/plugin/v2/config.rb +0 -5
  14. data/lib/vagrant/shared_helpers.rb +21 -0
  15. data/lib/vagrant/util/file_mutex.rb +47 -0
  16. data/lib/vagrant/util/install_cli_autocomplete.rb +3 -3
  17. data/lib/vagrant/util/platform.rb +8 -2
  18. data/lib/vagrant/util.rb +1 -0
  19. data/lib/vagrant.rb +1 -3
  20. data/pkg/vagrant-unbundled-2.3.2.0.gem +0 -0
  21. data/pkg/vagrant-unbundled-2.3.3.0.gem +0 -0
  22. data/plugins/commands/box/command/outdated.rb +1 -1
  23. data/plugins/commands/serve/command.rb +22 -24
  24. data/plugins/commands/serve/constants.rb +8 -0
  25. data/plugins/communicators/ssh/communicator.rb +11 -20
  26. data/plugins/guests/solaris/cap/remove_public_key.rb +2 -2
  27. data/plugins/hosts/arch/host.rb +1 -1
  28. data/plugins/hosts/gentoo/host.rb +1 -1
  29. data/plugins/hosts/slackware/host.rb +1 -1
  30. data/plugins/kernel_v2/config/vm.rb +0 -9
  31. data/plugins/providers/docker/action.rb +1 -2
  32. data/plugins/providers/docker/driver.rb +17 -1
  33. data/plugins/providers/hyperv/driver.rb +6 -1
  34. data/plugins/providers/hyperv/scripts/set_enhanced_session_transport_type.ps1 +11 -2
  35. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +15 -0
  36. data/plugins/providers/virtualbox/action/check_virtualbox.rb +0 -6
  37. data/plugins/providers/virtualbox/action/network.rb +23 -5
  38. data/plugins/providers/virtualbox/driver/base.rb +49 -1
  39. data/plugins/providers/virtualbox/driver/version_5_0.rb +40 -36
  40. data/plugins/providers/virtualbox/driver/version_7_0.rb +241 -6
  41. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +5 -1
  42. data/plugins/provisioners/ansible/cap/guest/posix/ansible_installed.rb +2 -2
  43. data/plugins/provisioners/ansible/provisioner/guest.rb +1 -1
  44. data/plugins/provisioners/ansible/provisioner/host.rb +4 -3
  45. data/plugins/provisioners/chef/config/chef_zero.rb +1 -1
  46. data/plugins/synced_folders/rsync/helper.rb +4 -6
  47. data/templates/commands/init/Vagrantfile.erb +7 -0
  48. data/templates/locales/en.yml +16 -0
  49. data/thirdparty/proto/api-common-protos/.bazelrc +2 -0
  50. data/thirdparty/proto/api-common-protos/.git +1 -0
  51. data/thirdparty/proto/api-common-protos/.gitignore +11 -0
  52. data/thirdparty/proto/api-common-protos/BUILD.bazel +129 -0
  53. data/thirdparty/proto/api-common-protos/CODE_OF_CONDUCT.md +43 -0
  54. data/thirdparty/proto/api-common-protos/CONTRIBUTING.md +42 -0
  55. data/thirdparty/proto/api-common-protos/Dockerfile +18 -0
  56. data/thirdparty/proto/api-common-protos/LICENSE +201 -0
  57. data/thirdparty/proto/api-common-protos/README.md +113 -0
  58. data/thirdparty/proto/api-common-protos/SECURITY.md +7 -0
  59. data/thirdparty/proto/api-common-protos/WORKSPACE +154 -0
  60. data/thirdparty/proto/api-common-protos/google/api/BUILD.bazel +246 -0
  61. data/thirdparty/proto/api-common-protos/google/api/README.md +46 -0
  62. data/thirdparty/proto/api-common-protos/google/api/annotations.proto +31 -0
  63. data/thirdparty/proto/api-common-protos/google/api/auth.proto +181 -0
  64. data/thirdparty/proto/api-common-protos/google/api/backend.proto +51 -0
  65. data/thirdparty/proto/api-common-protos/google/api/billing.proto +67 -0
  66. data/thirdparty/proto/api-common-protos/google/api/client.proto +99 -0
  67. data/thirdparty/proto/api-common-protos/google/api/config_change.proto +85 -0
  68. data/thirdparty/proto/api-common-protos/google/api/consumer.proto +83 -0
  69. data/thirdparty/proto/api-common-protos/google/api/context.proto +63 -0
  70. data/thirdparty/proto/api-common-protos/google/api/control.proto +33 -0
  71. data/thirdparty/proto/api-common-protos/google/api/distribution.proto +213 -0
  72. data/thirdparty/proto/api-common-protos/google/api/documentation.proto +157 -0
  73. data/thirdparty/proto/api-common-protos/google/api/endpoint.proto +71 -0
  74. data/thirdparty/proto/api-common-protos/google/api/field_behavior.proto +84 -0
  75. data/thirdparty/proto/api-common-protos/google/api/http.proto +318 -0
  76. data/thirdparty/proto/api-common-protos/google/api/httpbody.proto +76 -0
  77. data/thirdparty/proto/api-common-protos/google/api/label.proto +49 -0
  78. data/thirdparty/proto/api-common-protos/google/api/launch_stage.proto +67 -0
  79. data/thirdparty/proto/api-common-protos/google/api/log.proto +55 -0
  80. data/thirdparty/proto/api-common-protos/google/api/logging.proto +83 -0
  81. data/thirdparty/proto/api-common-protos/google/api/metric.proto +192 -0
  82. data/thirdparty/proto/api-common-protos/google/api/monitored_resource.proto +116 -0
  83. data/thirdparty/proto/api-common-protos/google/api/monitoring.proto +89 -0
  84. data/thirdparty/proto/api-common-protos/google/api/quota.proto +259 -0
  85. data/thirdparty/proto/api-common-protos/google/api/resource.proto +299 -0
  86. data/thirdparty/proto/api-common-protos/google/api/routing.proto +461 -0
  87. data/thirdparty/proto/api-common-protos/google/api/service.proto +175 -0
  88. data/thirdparty/proto/api-common-protos/google/api/source_info.proto +32 -0
  89. data/thirdparty/proto/api-common-protos/google/api/system_parameter.proto +96 -0
  90. data/thirdparty/proto/api-common-protos/google/api/usage.proto +92 -0
  91. data/thirdparty/proto/api-common-protos/google/cloud/extended_operations.proto +150 -0
  92. data/thirdparty/proto/api-common-protos/google/iam/README.md +14 -0
  93. data/thirdparty/proto/api-common-protos/google/iam/admin/v1/iam.proto +1087 -0
  94. data/thirdparty/proto/api-common-protos/google/iam/v1/iam_policy.proto +145 -0
  95. data/thirdparty/proto/api-common-protos/google/iam/v1/logging/audit_data.proto +34 -0
  96. data/thirdparty/proto/api-common-protos/google/iam/v1/options.proto +41 -0
  97. data/thirdparty/proto/api-common-protos/google/iam/v1/policy.proto +240 -0
  98. data/thirdparty/proto/api-common-protos/google/logging/type/README.md +12 -0
  99. data/thirdparty/proto/api-common-protos/google/logging/type/http_request.proto +92 -0
  100. data/thirdparty/proto/api-common-protos/google/logging/type/log_severity.proto +72 -0
  101. data/thirdparty/proto/api-common-protos/google/longrunning/README.md +31 -0
  102. data/thirdparty/proto/api-common-protos/google/longrunning/operations.proto +247 -0
  103. data/thirdparty/proto/api-common-protos/google/rpc/README.md +18 -0
  104. data/thirdparty/proto/api-common-protos/google/rpc/code.proto +186 -0
  105. data/thirdparty/proto/api-common-protos/google/rpc/context/attribute_context.proto +287 -0
  106. data/thirdparty/proto/api-common-protos/google/rpc/error_details.proto +246 -0
  107. data/thirdparty/proto/api-common-protos/google/rpc/status.proto +47 -0
  108. data/thirdparty/proto/api-common-protos/google/type/README.md +7 -0
  109. data/thirdparty/proto/api-common-protos/google/type/calendar_period.proto +57 -0
  110. data/thirdparty/proto/api-common-protos/google/type/color.proto +170 -0
  111. data/thirdparty/proto/api-common-protos/google/type/date.proto +50 -0
  112. data/thirdparty/proto/api-common-protos/google/type/datetime.proto +97 -0
  113. data/thirdparty/proto/api-common-protos/google/type/dayofweek.proto +51 -0
  114. data/thirdparty/proto/api-common-protos/google/type/expr.proto +51 -0
  115. data/thirdparty/proto/api-common-protos/google/type/fraction.proto +34 -0
  116. data/thirdparty/proto/api-common-protos/google/type/latlng.proto +37 -0
  117. data/thirdparty/proto/api-common-protos/google/type/money.proto +43 -0
  118. data/thirdparty/proto/api-common-protos/google/type/month.proto +66 -0
  119. data/thirdparty/proto/api-common-protos/google/type/postal_address.proto +135 -0
  120. data/thirdparty/proto/api-common-protos/google/type/quaternion.proto +95 -0
  121. data/thirdparty/proto/api-common-protos/google/type/timeofday.proto +44 -0
  122. data/thirdparty/proto/api-common-protos/renovate.json +5 -0
  123. data/thirdparty/proto/api-common-protos/repository_rules.bzl +222 -0
  124. data/tools.go +10 -0
  125. data/vagrant.gemspec +13 -13
  126. data/version.txt +1 -1
  127. metadata +111 -38
  128. data/lib/vagrant/patches/net-ssh.rb +0 -286
@@ -16,7 +16,7 @@ module VagrantPlugins
16
16
  o.banner = "Usage: vagrant box outdated [options]"
17
17
  o.separator ""
18
18
  o.separator "Checks if there is a new version available for the box"
19
- o.separator "that are you are using. If you pass in the --global flag,"
19
+ o.separator "that you are using. If you pass in the --global flag,"
20
20
  o.separator "all boxes will be checked for updates."
21
21
  o.separator ""
22
22
  o.separator "Options:"
@@ -1,39 +1,37 @@
1
- $LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs").to_s
2
- $LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto").to_s
3
- $LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto/vagrant_plugin_sdk").to_s
4
-
5
- require 'vagrant/protobufs/proto/vagrant_server/server_pb'
6
- require 'vagrant/protobufs/proto/vagrant_server/server_services_pb'
7
- require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_pb'
8
- require 'vagrant/protobufs/proto/ruby_vagrant/ruby-server_services_pb'
9
- require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_pb'
10
- require 'vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_services_pb'
11
- require 'vagrant/protobufs/proto/plugin/grpc_broker_pb'
12
- require 'vagrant/protobufs/proto/plugin/grpc_broker_services_pb'
13
-
14
1
  require "optparse"
15
- require 'grpc'
16
- require 'grpc/health/checker'
17
- require 'grpc/health/v1/health_services_pb'
18
2
 
19
3
  module VagrantPlugins
20
4
  module CommandServe
21
- # Simple constant aliases to reduce namespace typing
22
- SDK = Hashicorp::Vagrant::Sdk
23
- SRV = Hashicorp::Vagrant
24
- Empty = Google::Protobuf::Empty
25
-
26
5
  autoload :Broker, Vagrant.source_root.join("plugins/commands/serve/broker").to_s
27
6
  autoload :Client, Vagrant.source_root.join("plugins/commands/serve/client").to_s
28
7
  autoload :Mappers, Vagrant.source_root.join("plugins/commands/serve/mappers").to_s
29
8
  autoload :Service, Vagrant.source_root.join("plugins/commands/serve/service").to_s
30
9
  autoload :Type, Vagrant.source_root.join("plugins/commands/serve/type").to_s
31
10
  autoload :Util, Vagrant.source_root.join("plugins/commands/serve/util").to_s
11
+ autoload :SDK, Vagrant.source_root.join("plugins/commands/serve/constants").to_s
12
+ autoload :SRV, Vagrant.source_root.join("plugins/commands/serve/constants").to_s
13
+ autoload :Empty, Vagrant.source_root.join("plugins/commands/serve/constants").to_s
32
14
 
33
15
  class << self
34
16
  attr_accessor :broker
35
17
  attr_accessor :server
36
18
  attr_reader :cache
19
+
20
+ # Loads the required dependencies for this command. This is isolated
21
+ # into a method so that the dependencies can be loaded just in time when
22
+ # the command is actually executed.
23
+ def load_dependencies!
24
+ return if @dependencies_loaded
25
+ require 'grpc'
26
+ require 'grpc/health/checker'
27
+ require 'grpc/health/v1/health_services_pb'
28
+
29
+ # Add conversion patches
30
+ require Vagrant.source_root.join("plugins/commands/serve/util/direct_conversions.rb").to_s
31
+
32
+ # Mark dependencies as loaded
33
+ @dependencies_loaded = true
34
+ end
37
35
  end
38
36
  @cache = Util::Cacher.new
39
37
 
@@ -49,6 +47,9 @@ module VagrantPlugins
49
47
  end
50
48
 
51
49
  def execute
50
+ # Load dependencies before we start
51
+ CommandServe.load_dependencies!
52
+
52
53
  options = {
53
54
  bind: DEFAULT_BIND,
54
55
  min_port: DEFAULT_PORT_RANGE.first,
@@ -138,6 +139,3 @@ module VagrantPlugins
138
139
  end
139
140
  end
140
141
  end
141
-
142
- # Load in our conversions down here so all the autoload stuff is in place
143
- require Vagrant.source_root.join("plugins/commands/serve/util/direct_conversions.rb").to_s
@@ -0,0 +1,8 @@
1
+ module VagrantPlugins
2
+ module CommandServe
3
+ # Simple constant aliases to reduce namespace typing
4
+ SDK = Hashicorp::Vagrant::Sdk
5
+ SRV = Hashicorp::Vagrant
6
+ Empty = ::Google::Protobuf::Empty
7
+ end
8
+ end
@@ -404,7 +404,7 @@ module VagrantPlugins
404
404
 
405
405
  # Set some valid auth methods. We disable the auth methods that
406
406
  # we're not using if we don't have the right auth info.
407
- auth_methods = ["none", "hostbased"]
407
+ auth_methods = ["none", "hostbased", "keyboard-interactive"]
408
408
  auth_methods << "publickey" if ssh_info[:private_key_path]
409
409
  auth_methods << "password" if ssh_info[:password]
410
410
 
@@ -456,6 +456,15 @@ module VagrantPlugins
456
456
  connect_opts[:remote_user] = ssh_info[:remote_user]
457
457
  end
458
458
 
459
+ if @machine.config.ssh.keep_alive
460
+ connect_opts[:keepalive] = true
461
+ connect_opts[:keepalive_interval] = 5
462
+ end
463
+
464
+ if ssh_info[:password]
465
+ connect_opts[:non_interactive] = true
466
+ end
467
+
459
468
  @logger.info("Attempting to connect to SSH...")
460
469
  @logger.info(" - Host: #{ssh_info[:host]}")
461
470
  @logger.info(" - Port: #{ssh_info[:port]}")
@@ -464,7 +473,7 @@ module VagrantPlugins
464
473
  @logger.info(" - Key Path: #{ssh_info[:private_key_path]}")
465
474
  @logger.debug(" - connect_opts: #{connect_opts}")
466
475
 
467
- Net::SSH.start(ssh_info[:host], ssh_info[:username], connect_opts)
476
+ Net::SSH.start(ssh_info[:host], ssh_info[:username], **connect_opts)
468
477
  ensure
469
478
  # Make sure we output the connection log
470
479
  @logger.debug("== Net-SSH connection debug-level log START ==")
@@ -683,21 +692,6 @@ module VagrantPlugins
683
692
  end
684
693
 
685
694
  begin
686
- keep_alive = nil
687
-
688
- if machine_config_ssh.keep_alive
689
- # Begin sending keep-alive packets while we wait for the script
690
- # to complete. This avoids connections closing on long-running
691
- # scripts.
692
- keep_alive = Thread.new do
693
- loop do
694
- sleep 5
695
- @logger.debug("Sending SSH keep-alive...")
696
- connection.send_global_request("keep-alive@openssh.com")
697
- end
698
- end
699
- end
700
-
701
695
  # Wait for the channel to complete
702
696
  begin
703
697
  channel.wait
@@ -711,9 +705,6 @@ module VagrantPlugins
711
705
  rescue Net::SSH::Disconnect
712
706
  raise Vagrant::Errors::SSHDisconnected
713
707
  end
714
- ensure
715
- # Kill the keep-alive thread
716
- keep_alive.kill if keep_alive
717
708
  end
718
709
 
719
710
  # If we're in a PTY, we now finally parse the output
@@ -5,14 +5,14 @@ module VagrantPlugins
5
5
  module Cap
6
6
  class RemovePublicKey
7
7
  def self.remove_public_key(machine, contents)
8
- # TODO: code is identical to linux/cap/remove_public_key
8
+ # "sed -i" is specific to GNU sed and is not a posix standard option
9
9
  contents = contents.chomp
10
10
  contents = Vagrant::Util::ShellQuote.escape(contents, "'")
11
11
 
12
12
  machine.communicate.tap do |comm|
13
13
  if comm.test("test -f ~/.ssh/authorized_keys")
14
14
  comm.execute(
15
- "sed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys")
15
+ "cp ~/.ssh/authorized_keys ~/.ssh/authorized_keys.temp && sed '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys.temp > ~/.ssh/authorized_keys && rm ~/.ssh/authorized_keys.temp")
16
16
  end
17
17
  end
18
18
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  module HostArch
5
5
  class Host < Vagrant.plugin("2", :host)
6
6
  def detect?(env)
7
- File.exist?("/etc/arch-release")
7
+ File.exist?("/etc/arch-release") && !File.exist?("/etc/artix-release")
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  module HostGentoo
5
5
  class Host < Vagrant.plugin("2", :host)
6
6
  def detect?(env)
7
- File.exists?("/etc/gentoo-release")
7
+ File.exist?("/etc/gentoo-release")
8
8
  end
9
9
  end
10
10
  end
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  module HostSlackware
5
5
  class Host < Vagrant.plugin("2", :host)
6
6
  def detect?(env)
7
- return File.exists?("/etc/slackware-version") ||
7
+ return File.exist?("/etc/slackware-version") ||
8
8
  !Dir.glob("/usr/lib/setup/Plamo-*").empty?
9
9
  end
10
10
  end
@@ -10,15 +10,6 @@ require "vagrant/util/presence"
10
10
  require "vagrant/util/experimental"
11
11
  require "vagrant/util/map_command_options"
12
12
 
13
- $LOAD_PATH << Vagrant.source_root.join("lib/vagrant/protobufs/proto").to_s
14
-
15
- require "vagrant/protobufs/proto/protostructure_pb"
16
- require "vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_pb"
17
- require "vagrant/protobufs/proto/vagrant_plugin_sdk/plugin_services_pb"
18
-
19
- # Include mappers
20
- require Vagrant.source_root.join("plugins/commands/serve/command").to_s
21
-
22
13
  require File.expand_path("../vm_provisioner", __FILE__)
23
14
  require File.expand_path("../vm_subvm", __FILE__)
24
15
  require File.expand_path("../disk", __FILE__)
@@ -231,6 +231,7 @@ module VagrantPlugins
231
231
  b2.use HostMachineSyncFolders
232
232
  b2.use PrepareNFSValidIds
233
233
  b2.use SyncedFolderCleanup
234
+ b2.use SyncedFolders
234
235
  b2.use PrepareNFSSettings
235
236
  b2.use PrepareNetworks
236
237
  b2.use Login
@@ -248,7 +249,6 @@ module VagrantPlugins
248
249
  b3.use ForwardedPorts # This action converts the `ports` param into proper network configs
249
250
  b3.use PrepareForwardedPortCollisionParams
250
251
  b3.use HandleForwardedPortCollisions
251
- b3.use SyncedFolders
252
252
  b3.use Pull
253
253
  b3.use Create
254
254
  b3.use WaitForRunning
@@ -268,7 +268,6 @@ module VagrantPlugins
268
268
  end
269
269
  else
270
270
  # We're in a run command, so we do things a bit differently.
271
- b2.use SyncedFolders
272
271
  b2.use Create
273
272
  end
274
273
  end
@@ -140,6 +140,9 @@ module VagrantPlugins
140
140
  all_containers.each do |c|
141
141
  container_info = inspect_container(c)
142
142
 
143
+ active = container_info["State"]["Running"]
144
+ next unless active # Ignore used ports on inactive containers
145
+
143
146
  if container_info["HostConfig"]["PortBindings"]
144
147
  port_bindings = container_info["HostConfig"]["PortBindings"]
145
148
  next if port_bindings.empty? # Nothing defined, but not nil either
@@ -233,9 +236,22 @@ module VagrantPlugins
233
236
  execute('docker', 'ps', '-a', '-q', '--no-trunc').to_s.split
234
237
  end
235
238
 
239
+ # Attempts to first use the docker-cli tool to inspect the default bridge subnet
240
+ # Falls back to using /sbin/ip if that fails
241
+ #
236
242
  # @return [String] IP address of the docker bridge
237
243
  def docker_bridge_ip
238
- output = execute('/sbin/ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
244
+ bridge = inspect_network("bridge")&.first
245
+ if bridge
246
+ bridge_ip = bridge.dig("IPAM", "Config", 0, "Gateway")
247
+ end
248
+ return bridge_ip if bridge_ip
249
+ @logger.debug("Failed to get bridge ip from docker, falling back to `ip`")
250
+ docker_bridge_ip_fallback
251
+ end
252
+
253
+ def docker_bridge_ip_fallback
254
+ output = execute('ip', '-4', 'addr', 'show', 'scope', 'global', 'docker0')
239
255
  if output =~ /^\s+inet ([0-9.]+)\/[0-9]+\s+/
240
256
  return $1.to_s
241
257
  else
@@ -1,4 +1,5 @@
1
1
  require "json"
2
+ require "log4r"
2
3
 
3
4
  require "vagrant/util/powershell"
4
5
 
@@ -26,6 +27,7 @@ module VagrantPlugins
26
27
 
27
28
  def initialize(id)
28
29
  @vm_id = id
30
+ @logger = Log4r::Logger.new("vagrant::hyperv::driver")
29
31
  end
30
32
 
31
33
  # @return [Boolean] Supports VMCX
@@ -294,7 +296,10 @@ module VagrantPlugins
294
296
  # @param [String] enhanced session transport type of the VM
295
297
  # @return [nil]
296
298
  def set_enhanced_session_transport_type(transport_type)
297
- execute(:set_enhanced_session_transport_type, VmID: vm_id, type: transport_type)
299
+ result = execute(:set_enhanced_session_transport_type, VmID: vm_id, type: transport_type)
300
+ if !result.nil?
301
+ @logger.debug("EnhancedSessionTransportType is not supported by this version of hyperv, ignoring")
302
+ end
298
303
  end
299
304
 
300
305
  protected
@@ -17,8 +17,17 @@ try {
17
17
  }
18
18
 
19
19
  try {
20
- Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
20
+ # HyperV 1.1 (Windows Server 2012R2) crashes on this call. Vagrantfiles before 2.2.10 do break without skipping this.
21
+ $present = Get-Command Hyper-V\Set-VM -ParameterName EnhancedSessionTransportType -ErrorAction SilentlyContinue
22
+ if($present) {
23
+ Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
24
+ }else{
25
+ $message = @{
26
+ "EnhancedSessionTransportTypeSupportPresent"=$false;
27
+ } | ConvertTo-Json
28
+ Write-OutputMessage $message
29
+ }
21
30
  } catch {
22
- Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}: ${PSItem}"
31
+ Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}:${PSItem}"
23
32
  exit 1
24
33
  }
@@ -1,6 +1,21 @@
1
1
  # Always stop when errors are encountered unless instructed not to
2
2
  $ErrorActionPreference = "Stop"
3
3
 
4
+ # Check the version of Powershell currently in use. If it's
5
+ # under 7.3.0 we need to restrict the maximum version of the
6
+ # security module to prevent errors.
7
+ # Source: https://github.com/PowerShell/PowerShell/issues/18530
8
+ $checkVersion = $PSVersionTable.PSVersion
9
+ if($checkVersion -eq "") {
10
+ $checkVersion = $(Get-Host).Version
11
+ }
12
+
13
+ if([System.Version]$checkVersion -lt [System.Version]"7.3.0") {
14
+ Import-Module Microsoft.Powershell.Security -MaximumVersion 3.0.0.0
15
+ } else {
16
+ Import-Module Microsoft.Powershell.Security
17
+ }
18
+
4
19
  # Vagrant VM creation functions
5
20
 
6
21
  function New-VagrantVM {
@@ -16,12 +16,6 @@ module VagrantPlugins
16
16
  # which will break us out of execution of the middleware sequence.
17
17
  Driver::Meta.new.verify!
18
18
 
19
- if Vagrant::Util::Platform.windows? && Vagrant::Util::Platform.windows_hyperv_enabled?
20
- @logger.error("Virtualbox and Hyper-V cannot be used together at the same time on Windows and will result in a system crash.")
21
-
22
- raise Vagrant::Errors::HypervVirtualBoxError
23
- end
24
-
25
19
  # Carry on.
26
20
  @app.call(env)
27
21
  end
@@ -21,6 +21,8 @@ module VagrantPlugins
21
21
  VBOX_NET_CONF = "/etc/vbox/networks.conf".freeze
22
22
  # Version of VirtualBox that introduced hostonly network range restrictions
23
23
  HOSTONLY_VALIDATE_VERSION = Gem::Version.new("6.1.28")
24
+ # Version of VirtualBox on darwin platform that ignores restrictions
25
+ DARWIN_IGNORE_HOSTONLY_VALIDATE_VERSION = Gem::Version.new("7.0.0")
24
26
  # Default valid range for hostonly networks
25
27
  HOSTONLY_DEFAULT_RANGE = [IPAddr.new("192.168.56.0/21").freeze].freeze
26
28
 
@@ -69,6 +71,21 @@ module VagrantPlugins
69
71
  type = :internal_network
70
72
  end
71
73
 
74
+ if !options.key?(:type) && options.key?(:ip)
75
+ begin
76
+ addr = IPAddr.new(options[:ip])
77
+ options[:type] = if addr.ipv4?
78
+ :static
79
+ else
80
+ :static6
81
+ end
82
+ rescue IPAddr::Error => err
83
+ raise Vagrant::Errors::NetworkAddressInvalid,
84
+ address: options[:ip], mask: options[:netmask],
85
+ error: err.message
86
+ end
87
+ end
88
+
72
89
  # Configure it
73
90
  data = nil
74
91
  if type == :private_network
@@ -479,10 +496,7 @@ module VagrantPlugins
479
496
  #-----------------------------------------------------------------
480
497
  # This creates a host only network for the given configuration.
481
498
  def hostonly_create_network(config)
482
- @env[:machine].provider.driver.create_host_only_network(
483
- adapter_ip: config[:adapter_ip],
484
- netmask: config[:netmask]
485
- )
499
+ @env[:machine].provider.driver.create_host_only_network(config)
486
500
  end
487
501
 
488
502
  # This finds a matching host only network for the given configuration.
@@ -517,7 +531,11 @@ module VagrantPlugins
517
531
  # placed on the valid ranges
518
532
  def validate_hostonly_ip!(ip, driver)
519
533
  return if Gem::Version.new(driver.version) < HOSTONLY_VALIDATE_VERSION ||
520
- Vagrant::Util::Platform.windows?
534
+ (
535
+ Vagrant::Util::Platform.darwin? &&
536
+ Gem::Version.new(driver.version) >= DARWIN_IGNORE_HOSTONLY_VALIDATE_VERSION
537
+ ) ||
538
+ Vagrant::Util::Platform.windows?
521
539
 
522
540
  ip = IPAddr.new(ip.to_s) if !ip.is_a?(IPAddr)
523
541
  valid_ranges = load_net_conf
@@ -460,7 +460,9 @@ module VagrantPlugins
460
460
  end
461
461
 
462
462
  # Append in the options for subprocess
463
- command << { notify: [:stdout, :stderr] }
463
+ # NOTE: We include the LANG env var set to C to prevent command output
464
+ # from being localized
465
+ command << { notify: [:stdout, :stderr], env: env_lang}
464
466
 
465
467
  Vagrant::Util::Busy.busy(int_callback) do
466
468
  Vagrant::Util::Subprocess.execute(@vboxmanage_path, *command, &block)
@@ -469,6 +471,52 @@ module VagrantPlugins
469
471
  raise Vagrant::Errors::VBoxManageLaunchError,
470
472
  message: e.to_s
471
473
  end
474
+
475
+ private
476
+
477
+ # List of LANG values to attempt to use
478
+ LANG_VARIATIONS = %w(C.UTF-8 C.utf8 en_US.UTF-8 en_US.utf8 C POSIX).map(&:freeze).freeze
479
+
480
+ # By default set the LANG to C. If the host has the locale command
481
+ # available, check installed locales and verify C is included (or
482
+ # use C variant if available).
483
+ def env_lang
484
+ # If already set, just return immediately
485
+ return @env_lang if @env_lang
486
+
487
+ # Default the LANG to C
488
+ @env_lang = {LANG: "C"}
489
+
490
+ # If the locale command is not available, return default
491
+ return @env_lang if !Vagrant::Util::Which.which("locale")
492
+
493
+ @logger.debug("validating LANG value for virtualbox cli commands")
494
+ # Get list of available locales on the system
495
+ result = Vagrant::Util::Subprocess.execute("locale", "-a")
496
+
497
+ # If the command results in an error, just log the error
498
+ # and return the default value
499
+ if result.exit_code != 0
500
+ @logger.warn("locale command failed (exit code: #{result.exit_code}): #{result.stderr}")
501
+ return @env_lang
502
+ end
503
+ available = result.stdout.lines.map(&:chomp).find_all { |l|
504
+ l == "C" || l == "POSIX" || l.start_with?("C.") || l.start_with?("en_US.")
505
+ }
506
+ @logger.debug("list of available C locales: #{available.inspect}")
507
+
508
+ # Attempt to find a valid LANG from locale list
509
+ lang = LANG_VARIATIONS.detect { |l| available.include?(l) }
510
+
511
+ if lang
512
+ @logger.debug("valid variation found for LANG value: #{lang}")
513
+ @env_lang[:LANG] = lang
514
+ end
515
+
516
+ @logger.debug("LANG value set: #{@env_lang[:LANG].inspect}")
517
+
518
+ @env_lang
519
+ end
472
520
  end
473
521
  end
474
522
  end
@@ -104,15 +104,15 @@ module VagrantPlugins
104
104
  end
105
105
  end
106
106
 
107
- # Creates a disk. Default format is VDI unless overridden
108
- #
109
- # @param [String] disk_file
110
- # @param [Integer] disk_size - size in bytes
111
- # @param [String] disk_format - format of disk, defaults to "VDI"
107
+ # Creates a disk. Default format is VDI unless overridden
108
+ #
109
+ # @param [String] disk_file
110
+ # @param [Integer] disk_size - size in bytes
111
+ # @param [String] disk_format - format of disk, defaults to "VDI"
112
112
  # @param [Hash] opts - additional options
113
- def create_disk(disk_file, disk_size, disk_format="VDI", **opts)
114
- execute("createmedium", '--filename', disk_file, '--sizebyte', disk_size.to_i.to_s, '--format', disk_format)
115
- end
113
+ def create_disk(disk_file, disk_size, disk_format="VDI", **opts)
114
+ execute("createmedium", '--filename', disk_file, '--sizebyte', disk_size.to_i.to_s, '--format', disk_format)
115
+ end
116
116
 
117
117
 
118
118
  def create_host_only_network(options)
@@ -322,22 +322,22 @@ module VagrantPlugins
322
322
 
323
323
  if adapter[:bridge]
324
324
  args.concat(["--bridgeadapter#{adapter[:adapter]}",
325
- adapter[:bridge], "--cableconnected#{adapter[:adapter]}", "on"])
325
+ adapter[:bridge], "--cableconnected#{adapter[:adapter]}", "on"])
326
326
  end
327
327
 
328
328
  if adapter[:hostonly]
329
329
  args.concat(["--hostonlyadapter#{adapter[:adapter]}",
330
- adapter[:hostonly], "--cableconnected#{adapter[:adapter]}", "on"])
330
+ adapter[:hostonly], "--cableconnected#{adapter[:adapter]}", "on"])
331
331
  end
332
332
 
333
333
  if adapter[:intnet]
334
334
  args.concat(["--intnet#{adapter[:adapter]}",
335
- adapter[:intnet], "--cableconnected#{adapter[:adapter]}", "on"])
335
+ adapter[:intnet], "--cableconnected#{adapter[:adapter]}", "on"])
336
336
  end
337
337
 
338
338
  if adapter[:mac_address]
339
339
  args.concat(["--macaddress#{adapter[:adapter]}",
340
- adapter[:mac_address]])
340
+ adapter[:mac_address]])
341
341
  end
342
342
 
343
343
  if adapter[:nic_type]
@@ -361,7 +361,7 @@ module VagrantPlugins
361
361
 
362
362
  # If the file already exists we'll throw a custom error
363
363
  raise Vagrant::Errors::VirtualBoxFileExists,
364
- stderr: e.extra_data[:stderr]
364
+ stderr: e.extra_data[:stderr]
365
365
  end
366
366
  end
367
367
  end
@@ -370,14 +370,14 @@ module VagrantPlugins
370
370
  args = []
371
371
  ports.each do |options|
372
372
  pf_builder = [options[:name],
373
- options[:protocol] || "tcp",
374
- options[:hostip] || "",
375
- options[:hostport],
376
- options[:guestip] || "",
377
- options[:guestport]]
373
+ options[:protocol] || "tcp",
374
+ options[:hostip] || "",
375
+ options[:hostport],
376
+ options[:guestip] || "",
377
+ options[:guestport]]
378
378
 
379
379
  args.concat(["--natpf#{options[:adapter] || 1}",
380
- pf_builder.join(",")])
380
+ pf_builder.join(",")])
381
381
  end
382
382
 
383
383
  execute("modifyvm", @uuid, *args, retryable: true) if !args.empty?
@@ -507,11 +507,11 @@ module VagrantPlugins
507
507
  # since this comes first.
508
508
  current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
509
509
 
510
- # If we care about active VMs only, then we check the state
511
- # to verify the VM is running.
512
- if active_only && line =~ /^VMState="(.+?)"$/ && $1.to_s != "running"
513
- return []
514
- end
510
+ # If we care about active VMs only, then we check the state
511
+ # to verify the VM is running.
512
+ if active_only && line =~ /^VMState="(.+?)"$/ && $1.to_s != "running"
513
+ return []
514
+ end
515
515
 
516
516
  # Parse out the forwarded port information
517
517
  # Forwarding(1)="172.22.8.201tcp32977,tcp,172.22.8.201,32977,,3777"
@@ -600,7 +600,7 @@ module VagrantPlugins
600
600
 
601
601
  if !valid_ip_address?(ip)
602
602
  raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound,
603
- guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
603
+ guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
604
604
  end
605
605
 
606
606
  return ip
@@ -662,13 +662,17 @@ module VagrantPlugins
662
662
  end
663
663
 
664
664
  def read_machine_folder
665
- execute("list", "systemproperties", retryable: true).split("\n").each do |line|
666
- if line =~ /^Default machine folder:\s+(.+?)$/i
667
- return $1.to_s
668
- end
665
+ info = execute("list", "systemproperties", retryable: true)
666
+ info.each_line do |line|
667
+ match = line.match(/Default machine folder:\s+(?<folder>.+?)$/i)
668
+ next if match.nil?
669
+ return match[:folder]
669
670
  end
670
671
 
671
- nil
672
+ @logger.warn("failed to determine machine folder from system properties")
673
+ @logger.debug("processed output for machine folder lookup:\n#{info}")
674
+
675
+ raise Vagrant::Errors::VirtualBoxMachineFolderNotFound
672
676
  end
673
677
 
674
678
  def read_network_interfaces
@@ -771,7 +775,7 @@ module VagrantPlugins
771
775
  # We got VERR_ALREADY_EXISTS. This means that we're renaming to
772
776
  # a VM name that already exists. Raise a custom error.
773
777
  raise Vagrant::Errors::VirtualBoxNameExists,
774
- stderr: e.extra_data[:stderr]
778
+ stderr: e.extra_data[:stderr]
775
779
  end
776
780
  end
777
781
  end
@@ -791,9 +795,9 @@ module VagrantPlugins
791
795
  hostpath = Vagrant::Util::Platform.windows_path(folder[:hostpath])
792
796
  end
793
797
  args = ["--name",
794
- folder[:name],
795
- "--hostpath",
796
- hostpath]
798
+ folder[:name],
799
+ "--hostpath",
800
+ hostpath]
797
801
  args << "--transient" if folder.key?(:transient) && folder[:transient]
798
802
 
799
803
  args << "--automount" if folder.key?(:automount) && folder[:automount]
@@ -866,8 +870,8 @@ module VagrantPlugins
866
870
 
867
871
  # If we reached this point then it didn't work out.
868
872
  raise Vagrant::Errors::VBoxManageError,
869
- command: command.inspect,
870
- stderr: r.stderr
873
+ command: command.inspect,
874
+ stderr: r.stderr
871
875
  end
872
876
  end
873
877