vagrant-parallels 0.0.3 → 0.0.4.dev

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGU5YWFiMzVmN2ZiNjQ4NmM1Y2Q2YzY3YTY2ODg4ZmFmZjMyYTYzMA==
4
+ NmE4NmE1N2UwMDYzMjM0ZDVlNDdjNTBkYmIwMGEwOWE2NWI1YTM1ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZDFmMjZjZTZhMzc3M2M5MDUyMDdkZDhmZDIwYmJkNGEzMDA0ZmY0OQ==
6
+ MjUzYWFlNjE5ZWY1MTBjZjQyNmMxZTNhNWZkOWI2NWQzYjUzZTM1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGFhZGQ5NTE5NGVhNGYwOTk1OWFhYmMzNThlMTFkNmYxZGY3ZjRmNDMxNmJh
10
- YzhhZTMwNWVlZjYxMWMwMjlkMmY0ZjdmYzAxY2UzNDgzNTIzZjliNTU1YWMw
11
- NzcyOWIwNDY4NTM5ZWFmY2NlOGY5N2M3ZjQ5NjkwNzVhNzFhYTA=
9
+ NWM3MGY4NWQyMzk3NTFmMDE0YWFhZDE0NWUzMmU1ZWVjMjkwMWJkNzc2ZjVj
10
+ NmU5MWJmYTdkN2IwNmMxMzIxYjkzZWFhMGYzM2NjMzVlNWZiNzAyYjQ5Nzlh
11
+ MmJjZGI0ZWFiNGY4NjU5MDU4MzYzNjJmNjAyMTA0YTBlNTgyZDY=
12
12
  data.tar.gz: !binary |-
13
- NzdhMzdlOTEyMzU1ZThkZTJhMTdjMzMzMTk1YzMyNTY3MzNkZmFjZWI1ZTlm
14
- N2I1ZGYwY2U3NjM3YjA5ZjRhYjlmOTIxZTI3MTgyNjMwNjBlYTM3YTA2ZGUy
15
- ZmE1MTdmOTRkOWZmNzI5ODljYmFlOTAyZjAyZTY3ZTE5Njg0Njc=
13
+ YjNiYWYxNjdjNDdjMTAwNTAwNjA3NzFlMzBhZTE0NWEzNjk1Mjk1Mjg2NmFj
14
+ MDE0OTIzMTZjYmI0MWFiNjY5YjkwZjYwYTY0MjkyNWExODkzMWZjOTUwZjU2
15
+ MjAzMjAxYzEyMzNiMDc0ODgzYzQxMTI1YmE4ZWQzNGE1YjA1ZDg=
data/README.md CHANGED
@@ -1,20 +1,22 @@
1
1
  # Vagrant Parallels Provider
2
2
 
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.
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.
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.
9
+ Almost all features are available except for exporting/packaging VM's this will be available soon [isA](http://en.wikipedia.org/wiki/In_Shaa%27_Allah) (ان شاء الله)
10
10
 
11
11
  We look forward to hearing from you with any issues or features, Thank you
12
12
 
13
13
  ## Usage
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.
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.
15
17
 
16
18
  ```
17
- $ vagrant plugin install vagrant-parallels
19
+ $ vagrant plugin install vagrant-parallels --plugin-prerelease
18
20
  ...
19
21
  $ vagrant init
20
22
  $ vagrant up --provider=parallels
@@ -77,16 +79,3 @@ Use bundler to execute Vagrant:
77
79
  ```
78
80
  $ bundle exec vagrant up --provider=parallels
79
81
  ```
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`
@@ -76,9 +76,8 @@ module VagrantPlugins
76
76
  end
77
77
 
78
78
  b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
79
- if !env2[:result]
80
- b3.use ForcedHalt
81
- end
79
+ next if !env2[:result]
80
+ b3.use ForcedHalt
82
81
  end
83
82
  else
84
83
  b2.use MessageNotCreated
@@ -140,14 +139,16 @@ module VagrantPlugins
140
139
  # suspended machines.
141
140
  def self.action_resume
142
141
  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
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
151
152
  end
152
153
  end
153
154
  end
@@ -15,15 +15,16 @@ 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.read_all_names.has_key?(vm_name)
18
+ if env[:machine].provider.driver.registered? vm_name
19
19
  raise Vagrant::Errors::VMNameExists, :name => vm_name
20
20
  end
21
21
 
22
22
  # Import the virtual machine
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]
23
+ template_name = Pathname.glob(
24
+ env[:machine].box.directory.join('*.pvm')
25
+ ).first.basename.to_s[0...-4]
25
26
 
26
- env[:machine].id = env[:machine].provider.driver.import(template_uuid, vm_name) do |progress|
27
+ env[:machine].id = env[:machine].provider.driver.import(template_name, vm_name) do |progress|
27
28
  env[:ui].clear_line
28
29
  env[:ui].report_progress(progress, 100, false)
29
30
  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_all_names
11
+ vms = env[:machine].provider.driver.read_vms
12
12
  env[:host].nfs_prune(vms.values)
13
13
  end
14
14
 
@@ -7,11 +7,9 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
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
10
+ pvm_file = Pathname.glob(env[:machine].box.directory.join('*.pvm')).first
13
11
 
14
- unless env[:machine].provider.driver.registered?(pvm_file)
12
+ unless env[:machine].provider.driver.registered?(pvm_file.basename.to_s[0...-4])
15
13
  env[:machine].provider.driver.register(pvm_file.to_s)
16
14
  end
17
15
  # Call the next if we have one (but we shouldn't, since this
@@ -106,17 +106,8 @@ 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
- # 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)
109
+ # Symlink to mounted folder to guest path
110
+ @env[:machine].provider.driver.symlink(id, data[:guestpath])
120
111
  else
121
112
  # If no guest path is specified, then automounting is disabled
122
113
  @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry",
@@ -7,14 +7,12 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def call(env)
10
- template_path = File.realpath(Pathname.glob(
10
+ vm_name = Pathname.glob(
11
11
  env[:machine].box.directory.join('*.pvm')
12
- ).first)
12
+ ).first.basename.to_s[0...-4]
13
13
 
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)
14
+ if env[:machine].provider.driver.registered?(vm_name)
15
+ env[:machine].provider.driver.unregister(vm_name)
18
16
  end
19
17
  # Call the next if we have one (but we shouldn't, since this
20
18
  # middleware is built to run with the Call-type middlewares)
@@ -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 assigned to VMs and templates currently
45
- # known by Parallels. Keys are 'name' values
44
+ # Returns a hash of all UUIDs of virtual machines currently
45
+ # known by Parallels. Hash keys is VM names
46
46
  #
47
47
  # @return [Hash]
48
- def read_all_names
48
+ def read_vms
49
49
  list = {}
50
- read_all_info.each do |item|
51
- list[item.fetch('Name')] = item.fetch('ID')
50
+ json({}) { execute('list', '--all', '--json', retryable: true) }.each do |item|
51
+ list[item.fetch('name')] = item.fetch('uuid')
52
52
  end
53
53
 
54
54
  list
55
55
  end
56
56
 
57
- # Returns a hash of all UUIDs assigned to VMs and templates currently
58
- # known by Parallels. Keys are 'Home' directories
57
+ # Returns a hash of all UUIDs of VM templates currently
58
+ # known by Parallels. Hash keys is template names
59
59
  #
60
60
  # @return [Hash]
61
- def read_all_paths
61
+ def read_templates
62
62
  list = {}
63
- read_all_info.each do |item|
64
- list[File.realpath item.fetch('Home')] = item.fetch('ID')
63
+ json({}) { execute('list', '--template', '--json', retryable: true) }.each do |item|
64
+ list[item.fetch('name')] = item.fetch('uuid')
65
65
  end
66
66
 
67
67
  list
@@ -75,24 +75,18 @@ 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?
79
78
  execute('--version')
80
79
  end
81
80
 
82
- def version
83
- raw_version = execute('--version', retryable: true)
84
- raw_version.gsub('/prlctl version /', '')
85
- end
86
-
87
81
  def clear_shared_folders
88
82
  read_settings.fetch("Host Shared Folders", {}).keys.drop(1).each do |folder|
89
83
  execute("set", @uuid, "--shf-host-del", folder)
90
84
  end
91
85
  end
92
86
 
93
- def import(template_uuid, vm_name)
87
+ def import(template_name, vm_name)
94
88
  last = 0
95
- execute("clone", template_uuid, '--name', vm_name) do |type, data|
89
+ execute("clone", template_name, '--name', vm_name) do |type, data|
96
90
  lines = data.split("\r")
97
91
  # The progress of the import will be in the last line. Do a greedy
98
92
  # regular expression to find what we're looking for.
@@ -145,10 +139,8 @@ module VagrantPlugins
145
139
  execute("unregister", uuid)
146
140
  end
147
141
 
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)
142
+ def registered?(name)
143
+ read_templates.has_key?(name) || read_vms.has_key?(name)
152
144
  end
153
145
 
154
146
  def set_mac_address(mac)
@@ -170,6 +162,10 @@ module VagrantPlugins
170
162
  end
171
163
  end
172
164
 
165
+ def symlink(id, path)
166
+ guest_execute('ln', '-sf', "/media/psf/#{id}", path)
167
+ end
168
+
173
169
  def execute_command(command)
174
170
  raw(*command)
175
171
  end
@@ -190,17 +186,6 @@ module VagrantPlugins
190
186
 
191
187
  private
192
188
 
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
-
204
189
  def read_settings(uuid=nil)
205
190
  uuid ||= @uuid
206
191
  json({}) { execute('list', uuid, '--info', '--json', retryable: true).gsub(/^(INFO)?\[/, '').gsub(/\]$/, '') }
@@ -1,3 +1,5 @@
1
+ require "vagrant"
2
+
1
3
  begin
2
4
  require "vagrant"
3
5
  rescue LoadError
@@ -68,17 +70,6 @@ module VagrantPlugins
68
70
  # require File.expand_path("../config", __FILE__)
69
71
  # Config
70
72
  # 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
-
82
73
  end
83
74
 
84
75
  module Driver
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Parallels
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4.dev"
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,7 +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
4
+ version: 0.0.4.dev
5
5
  platform: ruby
6
6
  authors:
7
7
  - Youssef Shahin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-26 00:00:00.000000000 Z
12
+ date: 2013-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -120,8 +120,6 @@ files:
120
120
  - lib/vagrant-parallels/action.rb
121
121
  - lib/vagrant-parallels/driver/prl_ctl.rb
122
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
125
123
  - lib/vagrant-parallels/plugin.rb
126
124
  - lib/vagrant-parallels/provider.rb
127
125
  - lib/vagrant-parallels/version.rb
@@ -141,7 +139,7 @@ metadata: {}
141
139
  post_install_message:
142
140
  rdoc_options: []
143
141
  require_paths:
144
- - lib
142
+ - - lib
145
143
  required_ruby_version: !ruby/object:Gem::Requirement
146
144
  requirements:
147
145
  - - ! '>='
@@ -1,31 +0,0 @@
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
@@ -1,31 +0,0 @@
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