vagrant_utm 0.1.1 → 0.1.2.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e58e1f0313976a35281a3233fe67d4150f84c8ec51ed41c2ca55256ba9cae05e
4
- data.tar.gz: b5b234e460ef8517720492d3b5695cf771cd52efdd0a60c172ec3d644931b535
3
+ metadata.gz: 4afb59e8282747e3cca61c9ed2b297b7084606c268cc4e6231856f12fb2510b0
4
+ data.tar.gz: 1a4ba9a73219106a661fdddad221d14128d203fc8c273dc22fa3018d72b25e0b
5
5
  SHA512:
6
- metadata.gz: fb95231d43a7f9731d7b36823ff7e991b5e11c9113a60590120b21fcd0d6b420116fe7d39e3465e579e5c1548071d562b50b94142c5f4bb689d13c24a671271b
7
- data.tar.gz: b3a7b1655c81f270c6aa8399668fcfd5862201f9d00e9532ba00b7e9609e2d6dc7b5a986b502fd447b39dd303bb92ce1b9f513b7c09e2fa2ccf4a801de5878c4
6
+ metadata.gz: 01e79bc38a232a68a08eb43e7cddfcc2ed0866acd54a559b797e8c26f84fce16c5d8ec171492758fc514080c8b98be32dd2505554f9e04a8c2897a1d05fb3d2a
7
+ data.tar.gz: '07951106f1403e2bb7811f699ed914c12eb701e15cb4142f6f2318a2ffc4fd9065e49bfdc098b544d547f3129005b4cf8370bad9d513a356d0b9c9b77b8b2719'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [Unreleased]
2
+
3
+
4
+ ## [0.1.2.beta] - 2024-12-05
5
+
6
+ WARNING: This version of the plugin adds initial synced folder support. By default, Vagrant will pick the directory share method which it supports and prefers. e.g., SMB. However, SMB is not fully tested, so you need to force the plugin to pick the one that is simple and tested `rsync`
7
+
8
+ ```ruby
9
+ Vagrant.configure("2") do |config|
10
+ config.vm.synced_folder ".", "/vagrant", type: "rsync"
11
+ config.vm.box = "utm/ubuntu-24.04"
12
+ end
13
+ ```
14
+
15
+ ### Added
16
+
17
+ - Initial Synced Folder support with sync
18
+ - Warning: By default vagrant brings other sync methods eg: SMB, NFS but they are not ready to use.
19
+
1
20
  ## [0.1.1] - 2024-12-03
2
21
 
3
22
  IMPORTANT: This version of the plugin only works with UTM version 4.5.1 and above, and is incompatible with 0.0.1 version of the plugin.
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module Utm
5
+ module Action
6
+ # This action prepares the NFS settings for the machine.
7
+ class PrepareNFSSettings
8
+ include Vagrant::Action::Builtin::MixinSyncedFolders
9
+ include Vagrant::Util::Retryable
10
+
11
+ def initialize(app, _env)
12
+ @app = app
13
+ @logger = Log4r::Logger.new("vagrant::action::vm::nfs")
14
+ end
15
+
16
+ def call(env)
17
+ @machine = env[:machine]
18
+
19
+ @app.call(env)
20
+
21
+ opts = {
22
+ cached: !env[:synced_folders_cached].nil?,
23
+ config: env[:synced_folders_config],
24
+ disable_usable_check: !env[:test].nil?
25
+ }
26
+ folders = synced_folders(env[:machine], **opts)
27
+
28
+ return unless folders.key?(:nfs)
29
+
30
+ @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
31
+ add_ips_to_env!(env)
32
+ end
33
+
34
+ # Extracts the proper host and guest IPs for NFS mounts and stores them
35
+ # in the environment for the SyncedFolder action to use them in
36
+ # mounting.
37
+ #
38
+ # The ! indicates that this method modifies its argument.
39
+ def add_ips_to_env!(env)
40
+ # Hardcoded IP for the host IP
41
+ host_ip = "10.0.2.2"
42
+ machine_ip = read_dynamic_machine_ip
43
+
44
+ raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip
45
+
46
+ env[:nfs_host_ip] = host_ip
47
+ env[:nfs_machine_ip] = machine_ip
48
+ end
49
+
50
+ # Returns the IP address of the guest by looking at utm guest additions
51
+ # for the appropriate guest adapter.
52
+ #
53
+ # For DHCP interfaces, the guest property will not be present until the
54
+ # guest completes
55
+ #
56
+ # @param [Integer] adapter number to read IP for
57
+ # @return [String] ip address of adapter
58
+ def read_dynamic_machine_ip
59
+ # we need to wait for the guest's IP to show up as a guest property.
60
+ # retry thresholds are relatively high since we might need to wait
61
+ # for DHCP, but even static IPs can take a second or two to appear.
62
+ retryable(retry_options.merge(on: Vagrant::Errors::VirtualBoxGuestPropertyNotFound)) do
63
+ # Read the IP address from the list given by qemu-guest-agent
64
+ @machine.provider.driver.read_guest_ip[0]
65
+ end
66
+ rescue Vagrant::Errors::VirtualBoxGuestPropertyNotFound
67
+ # this error is more specific with a better error message directing
68
+ # the user towards the fact that it's probably a reportable bug
69
+ raise Vagrant::Errors::NFSNoGuestIP
70
+ end
71
+
72
+ # Separating these out so we can stub out the sleep in tests
73
+ def retry_options
74
+ { tries: 15, sleep: 1 }
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) HashiCorp, Inc.
4
+ # SPDX-License-Identifier: BUSL-1.1
5
+
6
+ module VagrantPlugins
7
+ module Utm
8
+ module Action
9
+ # This action prepares the NFS valid IDs for the VMs.
10
+ # The ids that are valid and should not be pruned by NFS
11
+ class PrepareNFSValidIds
12
+ def initialize(app, _env)
13
+ @app = app
14
+ @logger = Log4r::Logger.new("vagrant::action::vm::nfs")
15
+ end
16
+
17
+ def call(env)
18
+ env[:nfs_valid_ids] = env[:machine].provider.driver.read_vms.keys
19
+ @app.call(env)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -40,6 +40,8 @@ module VagrantPlugins
40
40
  autoload :PackageSetupFiles, action_root.join("package_setup_files")
41
41
  autoload :PackageSetupFolders, action_root.join("package_setup_folders")
42
42
  autoload :PackageVagrantfile, action_root.join("package_vagrantfile")
43
+ autoload :PrepareNFSSettings, action_root.join("prepare_nfs_settings")
44
+ autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
43
45
  autoload :PrepareForwardedPortCollisionParams, action_root.join("prepare_forwarded_port_collision_params")
44
46
  autoload :Resume, action_root.join("resume")
45
47
  autoload :SetId, action_root.join("set_id")
@@ -66,6 +68,10 @@ module VagrantPlugins
66
68
  b.use EnvSet, port_collision_repair: true
67
69
  b.use PrepareForwardedPortCollisionParams
68
70
  b.use HandleForwardedPortCollisions
71
+ b.use PrepareNFSValidIds
72
+ b.use SyncedFolderCleanup
73
+ b.use SyncedFolders
74
+ b.use PrepareNFSSettings
69
75
  b.use ForwardPorts
70
76
  b.use SetHostname
71
77
  b.use Customize, "pre-boot"
@@ -90,7 +96,7 @@ module VagrantPlugins
90
96
  # This is the action that is primarily responsible for completely
91
97
  # freeing the resources of the underlying virtual machine.
92
98
  # UTM equivalent of `utmctl delete <uuid>`
93
- def self.action_destroy
99
+ def self.action_destroy # rubocop:disable Metrics/AbcSize
94
100
  Vagrant::Action::Builder.new.tap do |b|
95
101
  b.use CheckUtm
96
102
  b.use Call, Created do |env1, b2|
@@ -106,6 +112,8 @@ module VagrantPlugins
106
112
  b3.use CheckAccessible
107
113
  b3.use action_halt
108
114
  b3.use Destroy
115
+ b3.use PrepareNFSValidIds
116
+ b3.use SyncedFolderCleanup
109
117
  else
110
118
  b3.use MessageWillNotDestroy
111
119
  end
@@ -160,7 +168,7 @@ module VagrantPlugins
160
168
  end
161
169
 
162
170
  # This action packages the virtual machine into a single box file.
163
- def self.action_package
171
+ def self.action_package # rubocop:disable Metrics/AbcSize
164
172
  Vagrant::Action::Builder.new.tap do |b|
165
173
  b.use CheckUtm
166
174
  b.use Call, Created do |env, b2|
@@ -174,6 +182,8 @@ module VagrantPlugins
174
182
  b2.use CheckAccessible
175
183
  b2.use action_halt
176
184
  b2.use ClearForwardedPorts
185
+ b2.use PrepareNFSValidIds
186
+ b2.use SyncedFolderCleanup
177
187
  b2.use Package
178
188
  b2.use Export
179
189
  b2.use PackageVagrantfile
@@ -405,6 +415,16 @@ module VagrantPlugins
405
415
  end
406
416
  end
407
417
 
418
+ # This is the action that is called to sync folders to a running
419
+ # machine without a reboot.
420
+ def self.action_sync_folders
421
+ Vagrant::Action::Builder.new.tap do |b|
422
+ b.use PrepareNFSValidIds
423
+ b.use SyncedFolders
424
+ b.use PrepareNFSSettings
425
+ end
426
+ end
427
+
408
428
  # This action brings the machine up from nothing, including importing
409
429
  # the box, configuring metadata, and booting.
410
430
  def self.action_up
@@ -86,6 +86,12 @@ module VagrantPlugins
86
86
  # @return [Array]
87
87
  def read_used_ports(active_only: true); end
88
88
 
89
+ # Returns a list of all UUIDs of virtual machines currently
90
+ # known by UTM.
91
+ #
92
+ # @return [Array<String>]
93
+ def read_vms; end
94
+
89
95
  # Returns the IP addresses of the guest machine.
90
96
  # Only supported for VMs with qemu-guest-agent installed.
91
97
  #
@@ -104,6 +104,7 @@ module VagrantPlugins
104
104
  :read_network_interfaces,
105
105
  :read_state,
106
106
  :read_used_ports,
107
+ :read_vms,
107
108
  :restore_snapshot,
108
109
  :set_mac_address,
109
110
  :set_name,
@@ -239,6 +239,16 @@ module VagrantPlugins
239
239
  ports
240
240
  end
241
241
 
242
+ def read_vms
243
+ results = {}
244
+ list.machines.each do |machine|
245
+ # Store UUID (Unique) as key and name as value
246
+ results[machine.uuid] = machine.name
247
+ end
248
+
249
+ results
250
+ end
251
+
242
252
  def set_name(name) # rubocop:disable Naming/AccessorMethodName
243
253
  command = ["customize_vm.applescript", @uuid, "--name", name.to_s]
244
254
  execute_osa_script(command)
@@ -4,6 +4,6 @@ module VagrantPlugins
4
4
  # Top level module for the Utm provider plugin.
5
5
  module Utm
6
6
  # Current version of the Utm provider plugin.
7
- VERSION = "0.1.1"
7
+ VERSION = "0.1.2.beta"
8
8
  end
9
9
  end
data/notes/README.md CHANGED
@@ -21,10 +21,17 @@ To release
21
21
  To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`
22
22
  GitHub action upon tag push with "v*" will publish gem to GHR and rubygems
23
23
 
24
- 1. Update the version number in `version.rb`
25
- 2. Run `bundle exec rake release`
26
- 3. Commit version and Gemlock file
27
- 4. Run `bundle exec rake release` again
28
- 5. Cancel push to rubygems.org
24
+ 1. Update
25
+ CHANGELOG.md
26
+ version number in `version.rb`
27
+ version number Gemlock file
28
+ 2. Commit
29
+ 3. Run `bundle exec rake release` (Commit and tags are pushed)
30
+ 4. Cancel push to rubygems.org
29
31
 
30
- GHA will publish gems to GHR and rubygems
32
+ GHA will publish gems to GHR and rubygems
33
+
34
+
35
+ To update specific gems in the project
36
+
37
+ `bundle update rubocop`
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant_utm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naveenraj M
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-03 00:00:00.000000000 Z
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Vagrant UTM provider that allows you to manage UTM virtual machines.
14
14
  email:
@@ -84,6 +84,8 @@ files:
84
84
  - lib/vagrant_utm/action/package_setup_folders.rb
85
85
  - lib/vagrant_utm/action/package_vagrantfile.rb
86
86
  - lib/vagrant_utm/action/prepare_forwarded_port_collision_params.rb
87
+ - lib/vagrant_utm/action/prepare_nfs_settings.rb
88
+ - lib/vagrant_utm/action/prepare_nfs_valid_ids.rb
87
89
  - lib/vagrant_utm/action/resume.rb
88
90
  - lib/vagrant_utm/action/set_id.rb
89
91
  - lib/vagrant_utm/action/set_name.rb