vagrant-parallels 0.0.3.dev → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGU5YWFiMzVmN2ZiNjQ4NmM1Y2Q2YzY3YTY2ODg4ZmFmZjMyYTYzMA==
5
+ data.tar.gz: !binary |-
6
+ ZDFmMjZjZTZhMzc3M2M5MDUyMDdkZDhmZDIwYmJkNGEzMDA0ZmY0OQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OGFhZGQ5NTE5NGVhNGYwOTk1OWFhYmMzNThlMTFkNmYxZGY3ZjRmNDMxNmJh
10
+ YzhhZTMwNWVlZjYxMWMwMjlkMmY0ZjdmYzAxY2UzNDgzNTIzZjliNTU1YWMw
11
+ NzcyOWIwNDY4NTM5ZWFmY2NlOGY5N2M3ZjQ5NjkwNzVhNzFhYTA=
12
+ data.tar.gz: !binary |-
13
+ NzdhMzdlOTEyMzU1ZThkZTJhMTdjMzMzMTk1YzMyNTY3MzNkZmFjZWI1ZTlm
14
+ N2I1ZGYwY2U3NjM3YjA5ZjRhYjlmOTIxZTI3MTgyNjMwNjBlYTM3YTA2ZGUy
15
+ ZmE1MTdmOTRkOWZmNzI5ODljYmFlOTAyZjAyZTY3ZTE5Njg0Njc=
data/README.md CHANGED
@@ -1,19 +1,17 @@
1
1
  # Vagrant Parallels Provider
2
2
 
3
- This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [Parallels](http://www.parallels.com/products/desktop/)
4
- provider to Vagrant, allowing Vagrant to control and provision machines using Parallels insead of the default Virtualbox.
3
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [Parallels Desktop](http://www.parallels.com/products/desktop/)
4
+ provider to Vagrant, allowing Vagrant to control and provision machines using Parallels Desktop insead of the default Virtualbox.
5
5
 
6
6
  ## Note
7
7
 
8
8
  This project is still in active development and not all vagrant features have been developed, please report any issues you might find.
9
- Almost all features are available except for exporting/packaging VM's this will be available soon isA (ان شاء الله)
9
+ Almost all features are available except for exporting/packaging VM's this will be available soon.
10
10
 
11
11
  We look forward to hearing from you with any issues or features, Thank you
12
12
 
13
13
  ## Usage
14
-
15
- Install using standard Vagrant 1.1+ plugin installation methods. After
16
- installing, then do a `vagrant up` and specify the `parallels` provider. An example is shown below.
14
+ Install using standard Vagrant 1.1+ plugin installation methods. After installing, then do a `vagrant up` and specify the `parallels` provider. An example is shown below.
17
15
 
18
16
  ```
19
17
  $ vagrant plugin install vagrant-parallels
@@ -79,3 +77,16 @@ Use bundler to execute Vagrant:
79
77
  ```
80
78
  $ bundle exec vagrant up --provider=parallels
81
79
  ```
80
+
81
+ After testing you can also build a gem-package by yourself and then install it as a plugin:
82
+ (if you have 'vagrant-parallels' plugin already installed, delete it first)
83
+
84
+ ```
85
+ $ git clone https://github.com/yshahin/vagrant-parallels
86
+ $ cd vagrant-parallels
87
+ $ rake build
88
+ ...
89
+ $ vagrant plugin install ./pkg/vagrant-parallels-<version>.gem
90
+ ...
91
+ ```
92
+ So, now you have your own plugin installed, check it by command `vagrant plugin list`
@@ -15,16 +15,15 @@ module VagrantPlugins
15
15
  vm_name = prefix + "_#{Time.now.to_i}"
16
16
 
17
17
  # Verify the name is not taken
18
- if env[:machine].provider.driver.registered? vm_name
18
+ if env[:machine].provider.driver.read_all_names.has_key?(vm_name)
19
19
  raise Vagrant::Errors::VMNameExists, :name => vm_name
20
20
  end
21
21
 
22
22
  # Import the virtual machine
23
- template_name = Pathname.glob(
24
- env[:machine].box.directory.join('*.pvm')
25
- ).first.basename.to_s[0...-4]
23
+ template_path = File.realpath(Pathname.glob(env[:machine].box.directory.join('*.pvm')).first)
24
+ template_uuid = env[:machine].provider.driver.read_all_paths[template_path]
26
25
 
27
- env[:machine].id = env[:machine].provider.driver.import(template_name, vm_name) do |progress|
26
+ env[:machine].id = env[:machine].provider.driver.import(template_uuid, vm_name) do |progress|
28
27
  env[:ui].clear_line
29
28
  env[:ui].report_progress(progress, 100, false)
30
29
  end
@@ -8,7 +8,7 @@ module VagrantPlugins
8
8
 
9
9
  def call(env)
10
10
  if env[:host]
11
- vms = env[:machine].provider.driver.read_vms
11
+ vms = env[:machine].provider.driver.read_all_names
12
12
  env[:host].nfs_prune(vms.values)
13
13
  end
14
14
 
@@ -7,9 +7,11 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- pvm_file = Pathname.glob(env[:machine].box.directory.join('*.pvm')).first
10
+ pvm_glob = Pathname.glob(env[:machine].box.directory.join('*.pvm')).first
11
+ # TODO: Handle error cases better, throw a Vagrant error and not a stack trace etc.
12
+ pvm_file = File.realpath pvm_glob.to_s
11
13
 
12
- unless env[:machine].provider.driver.registered?(pvm_file.basename.to_s[0...-4])
14
+ unless env[:machine].provider.driver.registered?(pvm_file)
13
15
  env[:machine].provider.driver.register(pvm_file.to_s)
14
16
  end
15
17
  # Call the next if we have one (but we shouldn't, since this
@@ -106,8 +106,17 @@ module VagrantPlugins
106
106
  @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
107
107
  :guest_path => data[:guestpath]))
108
108
 
109
- # Symlink to mounted folder to guest path
110
- @env[:machine].provider.driver.symlink(id, data[:guestpath])
109
+ # Dup the data so we can pass it to the guest API
110
+ data = data.dup
111
+
112
+ # Calculate the owner and group
113
+ ssh_info = @env[:machine].ssh_info
114
+ data[:owner] ||= ssh_info[:username]
115
+ data[:group] ||= ssh_info[:username]
116
+
117
+ # Mount the actual folder
118
+ @env[:machine].guest.capability(
119
+ :mount_parallels_shared_folder, id, data[:guestpath], data)
111
120
  else
112
121
  # If no guest path is specified, then automounting is disabled
113
122
  @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry",
@@ -7,12 +7,14 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- vm_name = Pathname.glob(
10
+ template_path = File.realpath(Pathname.glob(
11
11
  env[:machine].box.directory.join('*.pvm')
12
- ).first.basename.to_s[0...-4]
12
+ ).first)
13
13
 
14
- if env[:machine].provider.driver.registered?(vm_name)
15
- env[:machine].provider.driver.unregister(vm_name)
14
+ template_uuid = env[:machine].provider.driver.read_all_paths[template_path]
15
+
16
+ if env[:machine].provider.driver.registered?(template_path)
17
+ env[:machine].provider.driver.unregister(template_uuid)
16
18
  end
17
19
  # Call the next if we have one (but we shouldn't, since this
18
20
  # middleware is built to run with the Call-type middlewares)
@@ -76,8 +76,9 @@ module VagrantPlugins
76
76
  end
77
77
 
78
78
  b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
79
- next if !env2[:result]
80
- b3.use ForcedHalt
79
+ if !env2[:result]
80
+ b3.use ForcedHalt
81
+ end
81
82
  end
82
83
  else
83
84
  b2.use MessageNotCreated
@@ -139,16 +140,14 @@ module VagrantPlugins
139
140
  # suspended machines.
140
141
  def self.action_resume
141
142
  Vagrant::Action::Builder.new.tap do |b|
142
- Vagrant::Action::Builder.new.tap do |b|
143
- b.use CheckParallels
144
- b.use Call, Created do |env, b2|
145
- if env[:result]
146
- b2.use CheckAccessible
147
- b2.use EnvSet, :port_collision_repair => false
148
- b2.use Resume
149
- else
150
- b2.use MessageNotCreated
151
- end
143
+ b.use CheckParallels
144
+ b.use Call, Created do |env, b2|
145
+ if env[:result]
146
+ b2.use CheckAccessible
147
+ b2.use EnvSet, :port_collision_repair => false
148
+ b2.use Resume
149
+ else
150
+ b2.use MessageNotCreated
152
151
  end
153
152
  end
154
153
  end
@@ -41,27 +41,27 @@ module VagrantPlugins
41
41
  read_settings(@uuid).fetch('State', 'inaccessible').to_sym
42
42
  end
43
43
 
44
- # Returns a hash of all UUIDs of virtual machines currently
45
- # known by Parallels. Hash keys is VM names
44
+ # Returns a hash of all UUIDs assigned to VMs and templates currently
45
+ # known by Parallels. Keys are 'name' values
46
46
  #
47
47
  # @return [Hash]
48
- def read_vms
48
+ def read_all_names
49
49
  list = {}
50
- json({}) { execute('list', '--all', '--json', retryable: true) }.each do |item|
51
- list[item.fetch('name')] = item.fetch('uuid')
50
+ read_all_info.each do |item|
51
+ list[item.fetch('Name')] = item.fetch('ID')
52
52
  end
53
53
 
54
54
  list
55
55
  end
56
56
 
57
- # Returns a hash of all UUIDs of VM templates currently
58
- # known by Parallels. Hash keys is template names
57
+ # Returns a hash of all UUIDs assigned to VMs and templates currently
58
+ # known by Parallels. Keys are 'Home' directories
59
59
  #
60
60
  # @return [Hash]
61
- def read_templates
61
+ def read_all_paths
62
62
  list = {}
63
- json({}) { execute('list', '--template', '--json', retryable: true) }.each do |item|
64
- list[item.fetch('name')] = item.fetch('uuid')
63
+ read_all_info.each do |item|
64
+ list[File.realpath item.fetch('Home')] = item.fetch('ID')
65
65
  end
66
66
 
67
67
  list
@@ -75,18 +75,24 @@ module VagrantPlugins
75
75
  #
76
76
  # This should raise a VagrantError if things are not ready.
77
77
  def verify!
78
+ # TODO: Use version method?
78
79
  execute('--version')
79
80
  end
80
81
 
82
+ def version
83
+ raw_version = execute('--version', retryable: true)
84
+ raw_version.gsub('/prlctl version /', '')
85
+ end
86
+
81
87
  def clear_shared_folders
82
88
  read_settings.fetch("Host Shared Folders", {}).keys.drop(1).each do |folder|
83
89
  execute("set", @uuid, "--shf-host-del", folder)
84
90
  end
85
91
  end
86
92
 
87
- def import(template_name, vm_name)
93
+ def import(template_uuid, vm_name)
88
94
  last = 0
89
- execute("clone", template_name, '--name', vm_name) do |type, data|
95
+ execute("clone", template_uuid, '--name', vm_name) do |type, data|
90
96
  lines = data.split("\r")
91
97
  # The progress of the import will be in the last line. Do a greedy
92
98
  # regular expression to find what we're looking for.
@@ -139,8 +145,10 @@ module VagrantPlugins
139
145
  execute("unregister", uuid)
140
146
  end
141
147
 
142
- def registered?(name)
143
- read_templates.has_key?(name) || read_vms.has_key?(name)
148
+ def registered?(path)
149
+ # TODO: Make this take UUID and have callers pass that instead
150
+ # Need a way to get the UUID from unregistered templates though (config.pvs XML parsing/regex?)
151
+ read_all_paths.has_key?(path)
144
152
  end
145
153
 
146
154
  def set_mac_address(mac)
@@ -162,10 +170,6 @@ module VagrantPlugins
162
170
  end
163
171
  end
164
172
 
165
- def symlink(id, path)
166
- guest_execute('ln', '-sf', "/media/psf/#{id}", path)
167
- end
168
-
169
173
  def execute_command(command)
170
174
  raw(*command)
171
175
  end
@@ -186,6 +190,17 @@ module VagrantPlugins
186
190
 
187
191
  private
188
192
 
193
+ # Parse the JSON from *all* VMs and templates. Then return an array of objects (without duplicates)
194
+ def read_all_info
195
+ vms_arr = json({}) do
196
+ execute('list', '--info', '--json', retryable: true).gsub(/^(INFO)?/, '')
197
+ end
198
+ templates_arr = json({}) do
199
+ execute('list', '--info', '--json', '--template', retryable: true).gsub(/^(INFO)?/, '')
200
+ end
201
+ vms_arr | templates_arr
202
+ end
203
+
189
204
  def read_settings(uuid=nil)
190
205
  uuid ||= @uuid
191
206
  json({}) { execute('list', uuid, '--info', '--json', retryable: true).gsub(/^(INFO)?\[/, '').gsub(/\]$/, '') }
@@ -0,0 +1,31 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module GuestDarwinCap
4
+ class MountParallelsSharedFolder
5
+
6
+ def self.mount_parallels_shared_folder(machine, name, guestpath, options)
7
+ machine.communicate.tap do |comm|
8
+ # clear prior symlink
9
+ if comm.test("test -L \"#{guestpath}\"", :sudo => true)
10
+ comm.sudo("rm \"#{guestpath}\"")
11
+ end
12
+
13
+ # clear prior directory if exists
14
+ if comm.test("test -d \"#{guestpath}\"", :sudo => true)
15
+ comm.sudo("rm -Rf \"#{guestpath}\"")
16
+ end
17
+
18
+ # create intermediate directories if needed
19
+ intermediate_dir = File.dirname(guestpath)
20
+ if !comm.test("test -d \"#{intermediate_dir}\"", :sudo => true)
21
+ comm.sudo("mkdir -p \"#{intermediate_dir}\"")
22
+ end
23
+
24
+ # finally make the symlink
25
+ comm.sudo("ln -s \"/Volumes/SharedFolders/#{name}\" \"#{guestpath}\"")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module GuestLinuxCap
4
+ class MountParallelsSharedFolder
5
+
6
+ def self.mount_parallels_shared_folder(machine, name, guestpath, options)
7
+ machine.communicate.tap do |comm|
8
+ # clear prior symlink
9
+ if comm.test("test -L \"#{guestpath}\"", :sudo => true)
10
+ comm.sudo("rm \"#{guestpath}\"")
11
+ end
12
+
13
+ # clear prior directory if exists
14
+ if comm.test("test -d \"#{guestpath}\"", :sudo => true)
15
+ comm.sudo("rm -Rf \"#{guestpath}\"")
16
+ end
17
+
18
+ # create intermediate directories if needed
19
+ intermediate_dir = File.dirname(guestpath)
20
+ if !comm.test("test -d \"#{intermediate_dir}\"", :sudo => true)
21
+ comm.sudo("mkdir -p \"#{intermediate_dir}\"")
22
+ end
23
+
24
+ # finally make the symlink
25
+ comm.sudo("ln -s \"/media/psf/#{name}\" \"#{guestpath}\"")
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,3 @@
1
- require "vagrant"
2
-
3
1
  begin
4
2
  require "vagrant"
5
3
  rescue LoadError
@@ -70,6 +68,17 @@ module VagrantPlugins
70
68
  # require File.expand_path("../config", __FILE__)
71
69
  # Config
72
70
  # end
71
+
72
+ guest_capability(:darwin, :mount_parallels_shared_folder) do
73
+ require_relative "guest_cap/darwin/mount_parallels_shared_folder"
74
+ GuestDarwinCap::MountParallelsSharedFolder
75
+ end
76
+
77
+ guest_capability(:linux, :mount_parallels_shared_folder) do
78
+ require_relative "guest_cap/linux/mount_parallels_shared_folder"
79
+ GuestLinuxCap::MountParallelsSharedFolder
80
+ end
81
+
73
82
  end
74
83
 
75
84
  module Driver
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "0.0.3.dev"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -55,5 +55,5 @@ Gem::Specification.new do |spec|
55
55
 
56
56
  spec.files = unignored_files
57
57
  spec.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
58
- spec.require_path = ["lib"]
58
+ spec.require_path = "lib"
59
59
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-parallels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.dev
5
- prerelease: 6
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Youssef Shahin
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-09-26 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ! '>='
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ! '>='
45
40
  - !ruby/object:Gem::Version
@@ -47,7 +42,6 @@ dependencies:
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec-core
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ~>
53
47
  - !ruby/object:Gem::Version
@@ -55,7 +49,6 @@ dependencies:
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
@@ -63,7 +56,6 @@ dependencies:
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rspec-expectations
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
60
  - - ~>
69
61
  - !ruby/object:Gem::Version
@@ -71,7 +63,6 @@ dependencies:
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
67
  - - ~>
77
68
  - !ruby/object:Gem::Version
@@ -79,7 +70,6 @@ dependencies:
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: rspec-mocks
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
74
  - - ~>
85
75
  - !ruby/object:Gem::Version
@@ -87,7 +77,6 @@ dependencies:
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
81
  - - ~>
93
82
  - !ruby/object:Gem::Version
@@ -131,6 +120,8 @@ files:
131
120
  - lib/vagrant-parallels/action.rb
132
121
  - lib/vagrant-parallels/driver/prl_ctl.rb
133
122
  - lib/vagrant-parallels/errors.rb
123
+ - lib/vagrant-parallels/guest_cap/darwin/mount_parallels_shared_folder.rb
124
+ - lib/vagrant-parallels/guest_cap/linux/mount_parallels_shared_folder.rb
134
125
  - lib/vagrant-parallels/plugin.rb
135
126
  - lib/vagrant-parallels/provider.rb
136
127
  - lib/vagrant-parallels/version.rb
@@ -146,26 +137,26 @@ files:
146
137
  homepage: http://github.com/yshahin/vagrant-parallels
147
138
  licenses:
148
139
  - MIT
140
+ metadata: {}
149
141
  post_install_message:
150
142
  rdoc_options: []
151
143
  require_paths:
152
- - - lib
144
+ - lib
153
145
  required_ruby_version: !ruby/object:Gem::Requirement
154
- none: false
155
146
  requirements:
156
147
  - - ! '>='
157
148
  - !ruby/object:Gem::Version
158
149
  version: '0'
159
150
  required_rubygems_version: !ruby/object:Gem::Requirement
160
- none: false
161
151
  requirements:
162
152
  - - ! '>='
163
153
  - !ruby/object:Gem::Version
164
154
  version: 1.3.6
165
155
  requirements: []
166
156
  rubyforge_project: vagrant-parallels
167
- rubygems_version: 1.8.25
157
+ rubygems_version: 2.1.4
168
158
  signing_key:
169
- specification_version: 3
159
+ specification_version: 4
170
160
  summary: Enables Vagrant to manage Parallels machines.
171
161
  test_files: []
162
+ has_rdoc: