vagrant-parallels 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63f2802c08f2dca252035eebdba9346ca7e8ca1d
4
- data.tar.gz: 5c67f4b8efb10f42d9062ef63a4009b92f64a60f
3
+ metadata.gz: 357deec9b5427708e14fc8d7bafc0df42ef06b4d
4
+ data.tar.gz: d997bba5f56330d1bc7a69c0602aa613e0be08cb
5
5
  SHA512:
6
- metadata.gz: 42a742b4c31a08b698902c283d29145ffeb9ef3abaac6584030b823790ae5756a06f162f42d78aa67e4f531aa5ac1d74def2e24ff6094cd22fcf983bd4162bff
7
- data.tar.gz: 0bfa98293a6d5aace8a2cb4617837cce15e74c0b70ff9491f8e9d6f8a73e1df598e6e2f5f58ccde4d68b7a2e58f8d6daccbfc985f837871d84ae19238ff9fb92
6
+ metadata.gz: b5c9089a4c56fa43631d1ca66284e112898e374709ddcea08c3931c641cefdabe5a542279ab853880435052fe423d7cc03780f9341b170c9405f8602ce361835
7
+ data.tar.gz: eb0c5ed9cfad34c70225c60cac47131c3458549a64ae958eafb49b55379e499199f12d852057158002368378671e77ec0dd6de4845644bc69d516c4d1691a6a4
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  GIT
2
2
  remote: git://github.com/mitchellh/vagrant.git
3
- revision: 914d177346815a6516133e9471cb2ab8e1346250
3
+ revision: d0cf22dd5fc5fcb8ee49577c0a93e7c6eeda56b1
4
4
  specs:
5
- vagrant (1.5.0.dev)
5
+ vagrant (1.5.1.dev)
6
6
  bundler (~> 1.5.2)
7
7
  childprocess (~> 0.5.0)
8
8
  erubis (~> 2.7.0)
@@ -17,7 +17,7 @@ GIT
17
17
  PATH
18
18
  remote: .
19
19
  specs:
20
- vagrant-parallels (1.0.0)
20
+ vagrant-parallels (1.0.1)
21
21
 
22
22
  GEM
23
23
  remote: http://rubygems.org/
@@ -84,7 +84,7 @@ GEM
84
84
  atomic (>= 1.1.7, < 2)
85
85
  timers (1.1.0)
86
86
  tins (1.0.0)
87
- tzinfo (0.3.38)
87
+ tzinfo (0.3.39)
88
88
  wdm (0.1.0)
89
89
 
90
90
  PLATFORMS
data/Vagrantfile CHANGED
@@ -3,8 +3,7 @@ Vagrant.configure("2") do |config|
3
3
  # Configure base box parameters
4
4
  config.vm.define 'ubuntu' do |u|
5
5
  u.vm.hostname = "my-super-vm.do.sw.ru"
6
- u.vm.box = "ubuntu-13.10_x64.box"
7
- u.vm.box_url = "http://download.parallels.com/desktop/vagrant/saucy64.box"
6
+ u.vm.box = "parallels/ubuntu-13.10"
8
7
  end
9
8
 
10
9
  config.vm.define 'centos' do |c|
@@ -16,7 +15,7 @@ Vagrant.configure("2") do |config|
16
15
  end
17
16
 
18
17
  c.vm.network "private_network", ip: "33.33.30.25", netmask: "255.255.252.0"
19
- #c.vm.network "public_network", bridge: "en0"
18
+ c.vm.network "public_network", bridge: "en0"
20
19
 
21
20
  #c.vm.network "private_network", type: :dhcp
22
21
  #c.vm.network "public_network", dhcp: "yes", bridge: "en0"
@@ -24,8 +23,7 @@ Vagrant.configure("2") do |config|
24
23
 
25
24
 
26
25
  c.vm.hostname = "my-funny-centos.do.sw.ru"
27
- c.vm.box = "centos-6.5_x64"
28
- c.vm.box_url = "http://download.parallels.com/desktop/vagrant/centos64.box"
26
+ c.vm.box = "parallels/centos-6.5"
29
27
 
30
28
  #c.vm.box = "graylog2"
31
29
  #c.vm.box = "TEST_1.4"
@@ -0,0 +1,15 @@
1
+ module VagrantPlugins
2
+ module Parallels
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
@@ -73,7 +73,6 @@ module VagrantPlugins
73
73
  end
74
74
 
75
75
  def_delegators :@driver,
76
- #:clear_forwarded_ports,
77
76
  :clear_shared_folders,
78
77
  :compact,
79
78
  :create_host_only_network,
@@ -83,11 +82,8 @@ module VagrantPlugins
83
82
  :enable_adapters,
84
83
  :execute_command,
85
84
  :export,
86
- #:forward_ports,
87
85
  :halt,
88
86
  :import,
89
- :read_ip_dhcp,
90
- #:read_forwarded_ports,
91
87
  :read_bridged_interfaces,
92
88
  :read_guest_tools_version,
93
89
  :read_guest_ip,
@@ -184,21 +184,18 @@ module VagrantPlugins
184
184
  end
185
185
 
186
186
  def read_bridged_interfaces
187
- net_list = read_virtual_networks
188
-
189
- # Skip 'vnicXXX' and 'Default' interfaces
190
- net_list.delete_if do |net|
191
- net['Type'] != "bridged" or
192
- net['Bound To'] =~ /^(vnic(.+?))$/ or
193
- net['Network ID'] == "Default"
187
+ host_hw_info = read_host_info.fetch("Hardware info")
188
+ net_list = host_hw_info.select do |name, attrs|
189
+ # Get all network interfaces except 'vnicXXX'
190
+ attrs.fetch("type") == "net" and name !~ /^(vnic(.+?))$/
194
191
  end
195
192
 
196
193
  bridged_ifaces = []
197
- net_list.collect do |iface|
194
+ net_list.keys.each do |iface|
198
195
  info = {}
199
- ifconfig = execute(:ifconfig, iface['Bound To'])
196
+ ifconfig = execute(:ifconfig, iface)
200
197
  # Assign default values
201
- info[:name] = iface['Bound To']
198
+ info[:name] = iface
202
199
  info[:ip] = "0.0.0.0"
203
200
  info[:netmask] = "0.0.0.0"
204
201
  info[:status] = "Down"
@@ -220,16 +217,31 @@ module VagrantPlugins
220
217
  bridged_ifaces
221
218
  end
222
219
 
220
+ def read_guest_ip
221
+ mac_addr = read_mac_address.downcase
222
+ File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
223
+ if line.include? mac_addr
224
+ return line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
225
+ end
226
+ end
227
+
228
+ nil
229
+ end
230
+
223
231
  def read_guest_tools_version
224
232
  read_settings.fetch('GuestTools', {}).fetch('version', nil)
225
233
  end
226
234
 
235
+ def read_host_info
236
+ json { execute('server', 'info', '--json', retryable: true) }
237
+ end
238
+
227
239
  def read_host_only_interfaces
228
240
  net_list = read_virtual_networks
229
241
  net_list.keep_if { |net| net['Type'] == "host-only" }
230
242
 
231
243
  hostonly_ifaces = []
232
- net_list.collect do |iface|
244
+ net_list.each do |iface|
233
245
  info = {}
234
246
  net_info = json { execute(:prlsrvctl, 'net', 'info', iface['Network ID'], '--json') }
235
247
  # Really we need to work with bounded virtual interface
@@ -254,16 +266,6 @@ module VagrantPlugins
254
266
  hostonly_ifaces
255
267
  end
256
268
 
257
- def read_ip_dhcp
258
- mac_addr = read_mac_address.downcase
259
- File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
260
- if line.include? mac_addr
261
- ip = line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
262
- return ip
263
- end
264
- end
265
- end
266
-
267
269
  def read_mac_address
268
270
  read_settings.fetch('Hardware', {}).fetch('net0', {}).fetch('mac', nil)
269
271
  end
@@ -184,21 +184,18 @@ module VagrantPlugins
184
184
  end
185
185
 
186
186
  def read_bridged_interfaces
187
- net_list = read_virtual_networks
188
-
189
- # Skip 'vnicXXX' and 'Default' interfaces
190
- net_list.delete_if do |net|
191
- net['Type'] != "bridged" or
192
- net['Bound To'] =~ /^(vnic(.+?))$/ or
193
- net['Network ID'] == "Default"
187
+ host_hw_info = read_host_info.fetch("Hardware info")
188
+ net_list = host_hw_info.select do |name, attrs|
189
+ # Get all network interfaces except 'vnicXXX'
190
+ attrs.fetch("type") == "net" and name !~ /^(vnic(.+?))$/
194
191
  end
195
192
 
196
193
  bridged_ifaces = []
197
- net_list.collect do |iface|
194
+ net_list.keys.each do |iface|
198
195
  info = {}
199
- ifconfig = execute(:ifconfig, iface['Bound To'])
196
+ ifconfig = execute(:ifconfig, iface)
200
197
  # Assign default values
201
- info[:name] = iface['Bound To']
198
+ info[:name] = iface
202
199
  info[:ip] = "0.0.0.0"
203
200
  info[:netmask] = "0.0.0.0"
204
201
  info[:status] = "Down"
@@ -220,16 +217,34 @@ module VagrantPlugins
220
217
  bridged_ifaces
221
218
  end
222
219
 
220
+ def read_guest_ip
221
+ mac_addr = read_mac_address.downcase
222
+ leases_file = "/Library/Preferences/Parallels/parallels_dhcp_leases"
223
+ begin
224
+ File.open(leases_file).grep(/#{mac_addr}/) do |line|
225
+ return line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
226
+ end
227
+ rescue Errno::EACCES
228
+ raise Errors::DhcpLeasesNotAccessible, :leases_file => leases_file.to_s
229
+ end
230
+
231
+ nil
232
+ end
233
+
223
234
  def read_guest_tools_version
224
235
  read_settings.fetch('GuestTools', {}).fetch('version', nil)
225
236
  end
226
237
 
238
+ def read_host_info
239
+ json { execute('server', 'info', '--json', retryable: true) }
240
+ end
241
+
227
242
  def read_host_only_interfaces
228
243
  net_list = read_virtual_networks
229
244
  net_list.keep_if { |net| net['Type'] == "host-only" }
230
245
 
231
246
  hostonly_ifaces = []
232
- net_list.collect do |iface|
247
+ net_list.each do |iface|
233
248
  info = {}
234
249
  net_info = json { execute(:prlsrvctl, 'net', 'info', iface['Network ID'], '--json') }
235
250
  # Really we need to work with bounded virtual interface
@@ -254,16 +269,6 @@ module VagrantPlugins
254
269
  hostonly_ifaces
255
270
  end
256
271
 
257
- def read_ip_dhcp
258
- mac_addr = read_mac_address.downcase
259
- File.foreach("/Library/Preferences/Parallels/parallels_dhcp_leases") do |line|
260
- if line.include? mac_addr
261
- ip = line[/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/]
262
- return ip
263
- end
264
- end
265
- end
266
-
267
272
  def read_mac_address
268
273
  read_settings.fetch('Hardware', {}).fetch('net0', {}).fetch('mac', nil)
269
274
  end
@@ -7,6 +7,10 @@ module VagrantPlugins
7
7
  error_namespace("vagrant_parallels.errors")
8
8
  end
9
9
 
10
+ class DhcpLeasesNotAccessible < VagrantParallelsError
11
+ error_key(:dhcp_leases_file_not_accessible)
12
+ end
13
+
10
14
  class PrlCtlError < VagrantParallelsError
11
15
  error_key(:prlctl_error)
12
16
  end
@@ -40,6 +40,11 @@ module VagrantPlugins
40
40
  GuestLinuxCap::MountParallelsSharedFolder
41
41
  end
42
42
 
43
+ provider_capability("parallels", "public_address") do
44
+ require_relative "cap/public_address"
45
+ Cap::PublicAddress
46
+ end
47
+
43
48
  synced_folder(:parallels) do
44
49
  require File.expand_path("../synced_folder", __FILE__)
45
50
  SyncedFolder
@@ -52,11 +52,11 @@ module VagrantPlugins
52
52
  # we return nil.
53
53
  return nil if state.id == :not_created
54
54
 
55
- detected_ip = @machine.config.ssh.host || @driver.read_ip_dhcp
55
+ detected_ip = @driver.read_guest_ip
56
56
 
57
57
  # If ip couldn't be detected then we cannot possibly SSH into it,
58
58
  # and should return nil too.
59
- return nil if detected_ip.nil?
59
+ return nil if !detected_ip
60
60
 
61
61
  # Return ip from running machine, use ip from config if available
62
62
  return {
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -9,6 +9,12 @@ en:
9
9
  # Translations for exception classes
10
10
  #-------------------------------------------------------------------------------
11
11
  errors:
12
+ dhcp_leases_file_not_accessible: |-
13
+ Parallels DHCP leases file is not accessible. The Parallels provider
14
+ uses it to detect an IP address of virtual machine. This file must be
15
+ readable for the user that is running Vagrant.
16
+
17
+ Parallels DHCP leases file: %{leases_file}
12
18
  mac_os_x_required: |-
13
19
  Parallels provider only works on OS X (or Mac OS X).
14
20
  prlctl_error: |-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-parallels
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Zholobov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-10 00:00:00.000000000 Z
12
+ date: 2014-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -109,6 +109,7 @@ files:
109
109
  - lib/vagrant-parallels/action/setup_package_files.rb
110
110
  - lib/vagrant-parallels/action/suspend.rb
111
111
  - lib/vagrant-parallels/action.rb
112
+ - lib/vagrant-parallels/cap/public_address.rb
112
113
  - lib/vagrant-parallels/config.rb
113
114
  - lib/vagrant-parallels/driver/base.rb
114
115
  - lib/vagrant-parallels/driver/meta.rb