vagrant-parallels 0.2.0 → 0.2.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4daff90969e22a8bcb04c781f58bac65a49aee0e
4
+ data.tar.gz: 40e3c147c12794c1fbbbde625ff0f98b17651e8f
5
+ SHA512:
6
+ metadata.gz: d9c65806dcf82814e93cc394ccbbcf2ee8248584ff9dd46604b8b8fc1df0226d74371892b7a7348c60cdc51bc3b19624830be0bffff5faa22cd1be7cb2acbe93
7
+ data.tar.gz: 40ff69f74c702c2089c74f15b027878cf7b46bdee6b6fe76db0099ffe2418c4763b92bb263f4d938cdad780c20ef08ad2a48c5b61feb3928594a6f8a4fec8a70
data/Gemfile CHANGED
@@ -7,8 +7,5 @@ group :development do
7
7
  # We depend on Vagrant for development, but we don't add it as a
8
8
  # gem dependency because we expect to be installed within the
9
9
  # Vagrant environment itself using `vagrant plugin`.
10
- gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.4.1'
11
- gem 'vagrant-spec', git: "https://github.com/mitchellh/vagrant-spec.git"
12
- gem 'debugger-xml'
13
- gem 'pry'
10
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.4.3'
14
11
  end
@@ -1,11 +1,7 @@
1
- require "fileutils"
2
-
3
1
  module VagrantPlugins
4
2
  module Parallels
5
3
  module Action
6
4
  class Export
7
- attr_reader :temp_dir
8
-
9
5
  include Util
10
6
 
11
7
  def initialize(app, env)
@@ -18,33 +14,17 @@ module VagrantPlugins
18
14
  raise Vagrant::Errors::VMPowerOffToPackage if \
19
15
  @env[:machine].provider.state.id != :stopped
20
16
 
21
- setup_temp_dir
22
17
  export
23
18
  compact
24
19
 
25
20
  @app.call(env)
26
-
27
- recover(env) # called to cleanup temp directory
28
- end
29
-
30
- def recover(env)
31
- if temp_dir && File.exist?(temp_dir)
32
- FileUtils.rm_rf(temp_dir)
33
- end
34
- end
35
-
36
- def setup_temp_dir
37
- @env[:ui].info I18n.t("vagrant.actions.vm.export.create_dir")
38
- @temp_dir = @env["export.temp_dir"] = @env[:tmp_path].join(Time.now.to_i.to_s)
39
- FileUtils.mkpath(@env["export.temp_dir"])
40
21
  end
41
22
 
42
- #TODO: cleanup registered VM on interupt
43
23
  def export
44
- vm_name = generate_name(@env[:root_path], '_export')
24
+ temp_vm_name = generate_name(@env[:root_path], '_export')
45
25
 
46
26
  @env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
47
- @uuid = @env[:machine].provider.driver.export(@env["export.temp_dir"], vm_name) do |progress|
27
+ @temp_vm_uuid = @env[:machine].provider.driver.export(@env["export.temp_dir"], temp_vm_name) do |progress|
48
28
  @env[:ui].clear_line
49
29
  @env[:ui].report_progress(progress, 100, false)
50
30
  end
@@ -56,11 +36,11 @@ module VagrantPlugins
56
36
 
57
37
  def compact
58
38
  @env[:ui].info I18n.t("vagrant_parallels.actions.vm.export.compacting")
59
- @env[:machine].provider.driver.compact(@uuid) do |progress|
39
+ @env[:machine].provider.driver.compact(@temp_vm_uuid) do |progress|
60
40
  @env[:ui].clear_line
61
41
  @env[:ui].report_progress(progress, 100, false)
62
42
  end
63
- @env[:machine].provider.driver.unregister(@uuid)
43
+ @env[:machine].provider.driver.unregister(@temp_vm_uuid)
64
44
 
65
45
  # Clear the line a final time so the next data can appear
66
46
  # alone on the line.
@@ -49,6 +49,9 @@ module VagrantPlugins
49
49
  if env[:machine].provider.state.id != :not_created
50
50
  return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
51
51
 
52
+ # If we're not supposed to destroy on error then just return
53
+ return if !env[:destroy_on_error]
54
+
52
55
  # Interrupted, destroy the VM. We note that we don't want to
53
56
  # validate the configuration here, and we don't want to confirm
54
57
  # we want to destroy.
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  require 'vagrant/action/general/package'
2
4
 
3
5
  module VagrantPlugins
@@ -8,11 +10,33 @@ module VagrantPlugins
8
10
  # called in the unit tests.
9
11
  alias_method :general_call, :call
10
12
  def call(env)
13
+ # Setup the temporary directory
14
+ @temp_dir = env[:tmp_path].join(Time.now.to_i.to_s)
15
+ env["export.temp_dir"] = @temp_dir
16
+ FileUtils.mkpath(env["export.temp_dir"])
17
+
11
18
  # Just match up a couple environmental variables so that
12
19
  # the superclass will do the right thing. Then, call the
13
20
  # superclass
14
21
  env["package.directory"] = env["export.temp_dir"]
22
+
15
23
  general_call(env)
24
+
25
+ # Always call recover to clean up the temp dir
26
+ clean_temp_dir
27
+ end
28
+
29
+ def recover(env)
30
+ clean_temp_dir
31
+ super
32
+ end
33
+
34
+ protected
35
+
36
+ def clean_temp_dir
37
+ if @temp_dir && File.exist?(@temp_dir)
38
+ FileUtils.rm_rf(@temp_dir)
39
+ end
16
40
  end
17
41
  end
18
42
  end
@@ -0,0 +1,53 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module Parallels
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
+ # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs
27
+ name = prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
28
+ end
29
+
30
+ # Verify the name is not taken
31
+ vms_names = env[:machine].provider.driver.read_all_names
32
+ raise Vagrant::Errors::VMNameExists, :name => name if \
33
+ vms_names.has_key?(name) && vms_names[name] != env[:machine].id
34
+
35
+ if vms_names.has_key?(name)
36
+ @logger.info("Not setting the name because our name is already set.")
37
+ else
38
+ env[:ui].info(I18n.t(
39
+ "vagrant.actions.vm.set_name.setting_name", name: name))
40
+ env[:machine].provider.driver.set_name(name)
41
+ end
42
+
43
+ # Create the sentinel
44
+ sentinel.open("w") do |f|
45
+ f.write(Time.now.to_i.to_s)
46
+ end
47
+
48
+ @app.call(env)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -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 SetName
15
16
  # b.use ClearForwardedPorts
16
17
  b.use Provision
17
18
  b.use EnvSet, :port_collision_repair => true
@@ -29,7 +30,7 @@ module VagrantPlugins
29
30
  b.use Customize, "pre-boot"
30
31
  b.use Boot
31
32
  b.use Customize, "post-boot"
32
- b.use WaitForCommunicator
33
+ b.use WaitForCommunicator, [:starting, :running]
33
34
  b.use CheckGuestTools
34
35
  end
35
36
  end
@@ -51,9 +52,9 @@ module VagrantPlugins
51
52
  b3.use CheckAccessible
52
53
  b3.use EnvSet, :force_halt => true
53
54
  b3.use action_halt
54
- b3.use UnregisterTemplate
55
55
  b3.use Destroy
56
56
  b3.use DestroyUnusedNetworkInterfaces
57
+ b3.use ProvisionerCleanup
57
58
  b3.use PrepareNFSValidIds
58
59
  b3.use SyncedFolderCleanup
59
60
  else
@@ -106,9 +107,9 @@ module VagrantPlugins
106
107
  #b2.use ClearForwardedPorts
107
108
  b2.use PrepareNFSValidIds
108
109
  b2.use SyncedFolderCleanup
110
+ b2.use Package
109
111
  b2.use Export
110
112
  b2.use PackageConfigFiles
111
- b2.use Package
112
113
  end
113
114
  end
114
115
  end
@@ -166,6 +167,7 @@ module VagrantPlugins
166
167
  b2.use CheckAccessible
167
168
  b2.use EnvSet, :port_collision_repair => false
168
169
  b2.use Resume
170
+ b2.use WaitForCommunicator, [:resuming, :running]
169
171
  else
170
172
  b2.use MessageNotCreated
171
173
  end
@@ -236,7 +238,6 @@ module VagrantPlugins
236
238
  b2.use MessageNotCreated
237
239
  end
238
240
  end
239
-
240
241
  end
241
242
  end
242
243
 
@@ -245,12 +246,21 @@ module VagrantPlugins
245
246
  def self.action_up
246
247
  Vagrant::Action::Builder.new.tap do |b|
247
248
  b.use CheckParallels
249
+
250
+ # Handle box_url downloading early so that if the Vagrantfile
251
+ # references any files in the box or something it all just
252
+ # works fine.
253
+ b.use Call, Created do |env, b2|
254
+ if !env[:result]
255
+ b2.use HandleBoxUrl
256
+ end
257
+ end
258
+
248
259
  b.use ConfigValidate
249
260
  b.use Call, Created do |env, b2|
250
261
  # If the VM is NOT created yet, then do the setup steps
251
262
  if !env[:result]
252
263
  b2.use CheckAccessible
253
- b2.use HandleBoxUrl
254
264
  b2.use RegisterTemplate
255
265
  b2.use Customize, "pre-import"
256
266
  b2.use Import
@@ -291,6 +301,7 @@ module VagrantPlugins
291
301
  autoload :RegisterTemplate, File.expand_path("../action/register_template", __FILE__)
292
302
  autoload :Resume, File.expand_path("../action/resume", __FILE__)
293
303
  autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__)
304
+ autoload :SetName, File.expand_path("../action/set_name", __FILE__)
294
305
  autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
295
306
  autoload :UnregisterTemplate, File.expand_path("../action/unregister_template", __FILE__)
296
307
 
@@ -25,6 +25,15 @@ module VagrantPlugins
25
25
  @network_adapters[slot] = [type, args]
26
26
  end
27
27
 
28
+ # @param size [Integer, String] the memory size in MB
29
+ def memory=(size)
30
+ customize("pre-boot", ["set", :id, "--memsize", size.to_s])
31
+ end
32
+
33
+ def cpus=(count)
34
+ customize("pre-boot", ["set", :id, "--cpus", count.to_i])
35
+ end
36
+
28
37
  def finalize!
29
38
  if @destroy_unused_network_interfaces == UNSET_VALUE
30
39
  @destroy_unused_network_interfaces = true
@@ -34,7 +43,7 @@ module VagrantPlugins
34
43
  end
35
44
 
36
45
  def validate(machine)
37
- errors = []
46
+ errors = _detected_errors
38
47
  valid_events = ["pre-import", "pre-boot", "post-boot"]
39
48
  @customizations.each do |event, _|
40
49
  if !valid_events.include?(event)
@@ -390,6 +390,10 @@ module VagrantPlugins
390
390
  execute('resume', @uuid)
391
391
  end
392
392
 
393
+ def set_name(name)
394
+ execute('set', @uuid, '--name', name, :retryable => true)
395
+ end
396
+
393
397
  def set_mac_address(mac)
394
398
  execute('set', @uuid, '--device-set', 'net0', '--type', 'shared', '--mac', mac)
395
399
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -0,0 +1,30 @@
1
+ require_relative "../unit/base"
2
+
3
+ require VagrantPlugins::Parallels.source_root.join('lib/vagrant-parallels/config')
4
+
5
+ describe VagrantPlugins::Parallels::Config do
6
+
7
+ context "defaults" do
8
+ before { subject.finalize! }
9
+
10
+ it "should have one Shared adapter" do
11
+ expect(subject.network_adapters).to eql({
12
+ 0 => [:shared, []],
13
+ })
14
+ end
15
+ end
16
+
17
+ describe "memory=" do
18
+ it "configures memory size (in Mb)" do
19
+ subject.memory=(1024)
20
+ expect(subject.customizations).to include(["pre-boot", ["set", :id, "--memsize", '1024']])
21
+ end
22
+ end
23
+
24
+ describe "cpus=" do
25
+ it "configures count of cpus" do
26
+ subject.cpus=('4')
27
+ expect(subject.customizations).to include(["pre-boot", ["set", :id, "--cpus", 4]])
28
+ end
29
+ end
30
+ end
@@ -83,6 +83,16 @@ describe VagrantPlugins::Parallels::Driver::PrlCtl do
83
83
  end
84
84
  end
85
85
 
86
+ describe "set_name" do
87
+ it "sets new name for the VM" do
88
+ subprocess.should_receive(:execute).
89
+ with("prlctl", "set", uuid, '--name', an_instance_of(String), an_instance_of(Hash)).
90
+ and_return(subprocess_result(stdout: "Settings applied"))
91
+
92
+ subject.set_name('new_vm_name')
93
+ end
94
+ end
95
+
86
96
  describe "set_mac_address" do
87
97
  it "sets base MAC address to the Shared network adapter" do
88
98
  subprocess.should_receive(:execute).exactly(2).times.
@@ -10,13 +10,13 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["yshahin@gmail.com"]
11
11
  spec.description = %q{Enables Vagrant to manage Parallels machines.}
12
12
  spec.summary = %q{Enables Vagrant to manage Parallels machines.}
13
- spec.homepage = "http://github.com/yshahin/vagrant-parallels"
13
+ spec.homepage = "http://github.com/Parallels/vagrant-parallels"
14
14
  spec.license = "MIT"
15
15
 
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.3"
19
+ spec.add_development_dependency "bundler", "~> 1.5.2"
20
20
  spec.add_development_dependency "rake"
21
21
  spec.add_development_dependency "rspec", "~> 2.14.0"
22
22
  spec.add_development_dependency "i18n-tasks", "~> 0.2.14"
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-parallels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Youssef Shahin
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ version: 1.5.2
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '1.3'
26
+ version: 1.5.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 2.14.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.14.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: i18n-tasks
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 0.2.14
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 0.2.14
78
69
  description: Enables Vagrant to manage Parallels machines.
@@ -82,9 +73,15 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
- - config/i18n-tasks.yml.erb
86
- - debug.log
76
+ - ".gitignore"
77
+ - ".travis.yml"
87
78
  - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - config/i18n-tasks.yml.erb
83
+ - lib/vagrant-parallels.rb
84
+ - lib/vagrant-parallels/action.rb
88
85
  - lib/vagrant-parallels/action/boot.rb
89
86
  - lib/vagrant-parallels/action/check_accessible.rb
90
87
  - lib/vagrant-parallels/action/check_created.rb
@@ -114,10 +111,10 @@ files:
114
111
  - lib/vagrant-parallels/action/prepare_nfs_valid_ids.rb
115
112
  - lib/vagrant-parallels/action/register_template.rb
116
113
  - lib/vagrant-parallels/action/resume.rb
114
+ - lib/vagrant-parallels/action/set_name.rb
117
115
  - lib/vagrant-parallels/action/setup_package_files.rb
118
116
  - lib/vagrant-parallels/action/suspend.rb
119
117
  - lib/vagrant-parallels/action/unregister_template.rb
120
- - lib/vagrant-parallels/action.rb
121
118
  - lib/vagrant-parallels/config.rb
122
119
  - lib/vagrant-parallels/driver/prl_ctl.rb
123
120
  - lib/vagrant-parallels/errors.rb
@@ -127,48 +124,39 @@ files:
127
124
  - lib/vagrant-parallels/provider.rb
128
125
  - lib/vagrant-parallels/synced_folder.rb
129
126
  - lib/vagrant-parallels/version.rb
130
- - lib/vagrant-parallels.rb
131
- - LICENSE.txt
132
127
  - locales/en.yml
133
- - Rakefile
134
- - README.md
135
128
  - tasks/bundler.rake
136
129
  - tasks/test.rake
137
130
  - test/support/isolated_environment.rb
138
131
  - test/support/tempdir.rb
139
132
  - test/unit/base.rb
133
+ - test/unit/config_test.rb
140
134
  - test/unit/driver/prl_ctl_test.rb
141
135
  - test/unit/locales/locales_test.rb
142
136
  - test/unit/support/shared/parallels_context.rb
143
137
  - vagrant-parallels.gemspec
144
- - .gitignore
145
- - .travis.yml
146
- homepage: http://github.com/yshahin/vagrant-parallels
138
+ homepage: http://github.com/Parallels/vagrant-parallels
147
139
  licenses:
148
140
  - MIT
141
+ metadata: {}
149
142
  post_install_message:
150
143
  rdoc_options: []
151
144
  require_paths:
152
145
  - lib
153
146
  required_ruby_version: !ruby/object:Gem::Requirement
154
- none: false
155
147
  requirements:
156
- - - ! '>='
148
+ - - ">="
157
149
  - !ruby/object:Gem::Version
158
150
  version: '0'
159
- segments:
160
- - 0
161
- hash: -4205879572170991901
162
151
  required_rubygems_version: !ruby/object:Gem::Requirement
163
- none: false
164
152
  requirements:
165
- - - ! '>='
153
+ - - ">="
166
154
  - !ruby/object:Gem::Version
167
155
  version: 1.3.6
168
156
  requirements: []
169
157
  rubyforge_project: vagrant-parallels
170
- rubygems_version: 1.8.23
158
+ rubygems_version: 2.2.0
171
159
  signing_key:
172
- specification_version: 3
160
+ specification_version: 4
173
161
  summary: Enables Vagrant to manage Parallels machines.
174
162
  test_files: []