vagrant-parallels 1.0.8 → 1.0.9.rc1

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: 53efd8fa01ec277af1f83f69aa9dfab622b2fed0
4
- data.tar.gz: 67484ac9e531c0e2d9f9684877d1fc7ac323ad78
3
+ metadata.gz: a8ea354f8e68e8f1aaf7818f93d2dca3443810dd
4
+ data.tar.gz: 2233c2829d52b81c756887386609777cae1f9b20
5
5
  SHA512:
6
- metadata.gz: 7d4d5682d7172e1c4906a4105b57b5cf897b4cba4c89f7619ca2f1c4a03d70dee01a2473f5bb40ba19ce61b798d97b03d4b10edb38495a17adea12dd23663fc3
7
- data.tar.gz: 1570ee017231dbab9c23ba887c589ef2106a031255150a1f9d8efd7ff3a655bc046707054220f675be5704fd42b70310eda27d98d41896d9c44230cd013dfcd7
6
+ metadata.gz: f9d87dd9bb9b2d54ca7cf823b401afb7d6e2c613a545c6b5747c32d90f758a913a06886c22f589ddd033499fda31837e510e44c3a3f799d6de3b73907f39e601
7
+ data.tar.gz: ba152304d98bc5c2f1212783a1f50fffff9ba4f21b6ec9ea2ba2c235c977804614e27c7ac35c449d09a3c69dd9a35d475ef141a136b3e5af39a3b6a8b1f56350
@@ -49,7 +49,6 @@ module VagrantPlugins
49
49
 
50
50
  b2.use Call, DestroyConfirm do |env2, b3|
51
51
  if env2[:result]
52
- b3.use ConfigValidate
53
52
  b3.use CheckAccessible
54
53
  b3.use EnvSet, :force_halt => true
55
54
  b3.use action_halt
@@ -9,7 +9,7 @@ module VagrantPlugins
9
9
 
10
10
  def call(env)
11
11
  @env = env
12
- if env[:machine].provider.state.id != :stopped
12
+ if env[:machine].state.id != :stopped
13
13
  raise Vagrant::Errors::VMPowerOffToPackage
14
14
  end
15
15
 
@@ -26,7 +26,7 @@ module VagrantPlugins
26
26
  # We should to unregister template
27
27
  unregister_template
28
28
 
29
- if env[:machine].provider.state.id != :not_created
29
+ if env[:machine].state.id != :not_created
30
30
  return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
31
31
  return if env["vagrant_parallels.error"].is_a?(VagrantPlugins::Parallels::Errors::VagrantParallelsError)
32
32
 
@@ -318,11 +318,11 @@ module VagrantPlugins
318
318
  end
319
319
 
320
320
  return {
321
- :adapter => config[:adapter],
322
- :hostonly => interface[:name],
323
- :mac => config[:mac],
324
- :nic_type => config[:nic_type],
325
- :type => :hostonly
321
+ :adapter => config[:adapter],
322
+ :hostonly => interface[:name],
323
+ :mac_address => config[:mac],
324
+ :nic_type => config[:nic_type],
325
+ :type => :hostonly
326
326
  }
327
327
  end
328
328
 
@@ -7,7 +7,7 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- current_state = env[:machine].provider.state.id
10
+ current_state = env[:machine].state.id
11
11
 
12
12
  if current_state == :suspended
13
13
  env[:ui].info I18n.t("vagrant.actions.vm.resume.resuming")
@@ -7,7 +7,7 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- if env[:machine].provider.state.id == :running
10
+ if env[:machine].state.id == :running
11
11
  env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending")
12
12
  env[:machine].provider.driver.suspend
13
13
  end
@@ -0,0 +1,14 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Cap
4
+ module NicMacAddresses
5
+ # Reads the network interface card MAC addresses and returns them.
6
+ #
7
+ # @return [Hash<String, String>] Adapter => MAC address
8
+ def self.nic_mac_addresses(machine)
9
+ machine.provider.driver.read_mac_addresses
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,6 +4,7 @@ module VagrantPlugins
4
4
  attr_accessor :check_guest_tools
5
5
  attr_reader :customizations
6
6
  attr_accessor :destroy_unused_network_interfaces
7
+ attr_accessor :functional_psf
7
8
  attr_accessor :optimize_power_consumption
8
9
  attr_accessor :name
9
10
  attr_reader :network_adapters
@@ -16,6 +17,7 @@ module VagrantPlugins
16
17
  @check_guest_tools = UNSET_VALUE
17
18
  @customizations = []
18
19
  @destroy_unused_network_interfaces = UNSET_VALUE
20
+ @functional_psf = UNSET_VALUE
19
21
  @network_adapters = {}
20
22
  @name = UNSET_VALUE
21
23
  @optimize_power_consumption = UNSET_VALUE
@@ -42,6 +44,14 @@ module VagrantPlugins
42
44
  customize("pre-boot", ["set", :id, "--cpus", count.to_i])
43
45
  end
44
46
 
47
+ def merge(other)
48
+ super.tap do |result|
49
+ c = customizations.dup
50
+ c += other.customizations
51
+ result.instance_variable_set(:@customizations, c)
52
+ end
53
+ end
54
+
45
55
  def finalize!
46
56
  if @check_guest_tools == UNSET_VALUE
47
57
  @check_guest_tools = true
@@ -51,6 +61,10 @@ module VagrantPlugins
51
61
  @destroy_unused_network_interfaces = true
52
62
  end
53
63
 
64
+ if @functional_psf == UNSET_VALUE
65
+ @functional_psf = true
66
+ end
67
+
54
68
  if @optimize_power_consumption == UNSET_VALUE
55
69
  @optimize_power_consumption = true
56
70
  end
@@ -149,6 +149,12 @@ module VagrantPlugins
149
149
  def read_mac_address
150
150
  end
151
151
 
152
+ # Returns the network interface card MAC addresses
153
+ #
154
+ # @return [Hash<String, String>] Adapter => MAC address
155
+ def read_mac_addresses
156
+ end
157
+
152
158
  # Returns a list of network interfaces of the VM.
153
159
  #
154
160
  # @return [Hash]
@@ -234,6 +240,10 @@ module VagrantPlugins
234
240
  def suspend
235
241
  end
236
242
 
243
+ # Unshare folders.
244
+ def unshare_folders(names)
245
+ end
246
+
237
247
  # Verifies that the driver is ready to accept work.
238
248
  #
239
249
  # This should raise a VagrantError if things are not ready.
@@ -94,6 +94,7 @@ module VagrantPlugins
94
94
  :read_guest_property,
95
95
  :read_host_only_interfaces,
96
96
  :read_mac_address,
97
+ :read_mac_addresses,
97
98
  :read_network_interfaces,
98
99
  :read_shared_interface,
99
100
  :read_shared_folders,
@@ -277,6 +277,18 @@ module VagrantPlugins
277
277
  read_settings.fetch('Hardware', {}).fetch('net0', {}).fetch('mac', nil)
278
278
  end
279
279
 
280
+ def read_mac_addresses
281
+ macs = {}
282
+ read_settings.fetch('Hardware', {}).each do |device, params|
283
+ if device =~ /^net(\d+)$/
284
+ adapter = $1
285
+ mac = params.fetch('mac')
286
+ macs[adapter] = mac
287
+ end
288
+ end
289
+ macs
290
+ end
291
+
280
292
  def read_network_interfaces
281
293
  nics = {}
282
294
 
@@ -438,6 +450,12 @@ module VagrantPlugins
438
450
  execute("unregister", uuid)
439
451
  end
440
452
 
453
+ def unshare_folders(names)
454
+ names.each do |name|
455
+ execute("set", @uuid, "--shf-host-del", name)
456
+ end
457
+ end
458
+
441
459
  def verify!
442
460
  execute('--version', retryable: true)
443
461
  end
@@ -25,6 +25,10 @@ module VagrantPlugins
25
25
  comm.sudo("ln -s \"/Volumes/SharedFolders/#{name}\" \"#{guestpath}\"")
26
26
  end
27
27
  end
28
+
29
+ def self.unmount_parallels_shared_folder(machine, guestpath, options)
30
+ machine.communicate.sudo("rm #{guestpath}", error_check: false)
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -35,6 +35,10 @@ module VagrantPlugins
35
35
  end
36
36
  end
37
37
  end
38
+
39
+ def self.unmount_parallels_shared_folder(machine, guestpath, options)
40
+ machine.communicate.sudo("rm #{guestpath}", error_check: false)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -35,21 +35,36 @@ module VagrantPlugins
35
35
  GuestDarwinCap::MountParallelsSharedFolder
36
36
  end
37
37
 
38
+ guest_capability(:darwin, :unmount_parallels_shared_folder) do
39
+ require_relative "guest_cap/darwin/mount_parallels_shared_folder"
40
+ GuestDarwinCap::MountParallelsSharedFolder
41
+ end
42
+
38
43
  guest_capability(:linux, :mount_parallels_shared_folder) do
39
44
  require_relative "guest_cap/linux/mount_parallels_shared_folder"
40
45
  GuestLinuxCap::MountParallelsSharedFolder
41
46
  end
42
47
 
43
- provider_capability("parallels", "public_address") do
48
+ guest_capability(:linux, :unmount_virtualbox_shared_folder) do
49
+ require_relative "guest_cap/linux/mount_virtualbox_shared_folder"
50
+ GuestLinuxCap::MountParallelsSharedFolder
51
+ end
52
+
53
+ provider_capability(:parallels, :public_address) do
44
54
  require_relative "cap/public_address"
45
55
  Cap::PublicAddress
46
56
  end
47
57
 
48
- provider_capability("parallels", "host_address") do
58
+ provider_capability(:parallels, :host_address) do
49
59
  require_relative "cap/host_address"
50
60
  Cap::HostAddress
51
61
  end
52
62
 
63
+ provider_capability(:parallels, :nic_mac_addresses) do
64
+ require_relative "cap/nic_mac_addresses"
65
+ Cap::NicMacAddresses
66
+ end
67
+
53
68
  synced_folder(:parallels) do
54
69
  require File.expand_path("../synced_folder", __FILE__)
55
70
  SyncedFolder
@@ -6,6 +6,19 @@ module VagrantPlugins
6
6
  class Provider < Vagrant.plugin("2", :provider)
7
7
  attr_reader :driver
8
8
 
9
+ def self.usable?(raise_error=false)
10
+ # Instantiate the driver, which will determine the Parallels Desktop
11
+ # version and all that, which checks for Parallels Desktop being present
12
+ Driver::Meta.new
13
+ true
14
+ rescue VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion
15
+ raise if raise_error
16
+ return false
17
+ rescue VagrantPlugins::Parallels::Errors::ParallelsNotDetected
18
+ raise if raise_error
19
+ return false
20
+ end
21
+
9
22
  def initialize(machine)
10
23
  @logger = Log4r::Logger.new("vagrant::provider::parallels")
11
24
  @machine = machine
@@ -48,9 +61,8 @@ module VagrantPlugins
48
61
 
49
62
  # Returns the SSH info for accessing the Parallels VM.
50
63
  def ssh_info
51
- # If the VM is not created then we cannot possibly SSH into it, so
52
- # we return nil.
53
- return nil if state.id == :not_created
64
+ # If the VM is not running that we can't possibly SSH into it
65
+ return nil if state.id != :running
54
66
 
55
67
  detected_ip = @driver.read_guest_ip
56
68
 
@@ -80,6 +92,11 @@ module VagrantPlugins
80
92
  short = state_id.to_s.gsub("_", " ")
81
93
  long = I18n.t("vagrant_parallels.commands.status.#{state_id}")
82
94
 
95
+ # If machine is not created, then specify the special ID flag
96
+ if state_id == :not_created
97
+ state_id = Vagrant::MachineState::NOT_CREATED_ID
98
+ end
99
+
83
100
  # Return the state
84
101
  Vagrant::MachineState.new(state_id, short, long)
85
102
  end
@@ -3,21 +3,25 @@ require "vagrant/util/platform"
3
3
  module VagrantPlugins
4
4
  module Parallels
5
5
  class SyncedFolder < Vagrant.plugin("2", :synced_folder)
6
- def usable?(machine)
6
+ def usable?(machine, raise_errors=false)
7
7
  # These synced folders only work if the provider is Parallels
8
- machine.provider_name == :parallels
8
+ machine.provider_name == :parallels &&
9
+ machine.provider_config.functional_psf
9
10
  end
10
11
 
11
- def prepare(machine, folders, _opts)
12
+ def enable(machine, folders, _opts)
13
+ # Export the shared folders to the VM
12
14
  defs = []
13
15
  folders.each do |id, data|
14
- hostpath = Vagrant::Util::Platform.cygwin_windows_path(data[:hostpath])
16
+ hostpath = data[:hostpath]
17
+ if !data[:hostpath_exact]
18
+ hostpath = Vagrant::Util::Platform.cygwin_windows_path(hostpath)
19
+ end
20
+
15
21
 
16
22
  defs << {
17
- # Escape special symbols (Parallels Shared Folders specific)
18
- name: id.split('/').delete_if{|i| i.empty?}.join('_'),
23
+ name: os_friendly_id(id),
19
24
  hostpath: hostpath.to_s,
20
- transient: data[:transient],
21
25
  }
22
26
  end
23
27
 
@@ -25,9 +29,7 @@ module VagrantPlugins
25
29
  # Anyway, duplicates will be mounted later.
26
30
  defs.uniq! { |d| d[:hostpath] }
27
31
  driver(machine).share_folders(defs)
28
- end
29
32
 
30
- def enable(machine, folders, _opts)
31
33
  # short guestpaths first, so we don't step on ourselves
32
34
  folders = folders.sort_by do |id, data|
33
35
  if data[:guestpath]
@@ -48,8 +50,6 @@ module VagrantPlugins
48
50
  id = shf_config.key(data[:hostpath])
49
51
 
50
52
  if data[:guestpath] and id
51
- id = Pathname.new(id).to_s.split('/').drop_while{|i| i.empty?}.join('_')
52
-
53
53
  # Guest path specified, so mount the folder to specified point
54
54
  machine.ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
55
55
  guestpath: data[:guestpath],
@@ -74,6 +74,20 @@ module VagrantPlugins
74
74
  end
75
75
  end
76
76
 
77
+ def disable(machine, folders, _opts)
78
+ if machine.guest.capability?(:unmount_parallels_shared_folder)
79
+ folders.each do |id, data|
80
+ machine.guest.capability(
81
+ :unmount_parallels_shared_folder,
82
+ data[:guestpath], data)
83
+ end
84
+ end
85
+
86
+ # Remove the shared folders from the VM metadata
87
+ names = folders.map { |id, _data| os_friendly_id(id) }
88
+ driver(machine).unshare_folders(names)
89
+ end
90
+
77
91
  def cleanup(machine, opts)
78
92
  driver(machine).clear_shared_folders if machine.id && machine.id != ""
79
93
  end
@@ -84,6 +98,10 @@ module VagrantPlugins
84
98
  def driver(machine)
85
99
  machine.provider.driver
86
100
  end
101
+
102
+ def os_friendly_id(id)
103
+ id.gsub(/[\/]/,'_').sub(/^_/, '')
104
+ end
87
105
  end
88
106
  end
89
107
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9.rc1"
4
4
  end
5
5
  end
@@ -3,13 +3,46 @@ require_relative "base"
3
3
  require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config')
4
4
 
5
5
  describe VagrantPlugins::Parallels::Config do
6
+ let(:machine) { double("machine") }
7
+
8
+ def assert_invalid
9
+ errors = subject.validate(machine)
10
+ if !errors.values.any? { |v| !v.empty? }
11
+ raise "No errors: #{errors.inspect}"
12
+ end
13
+ end
14
+
15
+ def assert_valid
16
+ errors = subject.validate(machine)
17
+ if !errors.values.all? { |v| v.empty? }
18
+ raise "Errors: #{errors.inspect}"
19
+ end
20
+ end
21
+
22
+ def valid_defaults
23
+ subject.image = "foo"
24
+ end
25
+
26
+ before do
27
+ vm_config = double("vm_config")
28
+ vm_config.stub(networks: [])
29
+ config = double("config")
30
+ config.stub(vm: vm_config)
31
+ machine.stub(config: config)
32
+ end
33
+
34
+ its "valid by default" do
35
+ subject.finalize!
36
+ assert_valid
37
+ end
6
38
 
7
39
  context "defaults" do
8
40
  before { subject.finalize! }
9
41
 
10
- its(:check_guest_tools) { should be_true }
11
- its(:name) { should be_nil }
12
- its(:optimize_power_consumption) { should be_true }
42
+ it { expect(subject.check_guest_additions).to be_true }
43
+ it { expect(subject.name).to be_nil }
44
+ it { expect(subject.functional_psf).to be_true }
45
+ it { expect(subject.optimize_power_consumption).to be_true }
13
46
 
14
47
  it "should have one Shared adapter" do
15
48
  expect(subject.network_adapters).to eql({
@@ -18,6 +51,22 @@ describe VagrantPlugins::Parallels::Config do
18
51
  end
19
52
  end
20
53
 
54
+ describe "#merge" do
55
+ let(:one) { described_class.new }
56
+ let(:two) { described_class.new }
57
+
58
+ subject { one.merge(two) }
59
+
60
+ it "merges the customizations" do
61
+ one.customize ["foo"]
62
+ two.customize ["bar"]
63
+
64
+ expect(subject.customizations).to eq([
65
+ ["pre-boot", ["foo"]],
66
+ ["pre-boot", ["bar"]]])
67
+ end
68
+ end
69
+
21
70
  describe "memory=" do
22
71
  it "configures memory size (in Mb)" do
23
72
  subject.memory=(1024)
@@ -181,6 +181,14 @@ shared_examples "parallels desktop driver" do |options|
181
181
  end
182
182
  end
183
183
 
184
+ describe "read_mac_addresses" do
185
+ it "returns MAC addresses of all network interface cards" do
186
+ subject.read_mac_addresses.should be_kind_of(Hash)
187
+ subject.read_mac_addresses.should include("0")
188
+ subject.read_mac_addresses["0"].should be_kind_of(String)
189
+ end
190
+ end
191
+
184
192
  describe "read_settings" do
185
193
  it "returns a hash with detailed info about the VM" do
186
194
  subject.read_settings.should be_kind_of(Hash)
@@ -1,16 +1,23 @@
1
1
  require "vagrant"
2
2
  require_relative "base"
3
3
 
4
+ require VagrantPlugins::Parallels.source_root.join("lib/vagrant-parallels/config")
4
5
  require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/synced_folder')
5
6
 
6
7
  describe VagrantPlugins::Parallels::SyncedFolder do
7
8
  let(:machine) do
8
9
  double("machine").tap do |m|
10
+ m.stub(provider_config: VagrantPlugins::Parallels::Config.new)
11
+ m.stub(provider_name: :parallels)
9
12
  end
10
13
  end
11
14
 
12
15
  subject { described_class.new }
13
16
 
17
+ before do
18
+ machine.provider_config.finalize!
19
+ end
20
+
14
21
  describe "usable" do
15
22
  it "should be with parallels provider" do
16
23
  machine.stub(provider_name: :parallels)
@@ -21,6 +28,11 @@ describe VagrantPlugins::Parallels::SyncedFolder do
21
28
  machine.stub(provider_name: :virtualbox)
22
29
  subject.should_not be_usable(machine)
23
30
  end
31
+
32
+ it "should not be usable if not functional psf" do
33
+ machine.provider_config.functional_psf = false
34
+ expect(subject).to_not be_usable(machine)
35
+ end
24
36
  end
25
37
 
26
38
  describe "prepare" do
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.required_rubygems_version = ">= 1.3.6"
17
17
  spec.rubyforge_project = "vagrant-parallels"
18
18
 
19
- spec.add_development_dependency "bundler", "~> 1.5.2"
19
+ spec.add_development_dependency "bundler", ">= 1.5.2", "< 1.7.0"
20
20
  spec.add_development_dependency "rake"
21
21
  spec.add_development_dependency "minitest"
22
22
  spec.add_development_dependency "rspec", "~> 2.14.0"
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.8
4
+ version: 1.0.9.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Zholobov
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-07 00:00:00.000000000 Z
12
+ date: 2014-05-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: 1.5.2
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: 1.7.0
21
24
  type: :development
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - ~>
28
+ - - '>='
26
29
  - !ruby/object:Gem::Version
27
30
  version: 1.5.2
31
+ - - <
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.0
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: rake
30
36
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +130,7 @@ files:
124
130
  - lib/vagrant-parallels/action/suspend.rb
125
131
  - lib/vagrant-parallels/action.rb
126
132
  - lib/vagrant-parallels/cap/host_address.rb
133
+ - lib/vagrant-parallels/cap/nic_mac_addresses.rb
127
134
  - lib/vagrant-parallels/cap/public_address.rb
128
135
  - lib/vagrant-parallels/config.rb
129
136
  - lib/vagrant-parallels/driver/base.rb
@@ -142,7 +149,6 @@ files:
142
149
  - locales/en.yml
143
150
  - Rakefile
144
151
  - README.md
145
- - rel_1.0.7_commit.txt
146
152
  - tasks/bundler.rake
147
153
  - tasks/test.rake
148
154
  - test/unit/base.rb
data/rel_1.0.7_commit.txt DELETED
@@ -1,9 +0,0 @@
1
- driver: removed unnecessary 'version' method.
2
- action/import: Regenerate 'SourceVmUuid' while template registration [GH-113]
3
- driver: added 'regen_src_uuid' argument to the 'register' method
4
- tests/unit: added tests for 'set_power_consumption_mode' driver method
5
- Added 'SetPowerConsumption' action. [GH-110]
6
- gemspec: added 'minitest' dependency as a aorkaround for rspec warning about 'minitest/autorun'
7
- driver/meta: Don't show unreleased PD 10 version in the error message.
8
- Convert Parallels Desktop version to semantic-like format (x.y.z)
9
- errors: 'vm_name_exists' error key added