vagrant-vz 0.1.0

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.
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+
5
+ module VagrantPlugins
6
+ module VZ
7
+ # Builds the vfkit command line. Kept free of Vagrant so it can be tested
8
+ # on its own.
9
+ module VfkitCommand
10
+ module_function
11
+
12
+ # Virtualization.framework limits virtio-fs tags to 36 bytes, so tags
13
+ # are derived from a hash of the synced folder id.
14
+ def mount_tag(folder_id)
15
+ "vagrant-#{Digest::SHA1.hexdigest(folder_id.to_s)[0, 16]}"
16
+ end
17
+
18
+ # opts:
19
+ # :vfkit, :cpus, :memory, :efi_store, :disks, :mac, :rest_socket,
20
+ # :console_log, :shares ([{tag:, path:}]), :rosetta (tag or nil),
21
+ # :gui (bool), :extra_args
22
+ def build(opts)
23
+ efi_store = opts.fetch(:efi_store).to_s
24
+ args = [
25
+ opts.fetch(:vfkit),
26
+ "--cpus", opts.fetch(:cpus).to_s,
27
+ "--memory", opts.fetch(:memory).to_s,
28
+ "--bootloader", "efi,variable-store=#{safe(efi_store)}#{",create" unless File.exist?(efi_store)}",
29
+ "--restful-uri", "unix://#{opts.fetch(:rest_socket)}"
30
+ ]
31
+
32
+ Array(opts.fetch(:disks)).each do |disk|
33
+ args += ["--device", "virtio-blk,path=#{safe(disk)}"]
34
+ end
35
+
36
+ args += ["--device", "virtio-net,nat,mac=#{opts.fetch(:mac)}"]
37
+ args += ["--device", "virtio-rng"]
38
+ if opts[:console_log]
39
+ args += ["--device", "virtio-serial,logFilePath=#{safe(opts[:console_log])}"]
40
+ end
41
+
42
+ Array(opts[:shares]).each do |share|
43
+ args += ["--device", "virtio-fs,sharedDir=#{safe(share[:path])},mountTag=#{share[:tag]}"]
44
+ end
45
+
46
+ args += ["--device", "rosetta,mountTag=#{opts[:rosetta]}"] if opts[:rosetta]
47
+
48
+ if opts[:gui]
49
+ args += [
50
+ "--gui",
51
+ "--device", "virtio-gpu,width=1280,height=800",
52
+ "--device", "virtio-input,keyboard",
53
+ "--device", "virtio-input,pointing"
54
+ ]
55
+ end
56
+
57
+ args + Array(opts[:extra_args])
58
+ end
59
+
60
+ # vfkit separates device options with commas, so a path containing one
61
+ # cannot be expressed.
62
+ def safe(path)
63
+ path = path.to_s
64
+ raise ArgumentError, "vfkit cannot use paths containing a comma: #{path}" if path.include?(",")
65
+
66
+ path
67
+ end
68
+ end
69
+ end
70
+ end
data/lib/vagrant-vz.rb ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module VagrantPlugins
6
+ module VZ
7
+ lib_path = Pathname.new(File.expand_path("vagrant-vz", __dir__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # Root of the gem, used to find the locale files.
12
+ def self.source_root
13
+ @source_root ||= Pathname.new(File.expand_path("..", __dir__))
14
+ end
15
+ end
16
+ end
17
+
18
+ begin
19
+ require "vagrant"
20
+ rescue LoadError
21
+ raise "The vagrant-vz plugin must be run within Vagrant."
22
+ end
23
+
24
+ require "vagrant-vz/plugin"
data/locales/en.yml ADDED
@@ -0,0 +1,64 @@
1
+ en:
2
+ vagrant_vz:
3
+ already_running: "The machine is already running."
4
+ already_stopped: "The machine is already stopped."
5
+ not_created: "The machine is not created. Run `vagrant up` first."
6
+ not_running: "The machine is not running. Run `vagrant up` to start it."
7
+ will_not_destroy: "The machine will not be destroyed, since the confirmation was declined."
8
+ importing: "Importing box '%{name}' (%{provider} format)..."
9
+ importing_disk: "%{src} (%{disk_format}) -> raw"
10
+ disk_grown: "Boot disk grown to %{size} GiB."
11
+ disk_not_shrunk: "vz.disk_size (%{size} GiB) is smaller than the disk; disks are never shrunk."
12
+ booting: "Booting VM with vfkit (%{cpus} CPUs, %{memory} MiB)..."
13
+ waiting_for_ip: "Waiting for the VM to get an IP address and start SSH..."
14
+ ip_found: "IP address: %{ip}"
15
+ force_halting: "Stopping the VM..."
16
+ destroying: "Deleting the VM's disks and state..."
17
+ mounting_folders: "Mounting virtiofs shared folders..."
18
+
19
+ states:
20
+ short_not_created: "not created"
21
+ long_not_created: |-
22
+ The machine has not been created. Run `vagrant up` to create it.
23
+ short_running: "running"
24
+ long_running: |-
25
+ The VM is running. Use `vagrant halt` to stop it.
26
+ short_stopped: "stopped"
27
+ long_stopped: |-
28
+ The VM is stopped. Run `vagrant up` to start it.
29
+ short_paused: "paused"
30
+ long_paused: |-
31
+ The VM is paused.
32
+ short_error: "error"
33
+ long_error: |-
34
+ Virtualization.framework reports an error state. See vfkit.log in the
35
+ machine's .vagrant directory.
36
+
37
+ errors:
38
+ unsupported_host: |-
39
+ The vz provider only runs on macOS hosts.
40
+ vfkit_not_found: |-
41
+ vfkit was not found (looked for '%{path}'). Install it with
42
+
43
+ brew install vfkit
44
+
45
+ or set `vz.vfkit_path` in your Vagrantfile.
46
+ vfkit_start_failed: |-
47
+ vfkit failed to start the VM. Last lines of vfkit.log:
48
+
49
+ %{log}
50
+ qemu_img_not_found: |-
51
+ The box disk is in %{disk_format} format and must be converted to raw, but
52
+ qemu-img was not found (looked for '%{path}'). Install it with
53
+
54
+ brew install qemu
55
+
56
+ or set `vz.qemu_img_path` in your Vagrantfile.
57
+ box_disk_not_found: |-
58
+ No disk image was found in the box at %{path}.
59
+ disk_import_failed: |-
60
+ Importing the box disk failed: %{message}
61
+ ip_not_found: |-
62
+ No address for the VM (MAC %{mac}) accepted SSH connections within
63
+ %{timeout}s. Check that the guest runs DHCP on its network interface
64
+ and that sshd is enabled. The serial console output is in %{console}.
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joaquin Menchaca
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Runs Vagrant machines on macOS through Apple's Virtualization.framework
13
+ (VZ), driven by the vfkit command-line hypervisor.
14
+ executables: []
15
+ extensions: []
16
+ extra_rdoc_files: []
17
+ files:
18
+ - LICENSE
19
+ - README.md
20
+ - lib/vagrant-vz.rb
21
+ - lib/vagrant-vz/action.rb
22
+ - lib/vagrant-vz/action/boot.rb
23
+ - lib/vagrant-vz/action/destroy.rb
24
+ - lib/vagrant-vz/action/force_halt.rb
25
+ - lib/vagrant-vz/action/import.rb
26
+ - lib/vagrant-vz/action/resize_disk.rb
27
+ - lib/vagrant-vz/action/wait_for_ip.rb
28
+ - lib/vagrant-vz/config.rb
29
+ - lib/vagrant-vz/dhcp_leases.rb
30
+ - lib/vagrant-vz/disk_image.rb
31
+ - lib/vagrant-vz/driver.rb
32
+ - lib/vagrant-vz/errors.rb
33
+ - lib/vagrant-vz/plugin.rb
34
+ - lib/vagrant-vz/provider.rb
35
+ - lib/vagrant-vz/synced_folder.rb
36
+ - lib/vagrant-vz/version.rb
37
+ - lib/vagrant-vz/vfkit_command.rb
38
+ - locales/en.yml
39
+ homepage: https://github.com/darkn3rd/vagrant-vz
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '3.0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 4.0.23
58
+ specification_version: 4
59
+ summary: Vagrant provider for Apple Virtualization.framework using vfkit
60
+ test_files: []