vagrant-unbundled 2.3.2.0 → 2.3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +12 -12
  4. data/LICENSE +1 -3
  5. data/lib/vagrant/errors.rb +4 -0
  6. data/lib/vagrant/util/install_cli_autocomplete.rb +3 -3
  7. data/lib/vagrant.rb +0 -3
  8. data/pkg/vagrant-unbundled-2.3.2.0.gem +0 -0
  9. data/plugins/commands/serve/command.rb +1 -1
  10. data/plugins/guests/solaris/cap/remove_public_key.rb +2 -2
  11. data/plugins/hosts/gentoo/host.rb +1 -1
  12. data/plugins/hosts/slackware/host.rb +1 -1
  13. data/plugins/providers/virtualbox/action/network.rb +8 -5
  14. data/plugins/providers/virtualbox/driver/base.rb +3 -1
  15. data/plugins/providers/virtualbox/driver/version_5_0.rb +40 -36
  16. data/plugins/providers/virtualbox/driver/version_7_0.rb +223 -5
  17. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +1 -1
  18. data/plugins/provisioners/ansible/provisioner/host.rb +1 -1
  19. data/plugins/provisioners/chef/config/chef_zero.rb +1 -1
  20. data/plugins/synced_folders/rsync/helper.rb +1 -0
  21. data/templates/locales/en.yml +4 -0
  22. data/thirdparty/proto/api-common-protos/.bazelrc +2 -0
  23. data/thirdparty/proto/api-common-protos/.git +1 -0
  24. data/thirdparty/proto/api-common-protos/.gitignore +11 -0
  25. data/thirdparty/proto/api-common-protos/BUILD.bazel +129 -0
  26. data/thirdparty/proto/api-common-protos/CODE_OF_CONDUCT.md +43 -0
  27. data/thirdparty/proto/api-common-protos/CONTRIBUTING.md +42 -0
  28. data/thirdparty/proto/api-common-protos/Dockerfile +18 -0
  29. data/thirdparty/proto/api-common-protos/LICENSE +201 -0
  30. data/thirdparty/proto/api-common-protos/README.md +113 -0
  31. data/thirdparty/proto/api-common-protos/SECURITY.md +7 -0
  32. data/thirdparty/proto/api-common-protos/WORKSPACE +154 -0
  33. data/thirdparty/proto/api-common-protos/google/api/BUILD.bazel +246 -0
  34. data/thirdparty/proto/api-common-protos/google/api/README.md +46 -0
  35. data/thirdparty/proto/api-common-protos/google/api/annotations.proto +31 -0
  36. data/thirdparty/proto/api-common-protos/google/api/auth.proto +181 -0
  37. data/thirdparty/proto/api-common-protos/google/api/backend.proto +51 -0
  38. data/thirdparty/proto/api-common-protos/google/api/billing.proto +67 -0
  39. data/thirdparty/proto/api-common-protos/google/api/client.proto +99 -0
  40. data/thirdparty/proto/api-common-protos/google/api/config_change.proto +85 -0
  41. data/thirdparty/proto/api-common-protos/google/api/consumer.proto +83 -0
  42. data/thirdparty/proto/api-common-protos/google/api/context.proto +63 -0
  43. data/thirdparty/proto/api-common-protos/google/api/control.proto +33 -0
  44. data/thirdparty/proto/api-common-protos/google/api/distribution.proto +213 -0
  45. data/thirdparty/proto/api-common-protos/google/api/documentation.proto +157 -0
  46. data/thirdparty/proto/api-common-protos/google/api/endpoint.proto +71 -0
  47. data/thirdparty/proto/api-common-protos/google/api/field_behavior.proto +84 -0
  48. data/thirdparty/proto/api-common-protos/google/api/http.proto +318 -0
  49. data/thirdparty/proto/api-common-protos/google/api/httpbody.proto +76 -0
  50. data/thirdparty/proto/api-common-protos/google/api/label.proto +49 -0
  51. data/thirdparty/proto/api-common-protos/google/api/launch_stage.proto +67 -0
  52. data/thirdparty/proto/api-common-protos/google/api/log.proto +55 -0
  53. data/thirdparty/proto/api-common-protos/google/api/logging.proto +83 -0
  54. data/thirdparty/proto/api-common-protos/google/api/metric.proto +192 -0
  55. data/thirdparty/proto/api-common-protos/google/api/monitored_resource.proto +116 -0
  56. data/thirdparty/proto/api-common-protos/google/api/monitoring.proto +89 -0
  57. data/thirdparty/proto/api-common-protos/google/api/quota.proto +259 -0
  58. data/thirdparty/proto/api-common-protos/google/api/resource.proto +299 -0
  59. data/thirdparty/proto/api-common-protos/google/api/routing.proto +461 -0
  60. data/thirdparty/proto/api-common-protos/google/api/service.proto +175 -0
  61. data/thirdparty/proto/api-common-protos/google/api/source_info.proto +32 -0
  62. data/thirdparty/proto/api-common-protos/google/api/system_parameter.proto +96 -0
  63. data/thirdparty/proto/api-common-protos/google/api/usage.proto +92 -0
  64. data/thirdparty/proto/api-common-protos/google/cloud/extended_operations.proto +150 -0
  65. data/thirdparty/proto/api-common-protos/google/iam/README.md +14 -0
  66. data/thirdparty/proto/api-common-protos/google/iam/admin/v1/iam.proto +1087 -0
  67. data/thirdparty/proto/api-common-protos/google/iam/v1/iam_policy.proto +145 -0
  68. data/thirdparty/proto/api-common-protos/google/iam/v1/logging/audit_data.proto +34 -0
  69. data/thirdparty/proto/api-common-protos/google/iam/v1/options.proto +41 -0
  70. data/thirdparty/proto/api-common-protos/google/iam/v1/policy.proto +240 -0
  71. data/thirdparty/proto/api-common-protos/google/logging/type/README.md +12 -0
  72. data/thirdparty/proto/api-common-protos/google/logging/type/http_request.proto +92 -0
  73. data/thirdparty/proto/api-common-protos/google/logging/type/log_severity.proto +72 -0
  74. data/thirdparty/proto/api-common-protos/google/longrunning/README.md +31 -0
  75. data/thirdparty/proto/api-common-protos/google/longrunning/operations.proto +247 -0
  76. data/thirdparty/proto/api-common-protos/google/rpc/README.md +18 -0
  77. data/thirdparty/proto/api-common-protos/google/rpc/code.proto +186 -0
  78. data/thirdparty/proto/api-common-protos/google/rpc/context/attribute_context.proto +287 -0
  79. data/thirdparty/proto/api-common-protos/google/rpc/error_details.proto +246 -0
  80. data/thirdparty/proto/api-common-protos/google/rpc/status.proto +47 -0
  81. data/thirdparty/proto/api-common-protos/google/type/README.md +7 -0
  82. data/thirdparty/proto/api-common-protos/google/type/calendar_period.proto +57 -0
  83. data/thirdparty/proto/api-common-protos/google/type/color.proto +170 -0
  84. data/thirdparty/proto/api-common-protos/google/type/date.proto +50 -0
  85. data/thirdparty/proto/api-common-protos/google/type/datetime.proto +97 -0
  86. data/thirdparty/proto/api-common-protos/google/type/dayofweek.proto +51 -0
  87. data/thirdparty/proto/api-common-protos/google/type/expr.proto +51 -0
  88. data/thirdparty/proto/api-common-protos/google/type/fraction.proto +34 -0
  89. data/thirdparty/proto/api-common-protos/google/type/latlng.proto +37 -0
  90. data/thirdparty/proto/api-common-protos/google/type/money.proto +43 -0
  91. data/thirdparty/proto/api-common-protos/google/type/month.proto +66 -0
  92. data/thirdparty/proto/api-common-protos/google/type/postal_address.proto +135 -0
  93. data/thirdparty/proto/api-common-protos/google/type/quaternion.proto +95 -0
  94. data/thirdparty/proto/api-common-protos/google/type/timeofday.proto +44 -0
  95. data/thirdparty/proto/api-common-protos/renovate.json +5 -0
  96. data/thirdparty/proto/api-common-protos/repository_rules.bzl +222 -0
  97. data/vagrant.gemspec +4 -4
  98. data/version.txt +1 -1
  99. metadata +89 -20
  100. data/lib/vagrant/patches/net-ssh.rb +0 -286
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 011ad261587bca60f45ba75518042b42714fb3071f7d3b26a77e0a18c72128b5
4
- data.tar.gz: 05527c04f7777abfd80b43af313a906e2951c52f01e6ed4c3580ca14f665cd22
3
+ metadata.gz: 6d80f12bb6896767fb93de74dca7ff025aeb935c32bf6a2ab202b30582329ea1
4
+ data.tar.gz: ff5d56384a90926d3393a85400f3b34579f1e901b348318ae71b0219b8a29049
5
5
  SHA512:
6
- metadata.gz: 140d7455f8410bcf801b7aef6bdab946f0c17fa4f6f542f0587bf1cae69511fb07587a98760f822b3ff0b18218683f76f8c0baa424348e9acc040c0e1ea775f7
7
- data.tar.gz: d3dd774a2b030c6b56794d3339846e0b049e64a67ec6dd534763e5d48ccb8a8bcdce21fd3fbc618d8568ee3fff49d84a94cc84f89105f7444406321402ea6de6
6
+ metadata.gz: c84b9f9edc34fcecd13ca1b740903d1074242e0797cef80d849055959ea95da61b77eb07fe86ba5e53cf3db23aeddec02d91459972101fc2bd18efa026a690e6
7
+ data.tar.gz: 3cf8aebc8ff49c47dc52c47bf4ef329ed7fd3e2109c72aacbc06d751aafbecdb2e10be61f2405015683031bb5a9ca9bbf639d8b0c08809078eb72a9a1f060fcc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 2.3.3 (November 15, 2022)
2
+
3
+ IMPROVEMENTS:
4
+
5
+ - core: Bump net-ssh dependency to 7.0 and remove patches [GH-12979]
6
+ - synced_folders/rsync: Include ssh `extra_args` value [GH-12973]
7
+
8
+ BUG FIXES:
9
+
10
+ - command/serve: Force root level namespace for Google constant [GH-12989]
11
+ - guest/solaris: Fix insecure key authorized keys removal [GH-12740]
12
+ - provider/virtualbox: Fix `:private_network` support for VirtualBox 7 on macOS [GH-12983]
13
+ - provider/virtualbox: Prevent localization of command output [GH-12994]
14
+ - provisioner/ansible: Update setup packages in debian capability [GH-12832]
15
+
1
16
  ## 2.3.2 (October 18, 2022)
2
17
 
3
18
  FEATURES:
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- vagrant-unbundled (2.3.2.0)
15
+ vagrant-unbundled (2.3.3.0)
16
16
  bcrypt_pbkdf (~> 1.1)
17
17
  childprocess (~> 4.1.0)
18
18
  ed25519 (~> 1.3.0)
@@ -26,9 +26,9 @@ PATH
26
26
  log4r (~> 1.1.9, < 1.1.11)
27
27
  mime-types (~> 3.3)
28
28
  net-ftp (~> 0.1)
29
- net-scp (~> 3.0.0)
30
- net-sftp (~> 3.0)
31
- net-ssh (>= 6.1.0, < 6.2)
29
+ net-scp (~> 4.0)
30
+ net-sftp (~> 4.0)
31
+ net-ssh (~> 7.0)
32
32
  rb-kqueue (~> 0.2.0)
33
33
  rexml (~> 3.2)
34
34
  rgl (~> 0.5.7)
@@ -50,10 +50,10 @@ GEM
50
50
  diff-lcs (1.5.0)
51
51
  ed25519 (1.3.0)
52
52
  erubi (1.11.0)
53
- excon (0.93.1)
53
+ excon (0.94.0)
54
54
  fake_ftp (0.3.0)
55
55
  ffi (1.15.5)
56
- google-protobuf (3.21.8)
56
+ google-protobuf (3.21.9)
57
57
  googleapis-common-protos-types (1.4.0)
58
58
  google-protobuf (~> 3.14)
59
59
  grpc (1.50.0)
@@ -87,11 +87,11 @@ GEM
87
87
  time
88
88
  net-protocol (0.1.3)
89
89
  timeout
90
- net-scp (3.0.0)
91
- net-ssh (>= 2.6.5, < 7.0.0)
92
- net-sftp (3.0.0)
93
- net-ssh (>= 5.0.0, < 7.0.0)
94
- net-ssh (6.1.0)
90
+ net-scp (4.0.0)
91
+ net-ssh (>= 2.6.5, < 8.0.0)
92
+ net-sftp (4.0.0)
93
+ net-ssh (>= 5.0.0, < 8.0.0)
94
+ net-ssh (7.0.1)
95
95
  nori (2.6.0)
96
96
  pairing_heap (1.0.0)
97
97
  rake (13.0.6)
@@ -160,7 +160,7 @@ DEPENDENCIES
160
160
  fake_ftp (~> 0.3.0)
161
161
  grpc-tools (~> 1.41)
162
162
  rake (~> 13.0)
163
- rspec (~> 3.11.0)
163
+ rspec (~> 3.11)
164
164
  rspec-its (~> 1.3.0)
165
165
  vagrant-spec!
166
166
  vagrant-unbundled!
data/LICENSE CHANGED
@@ -1,6 +1,4 @@
1
- The MIT License
2
-
3
- Copyright (c) 2010-2019 Mitchell Hashimoto
1
+ Copyright (c) 2010 HashiCorp, Inc.
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
4
  of this software and associated documentation files (the "Software"), to deal
@@ -1020,6 +1020,10 @@ module Vagrant
1020
1020
  error_key(:virtualbox_install_incomplete)
1021
1021
  end
1022
1022
 
1023
+ class VirtualBoxMachineFolderNotFound < VagrantError
1024
+ error_key(:virtualbox_machine_folder_not_found)
1025
+ end
1026
+
1023
1027
  class VirtualBoxNoName < VagrantError
1024
1028
  error_key(:virtualbox_no_name)
1025
1029
  end
@@ -3,7 +3,7 @@ module Vagrant
3
3
  # Generic installation of content to shell config file
4
4
  class InstallShellConfig
5
5
 
6
- PERPEND_STRING = "# >>>> Vagrant command completion (start)".freeze
6
+ PREPEND_STRING = "# >>>> Vagrant command completion (start)".freeze
7
7
  APPEND_STRING = "# <<<< Vagrant command completion (end)".freeze
8
8
 
9
9
  attr_accessor :prepend_string
@@ -12,7 +12,7 @@ module Vagrant
12
12
  attr_accessor :config_paths
13
13
 
14
14
  def initialize(string_insert, config_paths)
15
- @prepend_string = PERPEND_STRING
15
+ @prepend_string = PREPEND_STRING
16
16
  @string_insert = string_insert
17
17
  @append_string = APPEND_STRING
18
18
  @config_paths = config_paths
@@ -29,7 +29,7 @@ module Vagrant
29
29
  @logger.info("Searching for config in home #{home}")
30
30
  @config_paths.each do |path|
31
31
  config_file = File.join(home, path)
32
- if File.exists?(config_file)
32
+ if File.exist?(config_file)
33
33
  @logger.info("Found config file #{config_file}")
34
34
  return config_file
35
35
  end
data/lib/vagrant.rb CHANGED
@@ -15,9 +15,6 @@ class Log4r::BasicFormatter
15
15
  end
16
16
  end
17
17
 
18
- # Add our patches to net-ssh
19
- require "vagrant/patches/net-ssh"
20
-
21
18
  require "optparse"
22
19
 
23
20
  module Vagrant
Binary file
@@ -21,7 +21,7 @@ module VagrantPlugins
21
21
  # Simple constant aliases to reduce namespace typing
22
22
  SDK = Hashicorp::Vagrant::Sdk
23
23
  SRV = Hashicorp::Vagrant
24
- Empty = Google::Protobuf::Empty
24
+ Empty = ::Google::Protobuf::Empty
25
25
 
26
26
  autoload :Broker, Vagrant.source_root.join("plugins/commands/serve/broker").to_s
27
27
  autoload :Client, Vagrant.source_root.join("plugins/commands/serve/client").to_s
@@ -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 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
@@ -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
 
@@ -479,10 +481,7 @@ module VagrantPlugins
479
481
  #-----------------------------------------------------------------
480
482
  # This creates a host only network for the given configuration.
481
483
  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
- )
484
+ @env[:machine].provider.driver.create_host_only_network(config)
486
485
  end
487
486
 
488
487
  # This finds a matching host only network for the given configuration.
@@ -517,7 +516,11 @@ module VagrantPlugins
517
516
  # placed on the valid ranges
518
517
  def validate_hostonly_ip!(ip, driver)
519
518
  return if Gem::Version.new(driver.version) < HOSTONLY_VALIDATE_VERSION ||
520
- Vagrant::Util::Platform.windows?
519
+ (
520
+ Vagrant::Util::Platform.darwin? &&
521
+ Gem::Version.new(driver.version) >= DARWIN_IGNORE_HOSTONLY_VALIDATE_VERSION
522
+ ) ||
523
+ Vagrant::Util::Platform.windows?
521
524
 
522
525
  ip = IPAddr.new(ip.to_s) if !ip.is_a?(IPAddr)
523
526
  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: {LANG: "C"}}
464
466
 
465
467
  Vagrant::Util::Busy.busy(int_callback) do
466
468
  Vagrant::Util::Subprocess.execute(@vboxmanage_path, *command, &block)
@@ -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
 
@@ -6,12 +6,214 @@ module VagrantPlugins
6
6
  module Driver
7
7
  # Driver for VirtualBox 7.0.x
8
8
  class Version_7_0 < Version_6_1
9
+ # VirtualBox version requirement for using host only networks
10
+ # instead of host only interfaces
11
+ HOSTONLY_NET_REQUIREMENT=Gem::Requirement.new(">= 7")
12
+ # Prefix of name used for host only networks
13
+ HOSTONLY_NAME_PREFIX="vagrantnet-vbox"
14
+ DEFAULT_NETMASK="255.255.255.0"
15
+
9
16
  def initialize(uuid)
10
17
  super
11
18
 
12
19
  @logger = Log4r::Logger.new("vagrant::provider::virtualbox_7_0")
13
20
  end
14
21
 
22
+ def read_bridged_interfaces
23
+ ifaces = super
24
+ return ifaces if !use_host_only_nets?
25
+
26
+ # Get a list of all subnets which are in use for hostonly networks
27
+ hostonly_ifaces = read_host_only_networks.map do |net|
28
+ IPAddr.new(net[:lowerip]).mask(net[:networkmask])
29
+ end
30
+
31
+ # Prune any hostonly interfaces in the list
32
+ ifaces.delete_if { |i|
33
+ addr = IPAddr.new(i[:ip]).mask(i[:netmask])
34
+ hostonly_ifaces.include?(addr)
35
+ }
36
+
37
+ ifaces
38
+ end
39
+
40
+ def delete_unused_host_only_networks
41
+ return super if !use_host_only_nets?
42
+
43
+ # First get the list of existing host only network names
44
+ network_names = read_host_only_networks.map { |net| net[:name] }
45
+ # Prune the network names to only include ones we manage
46
+ network_names.delete_if { |name| !name.start_with?(HOSTONLY_NAME_PREFIX) }
47
+
48
+ @logger.debug("managed host only network names: #{network_names}")
49
+
50
+ return if network_names.empty?
51
+
52
+ # Next get the list of host only networks currently in use
53
+ inuse_names = []
54
+ execute("list", "vms", retryable: true).split("\n").each do |line|
55
+ match = line.match(/^".+?"\s+\{(?<vmid>.+?)\}$/)
56
+ next if match.nil?
57
+ begin
58
+ info = execute("showvminfo", match[:vmid].to_s, "--machinereadable", retryable: true)
59
+ info.split("\n").each do |vmline|
60
+ if vmline.start_with?("hostonly-network")
61
+ net_name = vmline.split("=", 2).last.to_s.gsub('"', "")
62
+ inuse_names << net_name
63
+ end
64
+ end
65
+ rescue Vagrant::Errors::VBoxManageError => err
66
+ raise if !err.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
67
+ end
68
+ end
69
+
70
+ @logger.debug("currently in use network names: #{inuse_names}")
71
+
72
+ # Now remove all the networks not in use
73
+ (network_names - inuse_names).each do |name|
74
+ execute("hostonlynet", "remove", "--name", name, retryable: true)
75
+ end
76
+ end
77
+
78
+ def enable_adapters(adapters)
79
+ return super if !use_host_only_nets?
80
+
81
+ hostonly_adapters = adapters.find_all { |adapter| adapter[:hostonly] }
82
+ other_adapters = adapters - hostonly_adapters
83
+ super(other_adapters) if !other_adapters.empty?
84
+
85
+ if !hostonly_adapters.empty?
86
+ args = []
87
+ hostonly_adapters.each do |adapter|
88
+ args.concat(["--nic#{adapter[:adapter]}", "hostonlynet"])
89
+ args.concat(["--host-only-net#{adapter[:adapter]}", adapter[:hostonly],
90
+ "--cableconnected#{adapter[:adapter]}", "on"])
91
+ end
92
+
93
+ execute("modifyvm", @uuid, *args, retryable: true)
94
+ end
95
+ end
96
+
97
+ def create_host_only_network(options)
98
+ # If we are not on macOS, just setup the hostonly interface
99
+ return super if !use_host_only_nets?
100
+
101
+ opts = {
102
+ netmask: options.fetch(:netmask, DEFAULT_NETMASK),
103
+ }
104
+
105
+ if options[:type] == :dhcp
106
+ opts[:lower] = options[:dhcp_lower]
107
+ opts[:upper] = options[:dhcp_upper]
108
+ else
109
+ addr = IPAddr.new(options[:adapter_ip])
110
+ opts[:upper] = opts[:lower] = addr.mask(opts[:netmask]).to_range.first.to_s
111
+ end
112
+
113
+ name_idx = read_host_only_networks.map { |hn|
114
+ next if !hn[:name].start_with?(HOSTONLY_NAME_PREFIX)
115
+ hn[:name].sub(HOSTONLY_NAME_PREFIX, "").to_i
116
+ }.compact.max.to_i + 1
117
+ opts[:name] = HOSTONLY_NAME_PREFIX + name_idx.to_s
118
+
119
+ execute("hostonlynet", "add",
120
+ "--name", opts[:name],
121
+ "--netmask", opts[:netmask],
122
+ "--lower-ip", opts[:lower],
123
+ "--upper-ip", opts[:upper],
124
+ retryable: true)
125
+
126
+ {
127
+ name: opts[:name],
128
+ ip: options[:adapter_ip],
129
+ netmask: opts[:netmask],
130
+ }
131
+ end
132
+
133
+ # Disabled when host only nets are in use
134
+ def reconfig_host_only(options)
135
+ return super if !use_host_only_nets?
136
+ end
137
+
138
+ # Disabled when host only nets are in use since
139
+ # the host only nets will provide the dhcp server
140
+ def remove_dhcp_server(*_, **_)
141
+ super if !use_host_only_nets?
142
+ end
143
+
144
+ # Disabled when host only nets are in use since
145
+ # the host only nets will provide the dhcp server
146
+ def create_dhcp_server(*_, **_)
147
+ super if !use_host_only_nets?
148
+ end
149
+
150
+ def read_host_only_interfaces
151
+ return super if !use_host_only_nets?
152
+
153
+ # When host only nets are in use, read them and
154
+ # reformat the information to line up with how
155
+ # the interfaces is structured
156
+ read_host_only_networks.map do |net|
157
+ addr = IPAddr.new(net[:lowerip])
158
+ net[:netmask] = net[:networkmask]
159
+ if addr.ipv4?
160
+ net[:ip] = addr.mask(net[:netmask]).succ.to_s
161
+ net[:ipv6] = ""
162
+ else
163
+ net[:ip] = ""
164
+ net[:ipv6] = addr.mask(net[:netmwask]).succ.to_s
165
+ net[:ipv6_prefix] = net[:netmask]
166
+ end
167
+
168
+ net[:status] = net[:state] == "Enabled" ? "Up" : "Down"
169
+
170
+ net
171
+ end
172
+ end
173
+
174
+ def read_network_interfaces
175
+ return super if !use_host_only_nets?
176
+
177
+ {}.tap do |nics|
178
+ execute("showvminfo", @uuid, "--machinereadable", retryable: true).each_line do |line|
179
+ if m = line.match(/nic(?<adapter>\d+)="(?<type>.+?)"$/)
180
+ nics[m[:adapter].to_i] ||= {}
181
+ if m[:type] == "hostonlynetwork"
182
+ nics[m[:adapter].to_i][:type] = :hostonly
183
+ else
184
+ nics[m[:adapter].to_i][:type] = m[:type].to_sym
185
+ end
186
+ elsif m = line.match(/^bridgeadapter(?<adapter>\d+)="(?<network>.+?)"$/)
187
+ nics[m[:adapter].to_i] ||= {}
188
+ nics[m[:adapter].to_i][:bridge] = m[:network]
189
+ elsif m = line.match(/^hostonly-network(?<adapter>\d+)="(?<network>.+?)"$/)
190
+ nics[m[:adapter].to_i] ||= {}
191
+ nics[m[:adapter].to_i][:hostonly] = m[:network]
192
+ end
193
+ end
194
+ end
195
+ end
196
+
197
+ # Generate list of host only networks
198
+ def read_host_only_networks
199
+ networks = []
200
+ current = nil
201
+ execute("list", "hostonlynets", retryable: true).split("\n").each do |line|
202
+ line.chomp!
203
+ next if line.empty?
204
+ key, value = line.split(":", 2).map(&:strip)
205
+ key = key.downcase
206
+ if key == "name"
207
+ networks.push(current) if !current.nil?
208
+ current = Vagrant::Util::HashWithIndifferentAccess.new
209
+ end
210
+ current[key] = value
211
+ end
212
+ networks.push(current) if !current.nil?
213
+
214
+ networks
215
+ end
216
+
15
217
  # The initial VirtualBox 7.0 release has an issue with displaying port
16
218
  # forward information. When a single port forward is defined, the forwarding
17
219
  # information can be found in the `showvminfo` output. Once more than a
@@ -20,11 +222,8 @@ module VagrantPlugins
20
222
  # file from the `showvminfo` output and extract the port forward information
21
223
  # from there instead.
22
224
  def read_forwarded_ports(uuid=nil, active_only=false)
23
- @version ||= Meta.new.version
24
-
25
- # Only use this override for the 7.0.0 release. If it is still broken
26
- # on the 7.0.1 release we can modify the version check.
27
- return super if @version != "7.0.0"
225
+ # Only use this override for the 7.0.0 release.
226
+ return super if get_version.to_s != "7.0.0"
28
227
 
29
228
  uuid ||= @uuid
30
229
 
@@ -61,6 +260,25 @@ module VagrantPlugins
61
260
 
62
261
  results
63
262
  end
263
+
264
+ private
265
+
266
+ # Returns if hostonlynets are enabled on the current
267
+ # host platform
268
+ #
269
+ # @return [Boolean]
270
+ def use_host_only_nets?
271
+ Vagrant::Util::Platform.darwin? &&
272
+ HOSTONLY_NET_REQUIREMENT.satisfied_by?(get_version)
273
+ end
274
+
275
+ # VirtualBox version in use
276
+ #
277
+ # @return [Gem::Version]
278
+ def get_version
279
+ return @version if @version
280
+ @version = Gem::Version.new(Meta.new.version)
281
+ end
64
282
  end
65
283
  end
66
284
  end