vagrant_utm 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +43 -3
- data/docs/boxes/creating_utm_box.md +26 -2
- data/docs/commands.md +8 -0
- data/lib/vagrant_utm/action/ip_address.rb +33 -0
- data/lib/vagrant_utm/action/match_mac_address.rb +37 -0
- data/lib/vagrant_utm/action.rb +23 -1
- data/lib/vagrant_utm/commands/disposable.rb +29 -0
- data/lib/vagrant_utm/commands/ip_address.rb +28 -0
- data/lib/vagrant_utm/driver/base.rb +23 -2
- data/lib/vagrant_utm/driver/meta.rb +3 -3
- data/lib/vagrant_utm/driver/version_4_5.rb +10 -3
- data/lib/vagrant_utm/model/forwarded_port.rb +3 -1
- data/lib/vagrant_utm/plugin.rb +11 -8
- data/lib/vagrant_utm/provider.rb +2 -1
- data/lib/vagrant_utm/scripts/read_network_interfaces.applescript +2 -1
- data/lib/vagrant_utm/scripts/set_mac_address.applescript +25 -0
- data/lib/vagrant_utm/version.rb +1 -1
- data/locales/en.yml +8 -0
- data/notes/README.md +9 -1
- metadata +7 -4
- data/lib/vagrant_utm/disposable.rb +0 -16
- data/lib/vagrant_utm/scripts/read_guest_ip.applescript +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e58e1f0313976a35281a3233fe67d4150f84c8ec51ed41c2ca55256ba9cae05e
|
4
|
+
data.tar.gz: b5b234e460ef8517720492d3b5695cf771cd52efdd0a60c172ec3d644931b535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb95231d43a7f9731d7b36823ff7e991b5e11c9113a60590120b21fcd0d6b420116fe7d39e3465e579e5c1548071d562b50b94142c5f4bb689d13c24a671271b
|
7
|
+
data.tar.gz: b3a7b1655c81f270c6aa8399668fcfd5862201f9d00e9532ba00b7e9609e2d6dc7b5a986b502fd447b39dd303bb92ce1b9f513b7c09e2fa2ccf4a801de5878c4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
|
-
## [
|
1
|
+
## [0.1.1] - 2024-12-03
|
2
2
|
|
3
|
-
|
3
|
+
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.
|
4
4
|
|
5
|
-
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- command: add new vagrant command `vagrant ip-address` (9252020)
|
8
|
+
- command: add help messages to custom plugin commands (a35466f)
|
9
|
+
- action: Set mac address when bringing up new machine (0efe15b)
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- plugin: Make config.vm.box mandatory for this plugin (b5be5e8)
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
|
17
|
+
- disposable: allow disposable start only for machines already created (cbf591e)
|
18
|
+
- up: Set given mac address or random mac address for first interface of a machine to get different IPs of a same base box.
|
19
|
+
|
20
|
+
### Removed
|
21
|
+
|
22
|
+
- Driver: Removed support for UTM version 4.5.x (9aea46e)
|
23
|
+
|
24
|
+
## [0.1.0] (Beta) - 2024-11-30
|
25
|
+
|
26
|
+
IMPORTANT: This version of the plugin only works with UTM version 4.5.1 and above, and is incompatible with previous versions of the plugin.
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- driver: add new driver for UTM version 4.6.x (13d0ca0)
|
31
|
+
- vagrant: add vagrant box support (f7accad)
|
32
|
+
- command: support `vagrant package` command (39fb5a5)
|
33
|
+
|
34
|
+
|
35
|
+
### Removed
|
36
|
+
|
37
|
+
- Drop support for `utm_file_url` from provider config (4fb0ac0)
|
38
|
+
- Remove support for importing utm files in zip format (c988671)
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
## [0.0.1] (Pilot release) - 2024-08-08
|
43
|
+
|
44
|
+
* Initial release with all basic vagrant commands
|
45
|
+
* Uses UTM file in zip format from a url as VM box to import
|
@@ -8,6 +8,23 @@ nav_order: 2
|
|
8
8
|
|
9
9
|
As with [every Vagrant Provider](https://developer.hashicorp.com/vagrant/docs/providers/basic_usage), the Vagrant UTM provider has a custom box format that is required to work with Vagrant and the UTM plugin.
|
10
10
|
|
11
|
+
## UTM Vagrant box format
|
12
|
+
|
13
|
+
UTM file (in macOS) is a directory containing Data/qcow2 (s), Data/efi_vars.fd and config.plist.
|
14
|
+
Vagrant Box format will require additional metadata.json file.
|
15
|
+
|
16
|
+
Vagrant .box is a tar file
|
17
|
+
|
18
|
+
The contents of a `utm/ubuntu-24.04` vagrant box.
|
19
|
+
```bash
|
20
|
+
$tar -tf ubuntu-24.04.box
|
21
|
+
Vagrantfile
|
22
|
+
box.utm/Data/7FB247A3-DC9F-4A61-A123-0AEE1BEEC636.qcow2
|
23
|
+
box.utm/Data/efi_vars.fd
|
24
|
+
box.utm/config.plist
|
25
|
+
box.utm/screenshot.png
|
26
|
+
metadata.json
|
27
|
+
```
|
11
28
|
|
12
29
|
{: .warning }
|
13
30
|
This is a reasonably advanced topic that a beginning user of Vagrant does not need to understand. If you are just getting started with Vagrant, skip this and use an [available box](/utm_box_gallery.md). If you are an experienced user of Vagrant and want to create your own custom boxes, this is for you.
|
@@ -16,9 +33,16 @@ This is a reasonably advanced topic that a beginning user of Vagrant does not ne
|
|
16
33
|
|
17
34
|
The virtual machine created in UTM can use any configuration you would like, but Vagrant has some hard requirements:
|
18
35
|
|
19
|
-
* The
|
36
|
+
* The first network interface (adapter 1 or index 0) must be `Shared Network`, which is recommended for new virtual machines.
|
37
|
+
|
38
|
+
We use 'Shared Network' as a NAT equivalent in Vagrant.
|
39
|
+
|
40
|
+
* The second network interface (adapter 2 or index 1) must be a `Emulated VLAN` adapter. Vagrant uses this to connect the first time via forwarded ports.
|
41
|
+
|
42
|
+
We use 'Emulated VLAN' to achieve port forwarding.
|
43
|
+
|
44
|
+
|
20
45
|
|
21
|
-
* Use can use the first network interface (adapter 0 or index 0) to be `Shared Network`, which is recommended for new virtual machines.
|
22
46
|
|
23
47
|
Other than the above, you are free to customize the base virtual machine as you see fit.
|
24
48
|
|
data/docs/commands.md
CHANGED
@@ -141,6 +141,14 @@ Import VM (if not created)
|
|
141
141
|
|
142
142
|
These are the commands not available in vagrant but specific to UTM provider.
|
143
143
|
|
144
|
+
## IP Address
|
145
|
+
|
146
|
+
**Command: `vagrant ip-address [name|id]`**
|
147
|
+
|
148
|
+
`utmctl ip-address`
|
149
|
+
|
150
|
+
List all IP addresses associated with network interfaces on the guest.
|
151
|
+
|
144
152
|
## Disposable
|
145
153
|
|
146
154
|
**Command: `vagrant disposable [name|id]`**
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Utm
|
5
|
+
module Action
|
6
|
+
# Action to get IP address of machine.
|
7
|
+
class IpAddress
|
8
|
+
def initialize(app, _env)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env) # rubocop:disable Metrics/AbcSize
|
13
|
+
# Get IP address of the machine.
|
14
|
+
env[:ui].warn I18n.t("vagrant_utm.actions.vm.ip_address.reading")
|
15
|
+
guest_ips = env[:machine].provider.driver.read_guest_ip
|
16
|
+
|
17
|
+
if guest_ips.empty?
|
18
|
+
# Inform user that no IP address was found.
|
19
|
+
env[:ui].warn I18n.t("vagrant_utm.actions.vm.ip_address.not_found")
|
20
|
+
else
|
21
|
+
# Show IP address of the machine.
|
22
|
+
env[:ui].info I18n.t("vagrant_utm.actions.vm.ip_address.show")
|
23
|
+
guest_ips.each do |ip|
|
24
|
+
env[:ui].info " #{ip}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@app.call(env)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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 matches the MAC address of the virtual machine to the
|
10
|
+
# configured MAC address in the Vagrantfile.
|
11
|
+
# OR generates a new MAC address if none is set.
|
12
|
+
# This is useful to make sure that different virtual machines
|
13
|
+
# have different MAC addresses.
|
14
|
+
class MatchMACAddress
|
15
|
+
def initialize(app, _env)
|
16
|
+
@app = app
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env) # rubocop:disable Metrics/AbcSize
|
20
|
+
base_mac = env[:machine].config.vm.base_mac
|
21
|
+
# If we have a base MAC address and not is empty (empty in some default Vagranfile)
|
22
|
+
# then we use that to match
|
23
|
+
if base_mac && !base_mac.empty?
|
24
|
+
# Create the proc which we want to use to modify the virtual machine
|
25
|
+
env[:ui].info I18n.t("vagrant.actions.vm.match_mac.matching")
|
26
|
+
env[:machine].provider.driver.set_mac_address(env[:machine].config.vm.base_mac)
|
27
|
+
else
|
28
|
+
env[:ui].info I18n.t("vagrant.actions.vm.match_mac.generating")
|
29
|
+
env[:machine].provider.driver.set_mac_address(nil)
|
30
|
+
end
|
31
|
+
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/vagrant_utm/action.rb
CHANGED
@@ -25,9 +25,11 @@ module VagrantPlugins
|
|
25
25
|
autoload :ForcedHalt, action_root.join("forced_halt")
|
26
26
|
autoload :ForwardPorts, action_root.join("forward_ports")
|
27
27
|
autoload :Import, action_root.join("import")
|
28
|
+
autoload :IpAddress, action_root.join("ip_address")
|
28
29
|
autoload :IsPaused, action_root.join("is_paused")
|
29
30
|
autoload :IsRunning, action_root.join("is_running")
|
30
31
|
autoload :IsStopped, action_root.join("is_stopped")
|
32
|
+
autoload :MatchMACAddress, action_root.join("match_mac_address")
|
31
33
|
autoload :MessageAlreadyRunning, action_root.join("message_already_running")
|
32
34
|
autoload :MessageNotCreated, action_root.join("message_not_created")
|
33
35
|
autoload :MessageNotRunning, action_root.join("message_not_running")
|
@@ -140,6 +142,23 @@ module VagrantPlugins
|
|
140
142
|
end
|
141
143
|
end
|
142
144
|
|
145
|
+
# This action returns ip address of the machine.
|
146
|
+
# UTM equivalent of `utmctl ip-address <uuid>`
|
147
|
+
def self.action_ip_address
|
148
|
+
Vagrant::Action::Builder.new.tap do |b|
|
149
|
+
b.use CheckUtm
|
150
|
+
b.use ConfigValidate
|
151
|
+
b.use Call, IsRunning do |env1, b2|
|
152
|
+
unless env1[:result]
|
153
|
+
b2.use MessageNotRunning
|
154
|
+
next
|
155
|
+
end
|
156
|
+
# If the VM is running, then get the IP address.
|
157
|
+
b2.use IpAddress
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
143
162
|
# This action packages the virtual machine into a single box file.
|
144
163
|
def self.action_package
|
145
164
|
Vagrant::Action::Builder.new.tap do |b|
|
@@ -351,12 +370,14 @@ module VagrantPlugins
|
|
351
370
|
end
|
352
371
|
end
|
353
372
|
|
354
|
-
# This action
|
373
|
+
# This action starts VM in disposable mode.
|
355
374
|
# UTM equivalent of `utmctl start <uuid> --disposable`
|
356
375
|
def self.action_start_disposable
|
357
376
|
Vagrant::Action::Builder.new.tap do |b|
|
358
377
|
b.use CheckUtm
|
359
378
|
b.use ConfigValidate
|
379
|
+
b.use CheckCreated
|
380
|
+
|
360
381
|
b.use Call, IsRunning do |env1, b2|
|
361
382
|
if env1[:result]
|
362
383
|
b2.use MessageAlreadyRunning
|
@@ -405,6 +426,7 @@ module VagrantPlugins
|
|
405
426
|
b2.use Customize, "pre-import"
|
406
427
|
|
407
428
|
b2.use Import
|
429
|
+
b2.use MatchMACAddress
|
408
430
|
end
|
409
431
|
end
|
410
432
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Utm
|
5
|
+
# Run VM as a snapshot and do not save changes to disk.
|
6
|
+
class CommandDisposable < Vagrant.plugin(2, :command)
|
7
|
+
def self.synopsis
|
8
|
+
"UTM: boots machine in UTM disposable mode"
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
opts = OptionParser.new do |o|
|
13
|
+
o.banner = "Usage: vagrant disposable [name|id]"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Parse the options
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return unless argv
|
19
|
+
|
20
|
+
with_target_vms do |machine|
|
21
|
+
machine.action(:start_disposable)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Success, exit status 0
|
25
|
+
0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Utm
|
5
|
+
# Get All IP Adress of a machine.
|
6
|
+
class CommandIpAddress < Vagrant.plugin(2, :command)
|
7
|
+
def self.synopsis
|
8
|
+
"UTM: outputs ip address of the vagrant machine"
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
opts = OptionParser.new do |o|
|
13
|
+
o.banner = "Usage: vagrant ip-address [name|id]"
|
14
|
+
end
|
15
|
+
|
16
|
+
# Parse the options
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return unless argv
|
19
|
+
|
20
|
+
with_target_vms do |machine|
|
21
|
+
machine.action(:ip_address)
|
22
|
+
end
|
23
|
+
|
24
|
+
0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -86,9 +86,10 @@ module VagrantPlugins
|
|
86
86
|
# @return [Array]
|
87
87
|
def read_used_ports(active_only: true); end
|
88
88
|
|
89
|
-
# Returns the
|
89
|
+
# Returns the IP addresses of the guest machine.
|
90
|
+
# Only supported for VMs with qemu-guest-agent installed.
|
90
91
|
#
|
91
|
-
# @return [String] The IP
|
92
|
+
# @return [Array<String>] The IP addresses of the guest machine.
|
92
93
|
def read_guest_ip; end
|
93
94
|
|
94
95
|
# Returns a list of network interfaces of the VM.
|
@@ -96,6 +97,11 @@ module VagrantPlugins
|
|
96
97
|
# @return [Hash]
|
97
98
|
def read_network_interfaces; end
|
98
99
|
|
100
|
+
# Sets the MAC address of the first network adapter.
|
101
|
+
#
|
102
|
+
# @param [String] mac MAC address without any spaces/hyphens.
|
103
|
+
def set_mac_address(mac); end # rubocop:disable Naming/AccessorMethodName
|
104
|
+
|
99
105
|
# Execute the 'list' command and returns the list of machines.
|
100
106
|
# @return [ListResult] The list of machines.
|
101
107
|
def list; end
|
@@ -142,6 +148,21 @@ module VagrantPlugins
|
|
142
148
|
# This should raise a VagrantError if things are not ready.
|
143
149
|
def verify!; end
|
144
150
|
|
151
|
+
# Generate a random MAC address.
|
152
|
+
#
|
153
|
+
# This method generates a random MAC address because it is difficult
|
154
|
+
# to get UTM to generate one through scripting.
|
155
|
+
#
|
156
|
+
# @return [String] The MAC address.
|
157
|
+
def random_mac_address
|
158
|
+
# Generate 6 random bytes
|
159
|
+
bytes = Array.new(6) { rand(256) }
|
160
|
+
# Ensure the first byte is local
|
161
|
+
bytes[0] = (bytes[0] & 0xFC) | 0x02
|
162
|
+
# Convert bytes to MAC address string
|
163
|
+
bytes.map { |byte| format("%02X", byte) }.join(":")
|
164
|
+
end
|
165
|
+
|
145
166
|
# Execute a script using the OSA interface.
|
146
167
|
def execute_osa_script(command); end
|
147
168
|
|
@@ -55,13 +55,12 @@ module VagrantPlugins
|
|
55
55
|
# Instantiate the proper version driver for UTM
|
56
56
|
@logger.debug("Finding driver for UTM version: #{@version}")
|
57
57
|
driver_map = {
|
58
|
-
"4.5" => Version_4_5,
|
59
58
|
"4.6" => Version_4_6
|
60
59
|
}
|
61
60
|
|
62
|
-
# UTM 4.
|
61
|
+
# UTM 4.6.0 doesn't have import support to work with Vagrant box,
|
63
62
|
# so show error
|
64
|
-
raise Errors::UtmInvalidVersion if @version.start_with?("4.
|
63
|
+
raise Errors::UtmInvalidVersion if @version.start_with?("4.6.0")
|
65
64
|
|
66
65
|
driver_klass = nil
|
67
66
|
driver_map.each do |key, klass|
|
@@ -106,6 +105,7 @@ module VagrantPlugins
|
|
106
105
|
:read_state,
|
107
106
|
:read_used_ports,
|
108
107
|
:restore_snapshot,
|
108
|
+
:set_mac_address,
|
109
109
|
:set_name,
|
110
110
|
:ssh_port,
|
111
111
|
:start,
|
@@ -174,9 +174,8 @@ module VagrantPlugins
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def read_guest_ip
|
177
|
-
|
178
|
-
output
|
179
|
-
output.strip
|
177
|
+
output = execute("ip-address", @uuid)
|
178
|
+
output.strip.split("\n")
|
180
179
|
end
|
181
180
|
|
182
181
|
def read_network_interfaces
|
@@ -195,6 +194,14 @@ module VagrantPlugins
|
|
195
194
|
nics
|
196
195
|
end
|
197
196
|
|
197
|
+
def set_mac_address(mac) # rubocop:disable Naming/AccessorMethodName
|
198
|
+
# Set the MAC address of the first NIC (index 0)
|
199
|
+
# Set MAC address to given value or randomize it if nil
|
200
|
+
mac = random_mac_address if mac.nil?
|
201
|
+
command = ["set_mac_address.applescript", @uuid, "0", mac]
|
202
|
+
execute_osa_script(command)
|
203
|
+
end
|
204
|
+
|
198
205
|
def ssh_port(expected_port)
|
199
206
|
@logger.debug("Searching for SSH port: #{expected_port.inspect}")
|
200
207
|
|
@@ -57,7 +57,9 @@ module VagrantPlugins
|
|
57
57
|
options ||= {}
|
58
58
|
@auto_correct = false
|
59
59
|
@auto_correct = options[:auto_correct] if options.key?(:auto_correct)
|
60
|
-
|
60
|
+
# if adapter is not set, use index 1 (Emulated VLAN).
|
61
|
+
# index 0 is the default adapter (Shared Network)
|
62
|
+
@adapter = (options[:adapter] || 1).to_i
|
61
63
|
@guest_ip = options[:guest_ip] || nil
|
62
64
|
@host_ip = options[:host_ip] || nil
|
63
65
|
@protocol = options[:protocol] || "tcp" # default to TCP
|
data/lib/vagrant_utm/plugin.rb
CHANGED
@@ -21,12 +21,7 @@ module VagrantPlugins
|
|
21
21
|
DESCRIPTION
|
22
22
|
|
23
23
|
# Register the provider
|
24
|
-
|
25
|
-
# IDEA: UTM file comes as a zip file containing
|
26
|
-
# directory with Data/qcow2, Data/efi_vars.fd and config.plist
|
27
|
-
# Box format will only require additional metadata.json file
|
28
|
-
# Till then use UTM file directly and so box_optional: true
|
29
|
-
provider(:utm, box_optional: true, parallel: false) do
|
24
|
+
provider(:utm, box_optional: false, parallel: false) do
|
30
25
|
setup_i18n
|
31
26
|
require_relative "provider"
|
32
27
|
Provider
|
@@ -50,9 +45,17 @@ module VagrantPlugins
|
|
50
45
|
end
|
51
46
|
|
52
47
|
# Register the command
|
48
|
+
## Start machine as a snapshot and do not save changes to disk
|
53
49
|
command "disposable" do
|
54
|
-
require_relative "disposable"
|
55
|
-
|
50
|
+
require_relative "commands/disposable"
|
51
|
+
CommandDisposable
|
52
|
+
end
|
53
|
+
|
54
|
+
## Get the IP address of the machine
|
55
|
+
## Only supported if machine as qemu-guest-additions
|
56
|
+
command "ip-address" do
|
57
|
+
require_relative "commands/ip_address"
|
58
|
+
CommandIpAddress
|
56
59
|
end
|
57
60
|
|
58
61
|
# Load the translation files
|
data/lib/vagrant_utm/provider.rb
CHANGED
@@ -94,6 +94,8 @@ module VagrantPlugins
|
|
94
94
|
# If we have multiple network adapters, we need to pick the right one, read_guest_ip returns just first IP
|
95
95
|
# Also, since Vagrant by default adds port forwarding for ssh port 22,
|
96
96
|
# we might aswell use the forwarded ports to connect to the VM using the localhost.
|
97
|
+
# and the forwarded port.
|
98
|
+
# So we use 127.0.0.1 and the forwarded port to connect to the VM.
|
97
99
|
{
|
98
100
|
host: "127.0.0.1",
|
99
101
|
port: @driver.ssh_port(@machine.config.ssh.guest_port)
|
@@ -124,7 +126,6 @@ module VagrantPlugins
|
|
124
126
|
Vagrant::MachineState.new(state_id, short, long)
|
125
127
|
end
|
126
128
|
|
127
|
-
# TODO: Get UUID of the VM from UTM
|
128
129
|
# Returns a human-friendly string version of this provider which
|
129
130
|
# includes the machine's ID that this provider represents, if it
|
130
131
|
# has one.
|
@@ -5,7 +5,8 @@ on run argv
|
|
5
5
|
set config to configuration of vm
|
6
6
|
set networkInterfaces to network interfaces of config
|
7
7
|
repeat with anInterface in networkInterfaces
|
8
|
-
# if you start log with variable you'll get "," at the end of the log
|
8
|
+
# if you start log with variable you'll get "," at the end of the log so '&' is used to concatenate
|
9
|
+
# Example output: nic0,shared
|
9
10
|
log "nic" & index of anInterface & "," & mode of anInterface
|
10
11
|
end repeat
|
11
12
|
end tell
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This script sets the MAC address of a network interface in a specified UTM virtual machine.
|
2
|
+
# Usage: osascript set_mac_address.applescript <VM_UUID> <NIC_INDEX> <MAC_ADDRESS>
|
3
|
+
# Example: osascript set_mac_address.applescript A123 1 XX:XX:XX:XX:XX:XX
|
4
|
+
on run argv
|
5
|
+
set vmID to item 1 of argv
|
6
|
+
set nicIndex to item 2 of argv
|
7
|
+
set macAddress to item 3 of argv
|
8
|
+
|
9
|
+
tell application "UTM"
|
10
|
+
set vm to virtual machine id vmID
|
11
|
+
set config to configuration of vm
|
12
|
+
set networkInterfaces to network interfaces of config
|
13
|
+
|
14
|
+
repeat with anInterface in networkInterfaces
|
15
|
+
if nicIndex as integer is index of anInterface then
|
16
|
+
-- Set the provided MAC address
|
17
|
+
set address of anInterface to macAddress
|
18
|
+
end if
|
19
|
+
end repeat
|
20
|
+
|
21
|
+
-- Update the VM configuration
|
22
|
+
update configuration of vm with config
|
23
|
+
end tell
|
24
|
+
|
25
|
+
end run
|
data/lib/vagrant_utm/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -149,7 +149,15 @@ en:
|
|
149
149
|
WARNING: The UTM virtual machine is booting in disposable mode.
|
150
150
|
Changes made to the VM will be lost when the VM is powered off.
|
151
151
|
Learn more at https://docs.getutm.app/advanced/disposable/
|
152
|
+
ip_address:
|
153
|
+
reading: |-
|
154
|
+
Getting IP address of UTM virtual machine...
|
155
|
+
show: |-
|
156
|
+
Guest IP address(es):
|
157
|
+
not_found: |-
|
158
|
+
IP address not found. The VM may not have guest tools or may not have an IP address.
|
152
159
|
snapshot:
|
153
160
|
list: |-
|
154
161
|
Listing snapshots for UTM virtual machine...
|
162
|
+
|
155
163
|
|
data/notes/README.md
CHANGED
@@ -19,4 +19,12 @@ bundle exec jekyll serve
|
|
19
19
|
To release
|
20
20
|
|
21
21
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`
|
22
|
-
GitHub action upon tag push with "v*" will publish gem to GHR and rubygems
|
22
|
+
GitHub action upon tag push with "v*" will publish gem to GHR and rubygems
|
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
|
29
|
+
|
30
|
+
GHA will publish gems to GHR and rubygems
|
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.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2024-12-03 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:
|
@@ -68,9 +68,11 @@ files:
|
|
68
68
|
- lib/vagrant_utm/action/forced_halt.rb
|
69
69
|
- lib/vagrant_utm/action/forward_ports.rb
|
70
70
|
- lib/vagrant_utm/action/import.rb
|
71
|
+
- lib/vagrant_utm/action/ip_address.rb
|
71
72
|
- lib/vagrant_utm/action/is_paused.rb
|
72
73
|
- lib/vagrant_utm/action/is_running.rb
|
73
74
|
- lib/vagrant_utm/action/is_stopped.rb
|
75
|
+
- lib/vagrant_utm/action/match_mac_address.rb
|
74
76
|
- lib/vagrant_utm/action/message_already_running.rb
|
75
77
|
- lib/vagrant_utm/action/message_not_created.rb
|
76
78
|
- lib/vagrant_utm/action/message_not_running.rb
|
@@ -91,8 +93,9 @@ files:
|
|
91
93
|
- lib/vagrant_utm/action/suspend.rb
|
92
94
|
- lib/vagrant_utm/action/wait_for_running.rb
|
93
95
|
- lib/vagrant_utm/cap.rb
|
96
|
+
- lib/vagrant_utm/commands/disposable.rb
|
97
|
+
- lib/vagrant_utm/commands/ip_address.rb
|
94
98
|
- lib/vagrant_utm/config.rb
|
95
|
-
- lib/vagrant_utm/disposable.rb
|
96
99
|
- lib/vagrant_utm/driver/base.rb
|
97
100
|
- lib/vagrant_utm/driver/meta.rb
|
98
101
|
- lib/vagrant_utm/driver/version_4_5.rb
|
@@ -111,8 +114,8 @@ files:
|
|
111
114
|
- lib/vagrant_utm/scripts/list_vm.js
|
112
115
|
- lib/vagrant_utm/scripts/open_with_utm.js
|
113
116
|
- lib/vagrant_utm/scripts/read_forwarded_ports.applescript
|
114
|
-
- lib/vagrant_utm/scripts/read_guest_ip.applescript
|
115
117
|
- lib/vagrant_utm/scripts/read_network_interfaces.applescript
|
118
|
+
- lib/vagrant_utm/scripts/set_mac_address.applescript
|
116
119
|
- lib/vagrant_utm/util/compile_forwarded_ports.rb
|
117
120
|
- lib/vagrant_utm/version.rb
|
118
121
|
- locales/en.yml
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module Utm
|
5
|
-
# Run VM as a snapshot and do not save changes to disk.
|
6
|
-
class Disposable < Vagrant.plugin(2, :command)
|
7
|
-
def execute
|
8
|
-
with_target_vms do |machine|
|
9
|
-
machine.action(:start_disposable)
|
10
|
-
end
|
11
|
-
|
12
|
-
0
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|