vagrant-vmware-desktop 0.0.1 → 3.0.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.
- checksums.yaml +4 -4
- data/lib/vagrant-vmware-desktop.rb +190 -0
- data/lib/vagrant-vmware-desktop/action.rb +442 -0
- data/lib/vagrant-vmware-desktop/action/base_mac_to_ip.rb +55 -0
- data/lib/vagrant-vmware-desktop/action/boot.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/check_existing_network.rb +35 -0
- data/lib/vagrant-vmware-desktop/action/check_vmware.rb +28 -0
- data/lib/vagrant-vmware-desktop/action/checkpoint.rb +86 -0
- data/lib/vagrant-vmware-desktop/action/clear_shared_folders.rb +25 -0
- data/lib/vagrant-vmware-desktop/action/common.rb +16 -0
- data/lib/vagrant-vmware-desktop/action/compatibility.rb +36 -0
- data/lib/vagrant-vmware-desktop/action/created.rb +20 -0
- data/lib/vagrant-vmware-desktop/action/destroy.rb +32 -0
- data/lib/vagrant-vmware-desktop/action/discard_suspended_state.rb +32 -0
- data/lib/vagrant-vmware-desktop/action/export.rb +29 -0
- data/lib/vagrant-vmware-desktop/action/fix_old_machine_id.rb +29 -0
- data/lib/vagrant-vmware-desktop/action/forward_ports.rb +110 -0
- data/lib/vagrant-vmware-desktop/action/halt.rb +27 -0
- data/lib/vagrant-vmware-desktop/action/import.rb +138 -0
- data/lib/vagrant-vmware-desktop/action/machine_lock.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/message_already_running.rb +18 -0
- data/lib/vagrant-vmware-desktop/action/message_not_created.rb +18 -0
- data/lib/vagrant-vmware-desktop/action/message_not_running.rb +18 -0
- data/lib/vagrant-vmware-desktop/action/network.rb +339 -0
- data/lib/vagrant-vmware-desktop/action/package_vagrantfile.rb +46 -0
- data/lib/vagrant-vmware-desktop/action/prepare_forwarded_port_collision_params.rb +28 -0
- data/lib/vagrant-vmware-desktop/action/prepare_nfs_settings.rb +43 -0
- data/lib/vagrant-vmware-desktop/action/prepare_synced_folder_cleanup.rb +19 -0
- data/lib/vagrant-vmware-desktop/action/prune_forwarded_ports.rb +30 -0
- data/lib/vagrant-vmware-desktop/action/prune_nfs_exports.rb +22 -0
- data/lib/vagrant-vmware-desktop/action/running.rb +20 -0
- data/lib/vagrant-vmware-desktop/action/set_display_name.rb +37 -0
- data/lib/vagrant-vmware-desktop/action/share_folders.rb +97 -0
- data/lib/vagrant-vmware-desktop/action/snapshot_delete.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/snapshot_restore.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/snapshot_save.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/suspend.rb +26 -0
- data/lib/vagrant-vmware-desktop/action/suspended.rb +24 -0
- data/lib/vagrant-vmware-desktop/action/vmx_modify.rb +39 -0
- data/lib/vagrant-vmware-desktop/action/wait_for_address.rb +31 -0
- data/lib/vagrant-vmware-desktop/action/wait_for_communicator_compat.rb +32 -0
- data/lib/vagrant-vmware-desktop/action/wait_for_vmx_halt.rb +35 -0
- data/lib/vagrant-vmware-desktop/cap/disk.rb +287 -0
- data/lib/vagrant-vmware-desktop/cap/provider.rb +37 -0
- data/lib/vagrant-vmware-desktop/cap/snapshot.rb +41 -0
- data/lib/vagrant-vmware-desktop/checkpoint_client.rb +203 -0
- data/lib/vagrant-vmware-desktop/config.rb +377 -0
- data/lib/vagrant-vmware-desktop/constants.rb +16 -0
- data/lib/vagrant-vmware-desktop/driver.rb +15 -0
- data/lib/vagrant-vmware-desktop/driver/base.rb +1356 -0
- data/lib/vagrant-vmware-desktop/errors.rb +342 -0
- data/lib/vagrant-vmware-desktop/guest_cap/linux/mount_vmware_shared_folder.rb +158 -0
- data/lib/vagrant-vmware-desktop/guest_cap/linux/verify_vmware_hgfs.rb +27 -0
- data/lib/vagrant-vmware-desktop/helper/lock.rb +26 -0
- data/lib/vagrant-vmware-desktop/helper/routing_table.rb +182 -0
- data/lib/vagrant-vmware-desktop/helper/vagrant_utility.rb +185 -0
- data/lib/vagrant-vmware-desktop/plugin.rb +148 -0
- data/lib/vagrant-vmware-desktop/provider.rb +96 -0
- data/lib/vagrant-vmware-desktop/setup_plugin.rb +24 -0
- data/lib/vagrant-vmware-desktop/synced_folder.rb +93 -0
- data/locales/en.yml +634 -0
- metadata +71 -17
@@ -0,0 +1,27 @@
|
|
1
|
+
module HashiCorp
|
2
|
+
module VagrantVMwareDesktop
|
3
|
+
module GuestCap
|
4
|
+
module Linux
|
5
|
+
class VerifyVMwareHGFS
|
6
|
+
def self.verify_vmware_hgfs(machine)
|
7
|
+
# Retry a few times since some systems take time to load
|
8
|
+
# the VMware kernel modules.
|
9
|
+
8.times do |i|
|
10
|
+
# Kernel module
|
11
|
+
return true if machine.communicate.test(
|
12
|
+
"PATH=\"/sbin:$PATH\" lsmod | grep -i '^vmhgfs'")
|
13
|
+
|
14
|
+
# open-vm-tools (FUSE filesystem)
|
15
|
+
return true if machine.communicate.test(
|
16
|
+
"command -v vmhgfs-fuse")
|
17
|
+
|
18
|
+
sleep(2 ** i)
|
19
|
+
end
|
20
|
+
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HashiCorp
|
2
|
+
module VagrantVMwareDesktop
|
3
|
+
module Helper
|
4
|
+
# The Lock module implements some locking primitives for parallelism
|
5
|
+
# that respect the Vagrant version that is available.
|
6
|
+
module Lock
|
7
|
+
def self.lock(machine, name, **opts, &block)
|
8
|
+
# Before version 1.6, we don't have any sort of locking
|
9
|
+
return block.call if Vagrant::VERSION < "1.6.0"
|
10
|
+
|
11
|
+
# Set some defaults
|
12
|
+
opts = { retry: true }.merge(opts)
|
13
|
+
|
14
|
+
# Lock the environment and yield it.
|
15
|
+
begin
|
16
|
+
return machine.env.lock(name, &block)
|
17
|
+
rescue Vagrant::Errors::EnvironmentLockedError
|
18
|
+
raise if !opts[:retry]
|
19
|
+
sleep 1
|
20
|
+
retry
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require "ipaddr"
|
2
|
+
|
3
|
+
require "vagrant/util/platform"
|
4
|
+
require "vagrant/util/subprocess"
|
5
|
+
require "vagrant/util/which"
|
6
|
+
|
7
|
+
require "vagrant-vmware-desktop/errors"
|
8
|
+
|
9
|
+
module HashiCorp
|
10
|
+
module VagrantVMwareDesktop
|
11
|
+
module Helper
|
12
|
+
# This class reads the TCP/IP routing table for the current host.
|
13
|
+
# On Mac OS X and Linux machines, `netstat` is used. Windows is
|
14
|
+
# not currently implemented, but similar applications are installed
|
15
|
+
# by default.
|
16
|
+
class RoutingTable
|
17
|
+
def initialize
|
18
|
+
if Vagrant::Util::Platform.darwin?
|
19
|
+
@table = read_table_darwin
|
20
|
+
elsif Vagrant::Util::Platform.linux?
|
21
|
+
@table = read_table_linux
|
22
|
+
elsif Vagrant::Util::Platform.windows?
|
23
|
+
@table = read_table_windows
|
24
|
+
else
|
25
|
+
raise Errors::RoutingTableUnsupportedOS
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# This will return the device that the given IP would be routed
|
30
|
+
# to, or `nil` if it would just route to the default route.
|
31
|
+
#
|
32
|
+
# @param [String] ip The IP address.
|
33
|
+
def device_for_route(ip)
|
34
|
+
return @table[ip] if @table.has_key?(ip)
|
35
|
+
|
36
|
+
smallest = nil
|
37
|
+
smallest_size = nil
|
38
|
+
@table.each do |destination, interface|
|
39
|
+
if destination.include?(IPAddr.new(ip))
|
40
|
+
# Ruby 2.0 adds a "size" operator to Range, which we should
|
41
|
+
# use when we switch to it.
|
42
|
+
ip_range = destination.to_range
|
43
|
+
ip_size = ip_range.max.to_i - ip_range.min.to_i
|
44
|
+
if smallest_size.nil? || ip_size < smallest_size
|
45
|
+
smallest = interface
|
46
|
+
smallest_size = ip_size
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
smallest
|
52
|
+
end
|
53
|
+
|
54
|
+
protected
|
55
|
+
|
56
|
+
def read_table_darwin
|
57
|
+
netstat_path = Vagrant::Util::Which.which("netstat")
|
58
|
+
raise Errors::RoutingTableCommandNotFound if !netstat_path
|
59
|
+
|
60
|
+
r = Vagrant::Util::Subprocess.execute(netstat_path, "-nr", "-f", "inet")
|
61
|
+
raise Errors::RoutingTableLoadError, :output => r.stderr if r.exit_code != 0
|
62
|
+
|
63
|
+
result = {}
|
64
|
+
r.stdout.split("\n").each do |line|
|
65
|
+
# If the line doesn't start with a number, it isn't worth
|
66
|
+
# looking at.
|
67
|
+
next if line !~ /^\d/
|
68
|
+
|
69
|
+
# Split by whitespace
|
70
|
+
parts = line.split
|
71
|
+
|
72
|
+
# Get out the destination and device, since these are
|
73
|
+
# the only fields we actually care about.
|
74
|
+
destination = parts[0]
|
75
|
+
device = parts[5]
|
76
|
+
|
77
|
+
# Convert the destination into an IPAddr. This involves splitting
|
78
|
+
# out the mask and figuring out the proper IP address formatting...
|
79
|
+
ip_parts = destination.split("/")
|
80
|
+
mask = ip_parts[1]
|
81
|
+
ip_parts = ip_parts[0].split(".")
|
82
|
+
mask ||= Array.new(ip_parts.length, "255")
|
83
|
+
|
84
|
+
while ip_parts.length < 4
|
85
|
+
ip_parts << "0"
|
86
|
+
mask << "0" if mask.is_a?(Array)
|
87
|
+
end
|
88
|
+
|
89
|
+
# If mask is an array we turn it into a real mask here
|
90
|
+
mask = mask.join(".") if mask.is_a?(Array)
|
91
|
+
|
92
|
+
# Build the IP and final destination
|
93
|
+
ip_parts = ip_parts.join(".")
|
94
|
+
destination = IPAddr.new("#{ip_parts}/#{mask}")
|
95
|
+
|
96
|
+
# Map the destination to the device
|
97
|
+
result[destination] = device
|
98
|
+
end
|
99
|
+
|
100
|
+
result
|
101
|
+
end
|
102
|
+
|
103
|
+
def read_table_linux
|
104
|
+
netstat_path = Vagrant::Util::Which.which("netstat")
|
105
|
+
raise Errors::RoutingTableCommandNotFound if !netstat_path
|
106
|
+
|
107
|
+
r = Vagrant::Util::Subprocess.execute(netstat_path, "-nr")
|
108
|
+
raise Errors::RoutingTableLoadError, :output => r.stderr if r.exit_code != 0
|
109
|
+
|
110
|
+
result = {}
|
111
|
+
r.stdout.split("\n").each do |line|
|
112
|
+
# If the line doesn't start with a number, it isn't worth
|
113
|
+
# looking at.
|
114
|
+
next if line !~ /^\d/
|
115
|
+
|
116
|
+
# Split by whitespace
|
117
|
+
parts = line.split
|
118
|
+
|
119
|
+
# Grab the pieces
|
120
|
+
destination = parts[0]
|
121
|
+
mask = parts[2]
|
122
|
+
device = parts[7]
|
123
|
+
|
124
|
+
# If the destination is default, then ignore
|
125
|
+
next if destination == "0.0.0.0"
|
126
|
+
|
127
|
+
# Build the IP
|
128
|
+
ip = IPAddr.new("#{destination}/#{mask}")
|
129
|
+
|
130
|
+
# Map the destination to the device
|
131
|
+
result[ip] = device
|
132
|
+
end
|
133
|
+
|
134
|
+
result
|
135
|
+
end
|
136
|
+
|
137
|
+
def read_table_windows
|
138
|
+
netsh_path = Vagrant::Util::Which.which("netsh.exe")
|
139
|
+
raise Errors::RoutingTableCommandNotFound if !netsh_path
|
140
|
+
|
141
|
+
r = Vagrant::Util::Subprocess.execute(
|
142
|
+
netsh_path, "interface", "ip", "show", "route")
|
143
|
+
raise Errors::RoutingTableLoadError, :output => r.stderr if r.exit_code != 0
|
144
|
+
|
145
|
+
# Just use Unix-style line endings
|
146
|
+
r.stdout.gsub!("\r\n", "\n")
|
147
|
+
|
148
|
+
result = {}
|
149
|
+
r.stdout.split("\n").each do |line|
|
150
|
+
# Split by whitespace
|
151
|
+
parts = line.split
|
152
|
+
|
153
|
+
# If there aren't enough parts, ignore it
|
154
|
+
next if parts.length < 6
|
155
|
+
|
156
|
+
# If we didn't get numbers for the metrics, then ignore
|
157
|
+
next if parts[2] !~ /^\d+$/
|
158
|
+
|
159
|
+
# Grab the pieces
|
160
|
+
ip = parts[3]
|
161
|
+
device = parts[5..-1].join(" ")
|
162
|
+
|
163
|
+
# If we're working with a VMware device, parse out the vmnet
|
164
|
+
match = /^VMware Network Adapter (.+?)$/.match(device)
|
165
|
+
device = match[1].downcase if match
|
166
|
+
|
167
|
+
# If the destination is default, then ignore
|
168
|
+
next if ip == "0.0.0.0/0"
|
169
|
+
|
170
|
+
# Build the IP
|
171
|
+
ip = IPAddr.new(ip)
|
172
|
+
|
173
|
+
# Map the destination to the device
|
174
|
+
result[ip] = device
|
175
|
+
end
|
176
|
+
|
177
|
+
result
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "net/http"
|
3
|
+
require "net/https"
|
4
|
+
|
5
|
+
require "vagrant"
|
6
|
+
require "vagrant/util/downloader"
|
7
|
+
require "vagrant/util/string_block_editor"
|
8
|
+
|
9
|
+
module HashiCorp
|
10
|
+
module VagrantVMwareDesktop
|
11
|
+
module Helper
|
12
|
+
# This is a class for dealing the vagrant vmware utility API
|
13
|
+
class VagrantUtility
|
14
|
+
|
15
|
+
# Response wrapper class
|
16
|
+
class Response
|
17
|
+
|
18
|
+
# Raw value being wrapped
|
19
|
+
#
|
20
|
+
# @return [Hash]
|
21
|
+
attr_reader :value
|
22
|
+
|
23
|
+
def initialize(value)
|
24
|
+
if !value.is_a?(Hash)
|
25
|
+
raise TypeError.new("Expecting value of `Hash` type but received `#{value.class}`")
|
26
|
+
end
|
27
|
+
@value = value
|
28
|
+
end
|
29
|
+
|
30
|
+
# Provides Hash#dig functionality but will raise
|
31
|
+
# an invalid response exception if given path raises
|
32
|
+
# an error.
|
33
|
+
#
|
34
|
+
# @return [Object]
|
35
|
+
def get(*args)
|
36
|
+
begin
|
37
|
+
value.dig(*args)
|
38
|
+
rescue => err
|
39
|
+
raise Errors::DriverAPIInvalidResponse
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def [](v)
|
44
|
+
value[v]
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [TrueClass, FalseClass] response is success
|
48
|
+
def success?
|
49
|
+
value[:success]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Net::HTTP]
|
54
|
+
attr_reader :connection
|
55
|
+
# @return [Hash]
|
56
|
+
attr_reader :headers
|
57
|
+
# @return [Log4r::Logger]
|
58
|
+
attr_reader :logger
|
59
|
+
|
60
|
+
def initialize(host, port, **opts)
|
61
|
+
@logger = Log4r::Logger.new("hashicorp::provider::vmware::vagrant_utility")
|
62
|
+
@logger.debug("initialize HOST=#{host} PORT=#{port}")
|
63
|
+
@connection = Net::HTTP.new(host, port)
|
64
|
+
@connection.use_ssl = true
|
65
|
+
@connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
66
|
+
@connection.ca_file = File.join(opts[:certificate_path], "vagrant-utility.crt")
|
67
|
+
@headers = {
|
68
|
+
"Content-Type" => "application/vnd.hashicorp.vagrant.vmware.rest-v1+json",
|
69
|
+
"Origin" => "https://#{host}:#{port}",
|
70
|
+
"User-Agent" => Vagrant::Util::Downloader::USER_AGENT +
|
71
|
+
" - VagrantVMWareDesktop/#{VagrantVMwareDesktop::VERSION}",
|
72
|
+
"X-Requested-With" => "Vagrant",
|
73
|
+
}
|
74
|
+
cert_path = File.join(opts[:certificate_path], "vagrant-utility.client.crt")
|
75
|
+
key_path = File.join(opts[:certificate_path], "vagrant-utility.client.key")
|
76
|
+
begin
|
77
|
+
@connection.cert = OpenSSL::X509::Certificate.new(File.read(cert_path))
|
78
|
+
rescue => err
|
79
|
+
@logger.debug("certificate load failure - #{err.class}: #{err}")
|
80
|
+
raise Errors::DriverAPICertificateError.new(
|
81
|
+
path: cert_path,
|
82
|
+
message: err.message
|
83
|
+
)
|
84
|
+
end
|
85
|
+
begin
|
86
|
+
@connection.key = OpenSSL::PKey::RSA.new(File.read(key_path))
|
87
|
+
rescue => err
|
88
|
+
@logger.debug("key load failure - #{err.class}: #{err}")
|
89
|
+
raise Errors::DriverAPIKeyError.new(
|
90
|
+
path: key_path,
|
91
|
+
message: err.message
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Perform GET
|
97
|
+
#
|
98
|
+
# @param [String] path
|
99
|
+
# @return [Response]
|
100
|
+
def get(path)
|
101
|
+
perform_request(:get, path)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Perform PUT
|
105
|
+
#
|
106
|
+
# @param [String] path
|
107
|
+
# @param [Object] payload
|
108
|
+
# @return [Response]
|
109
|
+
def put(path, payload=nil)
|
110
|
+
perform_request(:put, path, payload)
|
111
|
+
end
|
112
|
+
|
113
|
+
# Perform POST
|
114
|
+
#
|
115
|
+
# @param [String] path
|
116
|
+
# @param [Object] payload
|
117
|
+
# @return [Response]
|
118
|
+
def post(path, payload=nil)
|
119
|
+
perform_request(:post, path, payload)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Perform DELETE
|
123
|
+
#
|
124
|
+
# @param [String] path
|
125
|
+
# @param [Object] payload
|
126
|
+
# @return [Response]
|
127
|
+
def delete(path, payload=nil)
|
128
|
+
perform_request(:delete, path, payload)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Perform the remote request and process the result
|
132
|
+
#
|
133
|
+
# @param [String,Symbol] method HTTP method
|
134
|
+
# @param [String] path remote path
|
135
|
+
# @param [Object] data request body
|
136
|
+
# @param [Hash] rheaders custom request headers
|
137
|
+
# @return [Response]
|
138
|
+
def perform_request(method, path, data=nil, rheaders={})
|
139
|
+
req_headers = headers.merge(rheaders)
|
140
|
+
if data && !data.is_a?(String)
|
141
|
+
data = JSON.generate(data)
|
142
|
+
end
|
143
|
+
method = method.to_s.upcase
|
144
|
+
response = process_response do
|
145
|
+
connection.send_request(method, path, data, req_headers)
|
146
|
+
end
|
147
|
+
if !response.success?
|
148
|
+
error = "ERROR=#{response.get(:content, :message)}"
|
149
|
+
end
|
150
|
+
@logger.debug("request METHOD=#{method} PATH=#{path} RESPONSE=#{response.get(:code)} #{error}")
|
151
|
+
response
|
152
|
+
end
|
153
|
+
|
154
|
+
# Wraps response into Response instance
|
155
|
+
#
|
156
|
+
# @yieldblock [Net::HTTPResponse]
|
157
|
+
# @return [Response]
|
158
|
+
def process_response
|
159
|
+
begin
|
160
|
+
response = yield
|
161
|
+
result = {
|
162
|
+
code: response.code.to_i,
|
163
|
+
success: response.code.start_with?('2')
|
164
|
+
}
|
165
|
+
if response.class.body_permitted?
|
166
|
+
body = response.body
|
167
|
+
begin
|
168
|
+
result[:content] = JSON.parse(body, :symbolize_names => true)
|
169
|
+
rescue
|
170
|
+
result[:content] = body
|
171
|
+
end
|
172
|
+
else
|
173
|
+
result[:content] = nil
|
174
|
+
end
|
175
|
+
Response.new(result)
|
176
|
+
rescue Net::HTTPServiceUnavailable
|
177
|
+
raise Errors::DriverAPIConnectionFailed
|
178
|
+
rescue => err
|
179
|
+
raise Errors::DriverAPIRequestUnexpectedError, error: err
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant VMware #{HashiCorp::VagrantVMwareDesktop::PRODUCT_NAME} provider must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.2.0"
|
10
|
+
raise "VMware #{HashiCorp::VagrantVMwareDesktop::PRODUCT_NAME} provider is only compatible with Vagrant 1.2+"
|
11
|
+
end
|
12
|
+
|
13
|
+
require "vagrant-vmware-desktop/setup_plugin"
|
14
|
+
|
15
|
+
module HashiCorp
|
16
|
+
module VagrantVMwareDesktop
|
17
|
+
class Plugin < Vagrant.plugin("2")
|
18
|
+
name "VMware #{PRODUCT_NAME.capitalize} Provider"
|
19
|
+
description <<-DESC
|
20
|
+
This plugin installs a provider which allows Vagrant to manage
|
21
|
+
VMware #{PRODUCT_NAME.capitalize} machines.
|
22
|
+
DESC
|
23
|
+
|
24
|
+
def self.provider_name
|
25
|
+
"vmware_#{PRODUCT_NAME}".to_sym
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.provider_options
|
29
|
+
{
|
30
|
+
box_format: ["vmware_desktop", "vmware_fusion", "vmware_workstation"],
|
31
|
+
priority: 10,
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
#--------------------------------------------------------------
|
36
|
+
# Action Hooks
|
37
|
+
#--------------------------------------------------------------
|
38
|
+
# Plugin activation/licensing
|
39
|
+
action_hook(:activation_start, :environment_load) do |h|
|
40
|
+
h.append(SetupPlugin)
|
41
|
+
end
|
42
|
+
|
43
|
+
#--------------------------------------------------------------
|
44
|
+
# VMware Provider
|
45
|
+
#--------------------------------------------------------------
|
46
|
+
|
47
|
+
# We register two providers now, vmware_desktop which is named after
|
48
|
+
# this plugin's now current name, and vmware_PRODUCT_NAME which is
|
49
|
+
# the legacy naming covering vmware_workstation and vmware_fusion.
|
50
|
+
# This provides backwards compatibility ensuring things still work
|
51
|
+
# after upgrading
|
52
|
+
|
53
|
+
[:vmware_desktop, provider_name].each do |p_name|
|
54
|
+
config(p_name, :provider) do
|
55
|
+
require File.expand_path("../config", __FILE__)
|
56
|
+
Config
|
57
|
+
end
|
58
|
+
|
59
|
+
provider_capability(p_name, :snapshot_list) do
|
60
|
+
require File.expand_path("../cap/snapshot", __FILE__)
|
61
|
+
Cap::Snapshot
|
62
|
+
end
|
63
|
+
|
64
|
+
provider_capability(p_name, :delete_all_snapshots) do
|
65
|
+
require File.expand_path("../cap/snapshot", __FILE__)
|
66
|
+
Cap::Snapshot
|
67
|
+
end
|
68
|
+
|
69
|
+
provider_capability(p_name, :delete_snapshot) do
|
70
|
+
require File.expand_path("../cap/snapshot", __FILE__)
|
71
|
+
Cap::Snapshot
|
72
|
+
end
|
73
|
+
|
74
|
+
provider(p_name, provider_options) do
|
75
|
+
require File.expand_path("../provider", __FILE__)
|
76
|
+
Provider
|
77
|
+
end
|
78
|
+
|
79
|
+
provider_capability(p_name, :forwarded_ports) do
|
80
|
+
require File.expand_path("../cap/provider", __FILE__)
|
81
|
+
Cap::Provider
|
82
|
+
end
|
83
|
+
|
84
|
+
provider_capability(p_name, :public_address) do
|
85
|
+
require File.expand_path("../cap/provider", __FILE__)
|
86
|
+
Cap::Provider
|
87
|
+
end
|
88
|
+
|
89
|
+
provider_capability(p_name, :nic_mac_addresses) do
|
90
|
+
require File.expand_path("../cap/provider", __FILE__)
|
91
|
+
Cap::Provider
|
92
|
+
end
|
93
|
+
|
94
|
+
provider_capability(p_name, :scrub_forwarded_ports) do
|
95
|
+
require File.expand_path("../cap/provider", __FILE__)
|
96
|
+
Cap::Provider
|
97
|
+
end
|
98
|
+
|
99
|
+
Vagrant::Util::Experimental.guard_with(:disks) do
|
100
|
+
provider_capability(p_name, :set_default_disk_ext) do
|
101
|
+
require File.expand_path("../cap/disk", __FILE__)
|
102
|
+
Cap::Disk
|
103
|
+
end
|
104
|
+
|
105
|
+
provider_capability(p_name, :default_disk_exts) do
|
106
|
+
require File.expand_path("../cap/disk", __FILE__)
|
107
|
+
Cap::Disk
|
108
|
+
end
|
109
|
+
|
110
|
+
provider_capability(p_name, :configure_disks) do
|
111
|
+
require File.expand_path("../cap/disk", __FILE__)
|
112
|
+
Cap::Disk
|
113
|
+
end
|
114
|
+
|
115
|
+
provider_capability(p_name, :cleanup_disks) do
|
116
|
+
require File.expand_path("../cap/disk", __FILE__)
|
117
|
+
Cap::Disk
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
#--------------------------------------------------------------
|
123
|
+
# Synced Folder
|
124
|
+
#--------------------------------------------------------------
|
125
|
+
|
126
|
+
synced_folder(:vmware) do
|
127
|
+
require File.expand_path("../synced_folder", __FILE__)
|
128
|
+
SyncedFolder
|
129
|
+
end
|
130
|
+
|
131
|
+
#--------------------------------------------------------------
|
132
|
+
# Capabilities introduced by VMware provider
|
133
|
+
#--------------------------------------------------------------
|
134
|
+
|
135
|
+
guest_capability("linux", "verify_vmware_hgfs") do
|
136
|
+
require_relative "guest_cap/linux/verify_vmware_hgfs"
|
137
|
+
GuestCap::Linux::VerifyVMwareHGFS
|
138
|
+
end
|
139
|
+
|
140
|
+
guest_capability("linux", "mount_vmware_shared_folder") do
|
141
|
+
require_relative "guest_cap/linux/mount_vmware_shared_folder"
|
142
|
+
GuestCap::Linux::MountVMwareSharedFolder
|
143
|
+
end
|
144
|
+
|
145
|
+
autoload :Action, File.expand_path("../action", __FILE__)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|