vagrant-veertu 0.0.12
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 +7 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +5 -0
- data/lib/vagrant-veertu.rb +18 -0
- data/lib/vagrant-veertu/action.rb +330 -0
- data/lib/vagrant-veertu/action/boot.rb +21 -0
- data/lib/vagrant-veertu/action/check_accessible.rb +22 -0
- data/lib/vagrant-veertu/action/check_created.rb +21 -0
- data/lib/vagrant-veertu/action/check_running.rb +21 -0
- data/lib/vagrant-veertu/action/check_veertu.rb +22 -0
- data/lib/vagrant-veertu/action/clear_forwarded_ports.rb +20 -0
- data/lib/vagrant-veertu/action/clear_network_interfaces.rb +31 -0
- data/lib/vagrant-veertu/action/created.rb +20 -0
- data/lib/vagrant-veertu/action/customize.rb +44 -0
- data/lib/vagrant-veertu/action/destroy.rb +19 -0
- data/lib/vagrant-veertu/action/discard_state.rb +20 -0
- data/lib/vagrant-veertu/action/export.rb +41 -0
- data/lib/vagrant-veertu/action/forced_halt.rb +25 -0
- data/lib/vagrant-veertu/action/forward_ports.rb +91 -0
- data/lib/vagrant-veertu/action/import.rb +96 -0
- data/lib/vagrant-veertu/action/is_paused.rb +20 -0
- data/lib/vagrant-veertu/action/is_running.rb +20 -0
- data/lib/vagrant-veertu/action/is_saved.rb +20 -0
- data/lib/vagrant-veertu/action/message_already_running.rb +16 -0
- data/lib/vagrant-veertu/action/message_not_created.rb +16 -0
- data/lib/vagrant-veertu/action/message_not_running.rb +16 -0
- data/lib/vagrant-veertu/action/message_will_not_destroy.rb +17 -0
- data/lib/vagrant-veertu/action/network.rb +556 -0
- data/lib/vagrant-veertu/action/network_fix_ipv6.rb +81 -0
- data/lib/vagrant-veertu/action/package.rb +44 -0
- data/lib/vagrant-veertu/action/package_vagrantfile.rb +33 -0
- data/lib/vagrant-veertu/action/prepare_forwarded_port_collision_params.rb +35 -0
- data/lib/vagrant-veertu/action/prepare_nfs_settings.rb +119 -0
- data/lib/vagrant-veertu/action/prepare_nfs_valid_ids.rb +17 -0
- data/lib/vagrant-veertu/action/resume.rb +21 -0
- data/lib/vagrant-veertu/action/sane_defaults.rb +89 -0
- data/lib/vagrant-veertu/action/set_name.rb +55 -0
- data/lib/vagrant-veertu/action/setup_package_files.rb +51 -0
- data/lib/vagrant-veertu/action/snapshot_delete.rb +32 -0
- data/lib/vagrant-veertu/action/snapshot_restore.rb +28 -0
- data/lib/vagrant-veertu/action/snapshot_save.rb +25 -0
- data/lib/vagrant-veertu/action/suspend.rb +20 -0
- data/lib/vagrant-veertu/cap.rb +23 -0
- data/lib/vagrant-veertu/cap/public_address.rb +15 -0
- data/lib/vagrant-veertu/config.rb +199 -0
- data/lib/vagrant-veertu/driver/base.rb +240 -0
- data/lib/vagrant-veertu/driver/meta.rb +143 -0
- data/lib/vagrant-veertu/driver/version_5_0.rb +284 -0
- data/lib/vagrant-veertu/errors.rb +18 -0
- data/lib/vagrant-veertu/model/forwarded_port.rb +70 -0
- data/lib/vagrant-veertu/plugin.rb +76 -0
- data/lib/vagrant-veertu/provider.rb +121 -0
- data/lib/vagrant-veertu/synced_folder.rb +120 -0
- data/lib/vagrant-veertu/util/compile_forwarded_ports.rb +35 -0
- data/lib/vagrant-veertu/version.rb +5 -0
- data/locales/en.yml +19 -0
- data/vagrant-veertu.gemspec +22 -0
- metadata +130 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module ProviderVeertu
|
5
|
+
module Action
|
6
|
+
class SetName
|
7
|
+
def initialize(app, env)
|
8
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::setname")
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
name = env[:machine].provider_config.name
|
14
|
+
|
15
|
+
# If we already set the name before, then don't do anything
|
16
|
+
sentinel = env[:machine].data_dir.join("action_set_name")
|
17
|
+
if !name && sentinel.file?
|
18
|
+
@logger.info("Default name was already set before, not doing it again.")
|
19
|
+
return @app.call(env)
|
20
|
+
end
|
21
|
+
|
22
|
+
# If no name was manually set, then use a default
|
23
|
+
if !name
|
24
|
+
prefix = "#{env[:root_path].basename.to_s}_#{env[:machine].name}"
|
25
|
+
prefix.gsub!(/[^-a-z0-9_]/i, "")
|
26
|
+
|
27
|
+
# milliseconds + random number suffix to allow for simultaneous
|
28
|
+
# `vagrant up` of the same box in different dirs
|
29
|
+
name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Verify the name is not taken
|
33
|
+
vms = env[:machine].provider.driver.read_vms
|
34
|
+
raise Vagrant::Errors::VMNameExists, name: name if \
|
35
|
+
vms.key?(name) && vms[name] != env[:machine].id
|
36
|
+
|
37
|
+
if vms.key?(name)
|
38
|
+
@logger.info("Not setting the name because our name is already set.")
|
39
|
+
else
|
40
|
+
env[:ui].info(I18n.t(
|
41
|
+
"vagrant.actions.vm.set_name.setting_name", name: name))
|
42
|
+
env[:machine].provider.driver.set_name(name)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create the sentinel
|
46
|
+
sentinel.open("w") do |f|
|
47
|
+
f.write(Time.now.to_i.to_s)
|
48
|
+
end
|
49
|
+
|
50
|
+
@app.call(env)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Action
|
4
|
+
class SetupPackageFiles
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
|
8
|
+
env["package.include"] ||= []
|
9
|
+
env["package.vagrantfile"] ||= nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
files = {}
|
14
|
+
env["package.include"].each do |file|
|
15
|
+
source = Pathname.new(file)
|
16
|
+
dest = nil
|
17
|
+
|
18
|
+
# If the source is relative then we add the file as-is to the include
|
19
|
+
# directory. Otherwise, we copy only the file into the root of the
|
20
|
+
# include directory. Kind of strange, but seems to match what people
|
21
|
+
# expect based on history.
|
22
|
+
if source.relative?
|
23
|
+
dest = source
|
24
|
+
else
|
25
|
+
dest = source.basename
|
26
|
+
end
|
27
|
+
|
28
|
+
# Assign the mapping
|
29
|
+
files[file] = dest
|
30
|
+
end
|
31
|
+
|
32
|
+
if env["package.vagrantfile"]
|
33
|
+
# Vagrantfiles are treated special and mapped to a specific file
|
34
|
+
files[env["package.vagrantfile"]] = "_Vagrantfile"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Verify the mapping
|
38
|
+
files.each do |from, _|
|
39
|
+
raise Vagrant::Errors::PackageIncludeMissing,
|
40
|
+
file: from if !File.exist?(from)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Save the mapping
|
44
|
+
env["package.files"] = files
|
45
|
+
|
46
|
+
@app.call(env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Action
|
4
|
+
class SnapshotDelete
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t(
|
11
|
+
"vagrant.actions.vm.snapshot.deleting",
|
12
|
+
name: env[:snapshot_name]))
|
13
|
+
env[:machine].provider.driver.delete_snapshot(
|
14
|
+
env[:machine].id, env[:snapshot_name]) do |progress|
|
15
|
+
env[:ui].clear_line
|
16
|
+
env[:ui].report_progress(progress, 100, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Clear the line one last time since the progress meter doesn't disappear
|
20
|
+
# immediately.
|
21
|
+
env[:ui].clear_line
|
22
|
+
|
23
|
+
env[:ui].success(I18n.t(
|
24
|
+
"vagrant.actions.vm.snapshot.deleted",
|
25
|
+
name: env[:snapshot_name]))
|
26
|
+
|
27
|
+
@app.call(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Action
|
4
|
+
class SnapshotRestore
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t(
|
11
|
+
"vagrant.actions.vm.snapshot.restoring",
|
12
|
+
name: env[:snapshot_name]))
|
13
|
+
env[:machine].provider.driver.restore_snapshot(
|
14
|
+
env[:machine].id, env[:snapshot_name]) do |progress|
|
15
|
+
env[:ui].clear_line
|
16
|
+
env[:ui].report_progress(progress, 100, false)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Clear the line one last time since the progress meter doesn't disappear
|
20
|
+
# immediately.
|
21
|
+
env[:ui].clear_line
|
22
|
+
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Action
|
4
|
+
class SnapshotSave
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env[:ui].info(I18n.t(
|
11
|
+
"vagrant.actions.vm.snapshot.saving",
|
12
|
+
name: env[:snapshot_name]))
|
13
|
+
env[:machine].provider.driver.create_snapshot(
|
14
|
+
env[:machine].id, env[:snapshot_name])
|
15
|
+
|
16
|
+
env[:ui].success(I18n.t(
|
17
|
+
"vagrant.actions.vm.snapshot.saved",
|
18
|
+
name: env[:snapshot_name]))
|
19
|
+
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Action
|
4
|
+
class Suspend
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
if env[:machine].state.id == :running
|
11
|
+
env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending")
|
12
|
+
env[:machine].provider.driver.suspend
|
13
|
+
end
|
14
|
+
|
15
|
+
@app.call(env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Cap
|
4
|
+
# Reads the forwarded ports that currently exist on the machine
|
5
|
+
# itself. This raises an exception if the machine isn't running.
|
6
|
+
#
|
7
|
+
# This also may not match up with configured forwarded ports, because
|
8
|
+
# Vagrant auto port collision fixing may have taken place.
|
9
|
+
#
|
10
|
+
# @return [Hash<Integer, Integer>] Host => Guest port mappings.
|
11
|
+
def self.forwarded_ports(machine)
|
12
|
+
return nil if machine.state.id != :running
|
13
|
+
|
14
|
+
{}.tap do |result|
|
15
|
+
machine.provider.driver.read_forwarded_ports.each do |_, _, h, g|
|
16
|
+
result[h] = g
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
module Cap
|
4
|
+
module PublicAddress
|
5
|
+
def self.public_address(machine)
|
6
|
+
return nil if machine.state.id != :running
|
7
|
+
|
8
|
+
ssh_info = machine.ssh_info
|
9
|
+
return nil if !ssh_info
|
10
|
+
ssh_info[:host]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module ProviderVeertu
|
3
|
+
class Config < Vagrant.plugin("2", :config)
|
4
|
+
|
5
|
+
# Vagrant by default will make "smart" decisions to enable/disable
|
6
|
+
# the NAT DNS proxy. If this is set to `true`, then the DNS proxy
|
7
|
+
# will not be enabled, and it is up to the end user to do it.
|
8
|
+
#
|
9
|
+
# @return [Boolean]
|
10
|
+
attr_accessor :auto_nat_dns_proxy
|
11
|
+
|
12
|
+
# If true, will check if guest additions are installed and up to
|
13
|
+
# date. By default, this is true.
|
14
|
+
#
|
15
|
+
# @return [Boolean]
|
16
|
+
attr_accessor :check_guest_additions
|
17
|
+
|
18
|
+
# An array of customizations to make on the VM prior to booting it.
|
19
|
+
#
|
20
|
+
# @return [Array]
|
21
|
+
attr_reader :customizations
|
22
|
+
|
23
|
+
# If true, unused network interfaces will automatically be deleted.
|
24
|
+
# This defaults to false because the detection does not work across
|
25
|
+
# multiple users, and because on Windows this operation requires
|
26
|
+
# administrative privileges.
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
attr_accessor :destroy_unused_network_interfaces
|
30
|
+
|
31
|
+
# If set to `true`, then VirtualBox will be launched with a GUI.
|
32
|
+
#
|
33
|
+
# @return [Boolean]
|
34
|
+
attr_accessor :gui
|
35
|
+
|
36
|
+
# If set to `true`, then a linked clone is created from a master
|
37
|
+
# VM generated from the specified box.
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
attr_accessor :linked_clone
|
41
|
+
|
42
|
+
# The snapshot to base the linked clone from. If this isn't set
|
43
|
+
# a snapshot will be made with the name of "base" which will be used.
|
44
|
+
#
|
45
|
+
# If this is set, then the snapshot must already exist.
|
46
|
+
#
|
47
|
+
# @return [String]
|
48
|
+
attr_accessor :linked_clone_snapshot
|
49
|
+
|
50
|
+
# This should be set to the name of the machine in the VirtualBox
|
51
|
+
# GUI.
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
attr_accessor :name
|
55
|
+
|
56
|
+
# Whether or not this VM has a functional vboxsf filesystem module.
|
57
|
+
# This defaults to true. If you set this to false, then the "virtualbox"
|
58
|
+
# synced folder type won't be valid.
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
attr_accessor :functional_vboxsf
|
62
|
+
|
63
|
+
# The defined network adapters.
|
64
|
+
#
|
65
|
+
# @return [Hash]
|
66
|
+
attr_reader :network_adapters
|
67
|
+
|
68
|
+
def initialize
|
69
|
+
@auto_nat_dns_proxy = UNSET_VALUE
|
70
|
+
@check_guest_additions = UNSET_VALUE
|
71
|
+
@customizations = []
|
72
|
+
@destroy_unused_network_interfaces = UNSET_VALUE
|
73
|
+
@functional_vboxsf = false
|
74
|
+
@name = UNSET_VALUE
|
75
|
+
@network_adapters = {}
|
76
|
+
@gui = UNSET_VALUE
|
77
|
+
@linked_clone = UNSET_VALUE
|
78
|
+
@linked_clone_snapshot = UNSET_VALUE
|
79
|
+
|
80
|
+
# We require that network adapter 1 is a NAT device.
|
81
|
+
network_adapter(1, :nat)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Customize the VM by calling `VeertuManage` with the given
|
85
|
+
# arguments.
|
86
|
+
#
|
87
|
+
# When called multiple times, the customizations will be applied
|
88
|
+
# in the order given.
|
89
|
+
#
|
90
|
+
# The special `:name` parameter in the command will be replaced with
|
91
|
+
# the unique ID or name of the virtual machine. This is useful for
|
92
|
+
# parameters to `modifyvm` and the like.
|
93
|
+
#
|
94
|
+
# @param [Array] command An array of arguments to pass to
|
95
|
+
# VeertuManage.
|
96
|
+
def customize(*command)
|
97
|
+
event = command.first.is_a?(String) ? command.shift : "pre-boot"
|
98
|
+
command = command[0]
|
99
|
+
@customizations << [event, command]
|
100
|
+
end
|
101
|
+
|
102
|
+
# This defines a network adapter that will be added to the VirtualBox
|
103
|
+
# virtual machine in the given slot.
|
104
|
+
#
|
105
|
+
# @param [Integer] slot The slot for this network adapter.
|
106
|
+
# @param [Symbol] type The type of adapter.
|
107
|
+
def network_adapter(slot, type, **opts)
|
108
|
+
@network_adapters[slot] = [type, opts]
|
109
|
+
end
|
110
|
+
|
111
|
+
# Shortcut for setting memory size for the virtual machine.
|
112
|
+
# Calls #customize internally.
|
113
|
+
#
|
114
|
+
# @param size [Integer, String] the memory size in MB
|
115
|
+
def memory=(size)
|
116
|
+
customize("pre-boot", ["modifyvm", :id, "--memory", size.to_s])
|
117
|
+
end
|
118
|
+
|
119
|
+
# Shortcut for setting CPU count for the virtual machine.
|
120
|
+
# Calls #customize internally.
|
121
|
+
#
|
122
|
+
# @param count [Integer, String] the count of CPUs
|
123
|
+
def cpus=(count)
|
124
|
+
customize("pre-boot", ["modifyvm", :id, "--cpus", count.to_i])
|
125
|
+
end
|
126
|
+
|
127
|
+
def merge(other)
|
128
|
+
super.tap do |result|
|
129
|
+
c = customizations.dup
|
130
|
+
c += other.customizations
|
131
|
+
result.instance_variable_set(:@customizations, c)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# This is the hook that is called to finalize the object before it
|
136
|
+
# is put into use.
|
137
|
+
def finalize!
|
138
|
+
# Default is to auto the DNS proxy
|
139
|
+
@auto_nat_dns_proxy = true if @auto_nat_dns_proxy == UNSET_VALUE
|
140
|
+
|
141
|
+
if @check_guest_additions == UNSET_VALUE
|
142
|
+
@check_guest_additions = true
|
143
|
+
end
|
144
|
+
|
145
|
+
if @destroy_unused_network_interfaces == UNSET_VALUE
|
146
|
+
@destroy_unused_network_interfaces = false
|
147
|
+
end
|
148
|
+
|
149
|
+
if @functional_vboxsf == UNSET_VALUE
|
150
|
+
@functional_vboxsf = true
|
151
|
+
end
|
152
|
+
|
153
|
+
# Default is to not show a GUI
|
154
|
+
@gui = false if @gui == UNSET_VALUE
|
155
|
+
|
156
|
+
# Do not create linked clone by default
|
157
|
+
@linked_clone = false if @linked_clone == UNSET_VALUE
|
158
|
+
@linked_clone_snapshot = nil if @linked_clone_snapshot == UNSET_VALUE
|
159
|
+
|
160
|
+
# The default name is just nothing, and we default it
|
161
|
+
@name = nil if @name == UNSET_VALUE
|
162
|
+
end
|
163
|
+
|
164
|
+
def validate(machine)
|
165
|
+
errors = _detected_errors
|
166
|
+
|
167
|
+
valid_events = ["pre-import", "pre-boot", "post-boot", "post-comm"]
|
168
|
+
@customizations.each do |event, _|
|
169
|
+
if !valid_events.include?(event)
|
170
|
+
errors << I18n.t(
|
171
|
+
"vagrant.virtualbox.config.invalid_event",
|
172
|
+
event: event.to_s,
|
173
|
+
valid_events: valid_events.join(", "))
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
@customizations.each do |event, command|
|
178
|
+
if event == "pre-import" && command.index(:id)
|
179
|
+
errors << I18n.t("vagrant.virtualbox.config.id_in_pre_import")
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Verify that internal networks are only on private networks.
|
184
|
+
machine.config.vm.networks.each do |type, data|
|
185
|
+
if data[:veertu__intnet] && type != :private_network
|
186
|
+
errors << I18n.t("vagrant.virtualbox.config.intnet_on_bad_type")
|
187
|
+
break
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
{ "VirtualBox Provider" => errors }
|
192
|
+
end
|
193
|
+
|
194
|
+
def to_s
|
195
|
+
"VirtualBox"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|