vagrant-parallels 1.0.6 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c730a520f86bd6a644552153dc93e37bb88e2101
4
- data.tar.gz: e7a1c78c9bc2632dde5215ff010926beb7168a3d
3
+ metadata.gz: 5608c204b87b50e5b244203de68ed4a756b12439
4
+ data.tar.gz: e0b2110f1fb2c2c7da44f96653419cd6f6fd3c86
5
5
  SHA512:
6
- metadata.gz: 7e9eff6c30ec5fb09d20b8b6422c92e0bd3d2869c56a89ab31e27938a62c4e9b0b97b634beb97ac35c00af25c0fb9fe9291a7af2d576d635aaf16bf90ed654d4
7
- data.tar.gz: ac7b0e602a129cfc0075fbb68cc1e71f4f718d0bca81bdb3d14a45ac4d32019fa88955ef12a10a330a73510c469a5519bfa09464f396cd192a42ab858e56ba46
6
+ metadata.gz: a35ae225981d552e39c133c649f5e7feb9a81acea54ebee5c0d6454a51036315ae25ddf742e6ace0e55c78a2cbb79122a7b04c1df9e76cbf08653d1749f90728
7
+ data.tar.gz: 1abc3b1bd8851aae1c6a154a1911bb00e4605328a80a16948ad5a76ae27d15eb52fcd63547a29f25d218eb6b1f78da41ab4427bff2849d6eb79b463efaeb5e48
@@ -1,6 +1,7 @@
1
1
  require "pathname"
2
2
 
3
3
  require "vagrant-parallels/plugin"
4
+ require "vagrant-parallels/version"
4
5
 
5
6
  module VagrantPlugins
6
7
  module Parallels
@@ -12,6 +12,7 @@ module VagrantPlugins
12
12
  def self.action_boot
13
13
  Vagrant::Action::Builder.new.tap do |b|
14
14
  b.use CheckAccessible
15
+ b.use SetPowerConsumption
15
16
  b.use SetName
16
17
  # b.use ClearForwardedPorts
17
18
  b.use Provision
@@ -298,6 +299,7 @@ module VagrantPlugins
298
299
  autoload :Resume, File.expand_path("../action/resume", __FILE__)
299
300
  autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__)
300
301
  autoload :SetName, File.expand_path("../action/set_name", __FILE__)
302
+ autoload :SetPowerConsumption, File.expand_path("../action/set_power_consumption", __FILE__)
301
303
  autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
302
304
  end
303
305
  end
@@ -20,7 +20,7 @@ module VagrantPlugins
20
20
  env[:ui].warn I18n.t("vagrant_parallels.actions.vm.check_guest_tools.not_detected")
21
21
  else
22
22
  pd_version = env[:machine].provider.driver.version
23
- unless pd_version.start_with? tools_version
23
+ if Gem::Version.new(pd_version) != Gem::Version.new(tools_version)
24
24
  env[:ui].warn(I18n.t("vagrant_parallels.actions.vm.check_guest_tools.version_mismatch",
25
25
  :tools_version => tools_version,
26
26
  :parallels_version => pd_version))
@@ -48,7 +48,9 @@ module VagrantPlugins
48
48
  def register_template
49
49
  if !@env[:machine].provider.driver.read_vms_paths.has_key?(@template_path)
50
50
  @logger.info("Register the box template: '#{@template_path}'")
51
- @env[:machine].provider.driver.register(@template_path)
51
+ # We should also regenerate 'SourceVmUuid' to make sure that
52
+ # SMBIOS UUID is unique [GH-113]
53
+ @env[:machine].provider.driver.register(@template_path, regen_src_uuid=true)
52
54
  end
53
55
 
54
56
  # Return the uuid of registered template
@@ -0,0 +1,38 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class SetPowerConsumption
5
+ def initialize(app, env)
6
+ @logger = Log4r::Logger.new("vagrant::plugins::parallels::power_consumption")
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ pd_version = env[:machine].provider.driver.version
12
+ if Gem::Version.new(pd_version) < Gem::Version.new("9")
13
+ @logger.info("Power consumption management is available only for Parallels Desktop >= 9")
14
+ return @app.call(env)
15
+ end
16
+
17
+ # Optimization of power consumption is defined by "Longer Battery Life" state.
18
+ vm_settings = env[:machine].provider.driver.read_settings
19
+
20
+ old_val = vm_settings.fetch("Longer battery life") == "on" ? true : false
21
+ new_val = env[:machine].provider_config.optimize_power_consumption
22
+
23
+ if old_val == new_val
24
+ @logger.info("Skipping power consumption method because it is already set")
25
+ return @app.call(env)
26
+ end
27
+
28
+ mode = new_val ? "Longer battery life" : "Better Performance"
29
+ env[:ui].info I18n.t("vagrant_parallels.parallels.power_consumption.set_mode",
30
+ mode: mode)
31
+ env[:machine].provider.driver.set_power_consumption_mode(new_val)
32
+
33
+ @app.call(env)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -2,20 +2,23 @@ module VagrantPlugins
2
2
  module Parallels
3
3
  class Config < Vagrant.plugin("2", :config)
4
4
  attr_accessor :check_guest_tools
5
- attr_reader :customizations
5
+ attr_reader :customizations
6
6
  attr_accessor :destroy_unused_network_interfaces
7
- attr_reader :network_adapters
7
+ attr_accessor :optimize_power_consumption
8
8
  attr_accessor :name
9
+ attr_reader :network_adapters
10
+
9
11
 
10
12
  # Compatibility with virtualbox provider's syntax
11
13
  alias :check_guest_additions= :check_guest_tools=
12
14
 
13
15
  def initialize
14
16
  @check_guest_tools = UNSET_VALUE
15
- @customizations = []
17
+ @customizations = []
16
18
  @destroy_unused_network_interfaces = UNSET_VALUE
17
19
  @network_adapters = {}
18
- @name = UNSET_VALUE
20
+ @name = UNSET_VALUE
21
+ @optimize_power_consumption = UNSET_VALUE
19
22
 
20
23
  network_adapter(0, :shared)
21
24
  end
@@ -48,6 +51,10 @@ module VagrantPlugins
48
51
  @destroy_unused_network_interfaces = true
49
52
  end
50
53
 
54
+ if @optimize_power_consumption == UNSET_VALUE
55
+ @optimize_power_consumption = true
56
+ end
57
+
51
58
  @name = nil if @name == UNSET_VALUE
52
59
  end
53
60
 
@@ -182,7 +182,11 @@ module VagrantPlugins
182
182
  end
183
183
 
184
184
  # Registers the virtual machine
185
- def register(pvm_file)
185
+ #
186
+ # @param [String] pvm_file Path to the machine image (*.pvm)
187
+ # @param [Boolean] regen_src_uuid Regenerate SourceVmUuid to avoid
188
+ # SMBIOS UUID collision
189
+ def register(pvm_file, regen_src_uuid)
186
190
  end
187
191
 
188
192
  # Resumes the virtual machine.
@@ -202,6 +206,13 @@ module VagrantPlugins
202
206
  def set_name(name)
203
207
  end
204
208
 
209
+ # Sets Power Consumption method.
210
+ #
211
+ # @param [Boolean] optimized Use "Longer Battery Life"
212
+ # instead "Better Performance"
213
+ def set_power_consumption_mode(optimized)
214
+ end
215
+
205
216
  # Share a set of folders on this VM.
206
217
  #
207
218
  # @param [Array<Hash>] folders
@@ -42,7 +42,6 @@ module VagrantPlugins
42
42
  # Instantiate the proper version driver for VirtualBox
43
43
  @logger.debug("Finding driver for Parallels Desktop version: #{@version}")
44
44
  driver_map = {
45
- #TODO: Use customized class for each version
46
45
  "8" => PD_8,
47
46
  "9" => PD_9,
48
47
  "10" => PD_9
@@ -57,9 +56,14 @@ module VagrantPlugins
57
56
  end
58
57
 
59
58
  if !driver_klass
60
- supported_versions = driver_map.keys.sort.join(", ")
59
+ supported_versions = driver_map.keys.sort
60
+
61
+ # TODO: Remove this after PD 10 release
62
+ # Don't show unreleased version in the error message
63
+ supported_versions.delete("10")
64
+
61
65
  raise VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion,
62
- supported_versions: supported_versions
66
+ supported_versions: supported_versions.join(", ")
63
67
  end
64
68
 
65
69
  @logger.info("Using Parallels driver: #{driver_klass}")
@@ -103,6 +107,7 @@ module VagrantPlugins
103
107
  :register,
104
108
  :registered?,
105
109
  :resume,
110
+ :set_power_consumption_mode,
106
111
  :set_mac_address,
107
112
  :set_name,
108
113
  :share_folders,
@@ -121,11 +126,14 @@ module VagrantPlugins
121
126
  def read_version
122
127
  # The version string is usually in one of the following formats:
123
128
  #
124
- # * 8.0.12345.123456
125
- # * 9.0.12345.123456
129
+ # * prlctl version 8.0.12345.123456
130
+ # * prlctl version 9.0.12345.123456
131
+ # * prlctl version 10.0.0 (12345) rev 123456
132
+ #
133
+ # But we need exactly the first 3 numbers: "x.x.x"
126
134
 
127
- if execute('--version', retryable: true) =~ /prlctl version ([\d\.]+)/
128
- return $1.downcase
135
+ if execute('--version', retryable: true) =~ /prlctl version (\d+\.\d+.\d+)/
136
+ return $1
129
137
  else
130
138
  return nil
131
139
  end
@@ -235,7 +235,8 @@ module VagrantPlugins
235
235
  end
236
236
 
237
237
  def read_guest_tools_version
238
- read_settings.fetch('GuestTools', {}).fetch('version', nil)
238
+ tools_version = read_settings.fetch('GuestTools', {}).fetch('version', '')
239
+ tools_version[/(^\d+\.\d+.\d+)/]
239
240
  end
240
241
 
241
242
  def read_host_info
@@ -392,8 +393,10 @@ module VagrantPlugins
392
393
  list
393
394
  end
394
395
 
395
- def register(pvm_file)
396
- execute("register", pvm_file)
396
+ def register(pvm_file, regen_src_uuid=false)
397
+ args = ['register', pvm_file]
398
+ args << '--regenerate-src-uuid' if regen_src_uuid
399
+ execute(*args)
397
400
  end
398
401
 
399
402
  def registered?(uuid)
@@ -436,15 +439,7 @@ module VagrantPlugins
436
439
  end
437
440
 
438
441
  def verify!
439
- version
440
- end
441
-
442
- def version
443
- if execute('--version', retryable: true) =~ /prlctl version ([\d\.]+)/
444
- $1.downcase
445
- else
446
- raise VagrantPlugins::Parallels::Errors::ParallelsInstallIncomplete
447
- end
442
+ execute('--version', retryable: true)
448
443
  end
449
444
 
450
445
  def vm_exists?(uuid)
@@ -52,6 +52,11 @@ module VagrantPlugins
52
52
  end
53
53
  vms_arr | templates_arr
54
54
  end
55
+
56
+ def set_power_consumption_mode(optimized)
57
+ state = optimized ? 'on' : 'off'
58
+ execute('set', @uuid, '--longer-battery-life', state)
59
+ end
55
60
  end
56
61
  end
57
62
  end
@@ -11,6 +11,10 @@ module VagrantPlugins
11
11
  error_key(:dhcp_leases_file_not_accessible)
12
12
  end
13
13
 
14
+ class MacOSXRequired < VagrantParallelsError
15
+ error_key(:mac_os_x_required)
16
+ end
17
+
14
18
  class PrlCtlError < VagrantParallelsError
15
19
  error_key(:prlctl_error)
16
20
  end
@@ -35,8 +39,8 @@ module VagrantPlugins
35
39
  error_key(:vm_inaccessible)
36
40
  end
37
41
 
38
- class MacOSXRequired < VagrantParallelsError
39
- error_key(:mac_os_x_required)
42
+ class VMNameExists < VagrantParallelsError
43
+ error_key(:vm_name_exists)
40
44
  end
41
45
  end
42
46
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -3,6 +3,9 @@ en:
3
3
  parallels:
4
4
  checking_guest_tools: |-
5
5
  Checking for Parallels Tools installed on the VM...
6
+ power_consumption:
7
+ set_mode: |-
8
+ Setting power consumption mode: "%{mode}"
6
9
  network_adapter: |-
7
10
  Adapter %{adapter}: %{type}%{extra}
8
11
  #-------------------------------------------------------------------------------
@@ -0,0 +1,9 @@
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
@@ -9,6 +9,7 @@ describe VagrantPlugins::Parallels::Config do
9
9
 
10
10
  its(:check_guest_tools) { should be_true }
11
11
  its(:name) { should be_nil }
12
+ its(:optimize_power_consumption) { should be_true }
12
13
 
13
14
  it "should have one Shared adapter" do
14
15
  expect(subject.network_adapters).to eql({
@@ -9,6 +9,8 @@ describe VagrantPlugins::Parallels::Driver::PD_8 do
9
9
  let(:tpl_uuid) {'1234-some-template-uuid-5678'}
10
10
  let(:tpl_name) {'Some_Template_Name'}
11
11
 
12
+ let(:tools_version) {'8.0.18615.123456'}
13
+
12
14
  let(:hostonly_iface) {'vnic10'}
13
15
 
14
16
  let(:vnic_options) do {
@@ -73,7 +75,7 @@ INFO[
73
75
  "State": "stopped",
74
76
  "Home": "/path/to/#{vm_name}.pvm/",
75
77
  "GuestTools": {
76
- "version": "8.0.18615"
78
+ "version": "#{tools_version}"
77
79
  },
78
80
  "Hardware": {
79
81
  "cpu": {
@@ -133,7 +135,7 @@ INFO[
133
135
  "State": "stopped",
134
136
  "Home": "/path/to/#{tpl_name}.pvm/",
135
137
  "GuestTools": {
136
- "version": "8.0.18615"
138
+ "version": "#{tools_version}"
137
139
  },
138
140
  "Hardware": {
139
141
  "cpu": {
@@ -9,6 +9,8 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
9
9
  let(:tpl_uuid) {'1234-some-template-uuid-5678'}
10
10
  let(:tpl_name) {'Some_Template_Name'}
11
11
 
12
+ let(:tools_version) {'9.0.23062.123456'}
13
+
12
14
  let(:hostonly_iface) {'vnic10'}
13
15
 
14
16
  let(:vnic_options) do {
@@ -73,7 +75,7 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
73
75
  "State": "stopped",
74
76
  "Home": "/path/to/#{vm_name}.pvm/",
75
77
  "GuestTools": {
76
- "version": "9.0.23062"
78
+ "version": "#{tools_version}"
77
79
  },
78
80
  "Hardware": {
79
81
  "cpu": {
@@ -133,7 +135,7 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
133
135
  "State": "stopped",
134
136
  "Home": "/path/to/#{tpl_name}.pvm/",
135
137
  "GuestTools": {
136
- "version": "9.0.24172"
138
+ "version": "#{tools_version}"
137
139
  },
138
140
  "Hardware": {
139
141
  "cpu": {
@@ -193,4 +195,24 @@ describe VagrantPlugins::Parallels::Driver::PD_9 do
193
195
  end
194
196
 
195
197
  end
198
+
199
+ describe "set_power_consumption_mode" do
200
+ it "turns 'longer-battery-life' on" do
201
+ subprocess.should_receive(:execute).
202
+ with("prlctl", "set", uuid, "--longer-battery-life", "on",
203
+ an_instance_of(Hash)).
204
+ and_return(subprocess_result(exit_code: 0))
205
+
206
+ subject.set_power_consumption_mode(true)
207
+ end
208
+
209
+ it "turns 'longer-battery-life' off" do
210
+ subprocess.should_receive(:execute).
211
+ with("prlctl", "set", uuid, "--longer-battery-life", "off",
212
+ an_instance_of(Hash)).
213
+ and_return(subprocess_result(exit_code: 0))
214
+
215
+ subject.set_power_consumption_mode(false)
216
+ end
217
+ end
196
218
  end
@@ -20,7 +20,7 @@ shared_context "parallels" do
20
20
  # Parallels Desktop version, so wire this stub in automatically
21
21
  subprocess.stub(:execute).
22
22
  with("prlctl", "--version", an_instance_of(Hash)).
23
- and_return(subprocess_result(stdout: "prlctl version #{parallels_version}.23456.987654"))
23
+ and_return(subprocess_result(stdout: "prlctl version #{parallels_version}.0.98765"))
24
24
 
25
25
  # drivers also call vm_exists? during init;
26
26
  subprocess.stub(:execute).
@@ -146,6 +146,21 @@ shared_examples "parallels desktop driver" do |options|
146
146
  end
147
147
  end
148
148
 
149
+ describe "read_guest_tools_version" do
150
+ let(:tools_version) {'9.0.23062.123456-something-else'}
151
+
152
+ it "returns Guest Tools version in semantic format: 'x.y.z'" do
153
+ subject.read_guest_tools_version.should match(/^\d+.\d+\.\d+$/)
154
+ subject.read_guest_tools_version.should == "9.0.23062"
155
+ end
156
+
157
+ it "returns nil if Guest Tools version is invalid" do
158
+ settings = {"GuestTools" => {"vesion" => "something_wrong"}}
159
+ driver.should_receive(:read_settings).and_return(settings)
160
+ subject.read_guest_tools_version.should be_nil
161
+ end
162
+ end
163
+
149
164
  describe "read_guest_ip" do
150
165
  let(:content) {'10.200.0.99="1394547632,1800,001c420000ff,01001c420000ff"'}
151
166
 
@@ -194,6 +209,25 @@ shared_examples "parallels desktop driver" do |options|
194
209
  end
195
210
  end
196
211
 
212
+ describe "register" do
213
+ it "registers specified virtual machine or template" do
214
+ subprocess.should_receive(:execute).
215
+ with("prlctl", "register", an_instance_of(String), an_instance_of(Hash)).
216
+ and_return(subprocess_result(exit_code: 0))
217
+
218
+ subject.register("/path/to/vm_image.pvm")
219
+ end
220
+
221
+ it "registers specified virtual machine or template and regen src uuid" do
222
+ subprocess.should_receive(:execute).
223
+ with("prlctl", "register", an_instance_of(String),
224
+ "--regenerate-src-uuid", an_instance_of(Hash)).
225
+ and_return(subprocess_result(exit_code: 0))
226
+
227
+ subject.register("/path/to/vm_image.pvm", regen_src_uuid=true)
228
+ end
229
+ end
230
+
197
231
  describe "set_mac_address" do
198
232
  it "sets base MAC address to the Shared network adapter" do
199
233
  subprocess.should_receive(:execute).exactly(2).times.
@@ -247,13 +281,13 @@ shared_examples "parallels desktop driver" do |options|
247
281
 
248
282
  describe "version" do
249
283
  it "parses the version from output" do
250
- subject.version.should match(/(#{parallels_version}[\d\.]+)/)
284
+ subject.version.should match(/^#{parallels_version}.\d+\.\d+$/)
251
285
  end
252
286
 
253
- it "rises ParallelsInvalidVersion exception when output is invalid" do
287
+ it "rises ParallelsInvalidVersion exception for unsupported version" do
254
288
  subprocess.should_receive(:execute).
255
289
  with("prlctl", "--version", an_instance_of(Hash)).
256
- and_return(subprocess_result(exit_code: 0))
290
+ and_return(subprocess_result(stdout: "prlctl version 7.0.12345"))
257
291
  expect { subject.version }.
258
292
  to raise_error(VagrantPlugins::Parallels::Errors::ParallelsInvalidVersion)
259
293
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.add_development_dependency "bundler", "~> 1.5.2"
20
20
  spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "minitest"
21
22
  spec.add_development_dependency "rspec", "~> 2.14.0"
22
23
  spec.add_development_dependency "i18n-tasks", "~> 0.3.9"
23
24
 
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.6
4
+ version: 1.0.7
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-25 00:00:00.000000000 Z
12
+ date: 2014-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: minitest
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: rspec
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +119,7 @@ files:
105
119
  - lib/vagrant-parallels/action/prepare_nfs_valid_ids.rb
106
120
  - lib/vagrant-parallels/action/resume.rb
107
121
  - lib/vagrant-parallels/action/set_name.rb
122
+ - lib/vagrant-parallels/action/set_power_consumption.rb
108
123
  - lib/vagrant-parallels/action/setup_package_files.rb
109
124
  - lib/vagrant-parallels/action/suspend.rb
110
125
  - lib/vagrant-parallels/action.rb
@@ -127,6 +142,7 @@ files:
127
142
  - locales/en.yml
128
143
  - Rakefile
129
144
  - README.md
145
+ - rel_1.0.7_commit.txt
130
146
  - tasks/bundler.rake
131
147
  - tasks/test.rake
132
148
  - test/unit/base.rb