vagrant-parallels 0.0.1.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.
Files changed (45) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +23 -0
  3. data/.ruby-gemset +1 -0
  4. data/Gemfile +13 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +59 -0
  7. data/Rakefile +23 -0
  8. data/lib/vagrant-parallels.rb +18 -0
  9. data/lib/vagrant-parallels/action.rb +282 -0
  10. data/lib/vagrant-parallels/action/boot.rb +21 -0
  11. data/lib/vagrant-parallels/action/check_accessible.rb +23 -0
  12. data/lib/vagrant-parallels/action/check_created.rb +21 -0
  13. data/lib/vagrant-parallels/action/check_guest_tools.rb +32 -0
  14. data/lib/vagrant-parallels/action/check_parallels.rb +22 -0
  15. data/lib/vagrant-parallels/action/check_running.rb +21 -0
  16. data/lib/vagrant-parallels/action/clear_network_interfaces.rb +19 -0
  17. data/lib/vagrant-parallels/action/clear_shared_folders.rb +17 -0
  18. data/lib/vagrant-parallels/action/created.rb +20 -0
  19. data/lib/vagrant-parallels/action/destroy.rb +19 -0
  20. data/lib/vagrant-parallels/action/forced_halt.rb +20 -0
  21. data/lib/vagrant-parallels/action/import.rb +63 -0
  22. data/lib/vagrant-parallels/action/is_paused.rb +21 -0
  23. data/lib/vagrant-parallels/action/is_running.rb +20 -0
  24. data/lib/vagrant-parallels/action/is_saved.rb +21 -0
  25. data/lib/vagrant-parallels/action/match_mac_address.rb +21 -0
  26. data/lib/vagrant-parallels/action/message_already_running.rb +16 -0
  27. data/lib/vagrant-parallels/action/message_not_created.rb +16 -0
  28. data/lib/vagrant-parallels/action/message_not_running.rb +16 -0
  29. data/lib/vagrant-parallels/action/message_will_not_destroy.rb +17 -0
  30. data/lib/vagrant-parallels/action/prepare_nfs_settings.rb +64 -0
  31. data/lib/vagrant-parallels/action/prune_nfs_exports.rb +20 -0
  32. data/lib/vagrant-parallels/action/register_template.rb +22 -0
  33. data/lib/vagrant-parallels/action/resume.rb +25 -0
  34. data/lib/vagrant-parallels/action/share_folders.rb +121 -0
  35. data/lib/vagrant-parallels/action/suspend.rb +20 -0
  36. data/lib/vagrant-parallels/action/unregister_template.rb +24 -0
  37. data/lib/vagrant-parallels/driver/prl_ctl.rb +281 -0
  38. data/lib/vagrant-parallels/errors.rb +23 -0
  39. data/lib/vagrant-parallels/plugin.rb +79 -0
  40. data/lib/vagrant-parallels/provider.rb +68 -0
  41. data/lib/vagrant-parallels/version.rb +5 -0
  42. data/locales/en.yml +1137 -0
  43. data/spec/vagrant-parallels/setup_spec.rb +7 -0
  44. data/vagrant-parallels.gemspec +59 -0
  45. metadata +158 -0
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class Boot
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ @env = env
11
+
12
+ env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
13
+ env[:machine].provider.driver.start
14
+
15
+ @app.call(env)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class CheckAccessible
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ if env[:machine].state.id == :inaccessible
11
+ # The VM we are attempting to manipulate is inaccessible. This
12
+ # is a very bad situation and can only be fixed by the user. It
13
+ # also prohibits us from actually doing anything with the virtual
14
+ # machine, so we raise an error.
15
+ raise Vagrant::Errors::VMInaccessible
16
+ end
17
+
18
+ @app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ # This middleware checks that the VM is created, and raises an exception
5
+ # if it is not, notifying the user that creation is required.
6
+ class CheckCreated
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if env[:machine].state.id == :not_created
13
+ raise Vagrant::Errors::VMNotCreatedError
14
+ end
15
+
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class CheckGuestTools
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ # Use the raw interface for now, while the virtualbox gem
11
+ # doesn't support guest properties (due to cross platform issues)
12
+ tools_version = env[:machine].provider.driver.read_guest_tools_version
13
+ if !tools_version
14
+ env[:ui].warn I18n.t("vagrant.actions.vm.check_guest_tools.not_detected")
15
+ else
16
+ env[:machine].provider.driver.verify! =~ /^[\w\s]+ ([\d.]+)$/
17
+ os_version = $1
18
+ unless os_version.start_with? tools_version
19
+ env[:ui].warn(I18n.t("vagrant.actions.vm.check_guest_tools.version_mismatch",
20
+ tools_version: tools_version,
21
+ parallels_version: os_version))
22
+ end
23
+ end
24
+
25
+ # Continue
26
+ @app.call(env)
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ # Checks that Parallels is installed and ready to be used.
5
+ class CheckParallels
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ # This verifies that Parallels is installed and the driver is
12
+ # ready to function. If not, then an exception will be raised
13
+ # which will break us out of execution of the middleware sequence.
14
+ env[:machine].provider.driver.verify!
15
+
16
+ # Carry on.
17
+ @app.call(env)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ # This middleware checks that the VM is running, and raises an exception
5
+ # if it is not, notifying the user that the VM must be running.
6
+ class CheckRunning
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ if env[:machine].state.id != :running
13
+ raise Vagrant::Errors::VMNotRunningError
14
+ end
15
+
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class ClearNetworkInterfaces
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ # "Enable" all the adapters we setup.
11
+ env[:ui].info I18n.t("vagrant.actions.vm.clear_network_interfaces.deleting")
12
+ env[:machine].provider.driver.delete_adapters
13
+
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class ClearSharedFolders
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:machine].provider.driver.clear_shared_folders
11
+
12
+ @app.call(env)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class Created
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ # Set the result to be true if the machine is created.
11
+ env[:result] = (env[:machine].state.id != :not_created)
12
+
13
+ # Call the next if we have one (but we shouldn't, since this
14
+ # middleware is built to run with the Call-type middlewares)
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class Destroy
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying")
11
+ env[:machine].provider.driver.delete
12
+ env[:machine].id = nil
13
+
14
+ @app.call(env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class ForcedHalt
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ current_state = env[:machine].state.id
11
+ if current_state == :running
12
+ env[:ui].info I18n.t("vagrant.actions.vm.halt.force")
13
+ env[:machine].provider.driver.halt(:force)
14
+ end
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,63 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class Import
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
11
+ :name => env[:machine].box.name)
12
+
13
+ prefix = env[:root_path].basename.to_s
14
+ prefix.gsub!(/[^-a-z0-9_]/i, "")
15
+ vm_name = prefix + "_#{Time.now.to_i}"
16
+
17
+ # Verify the name is not taken
18
+ if env[:machine].provider.driver.registered? vm_name
19
+ raise Vagrant::Errors::VMNameExists, :name => vm_name
20
+ end
21
+
22
+ # Import the virtual machine
23
+ template_name = Pathname.glob(
24
+ env[:machine].box.directory.join('*.pvm')
25
+ ).first.basename.to_s[0...-4]
26
+
27
+ env[:machine].id = env[:machine].provider.driver.import(template_name, vm_name) do |progress|
28
+ env[:ui].clear_line
29
+ env[:ui].report_progress(progress, 100, false)
30
+ end
31
+
32
+ # Clear the line one last time since the progress meter doesn't disappear
33
+ # immediately.
34
+ env[:ui].clear_line
35
+
36
+ # If we got interrupted, then the import could have been
37
+ # interrupted and its not a big deal. Just return out.
38
+ return if env[:interrupted]
39
+
40
+ # Flag as erroneous and return if import failed
41
+ raise Vagrant::Errors::VMImportFailure if !env[:machine].id
42
+
43
+ # Import completed successfully. Continue the chain
44
+ @app.call(env)
45
+ end
46
+
47
+ def recover(env)
48
+ if env[:machine].provider.state.id != :not_created
49
+ return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
50
+
51
+ # Interrupted, destroy the VM. We note that we don't want to
52
+ # validate the configuration here, and we don't want to confirm
53
+ # we want to destroy.
54
+ destroy_env = env.clone
55
+ destroy_env[:config_validate] = false
56
+ destroy_env[:force_confirm_destroy] = true
57
+ env[:action_runner].run(Action.action_destroy, destroy_env)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class IsPaused
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+
11
+ # Set the result to be true if the machine is paused.
12
+ env[:result] = env[:machine].state.id == :paused
13
+
14
+ # Call the next if we have one (but we shouldn't, since this
15
+ # middleware is built to run with the Call-type middlewares)
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class IsRunning
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ # Set the result to be true if the machine is running.
11
+ env[:result] = env[:machine].state.id == :running
12
+
13
+ # Call the next if we have one (but we shouldn't, since this
14
+ # middleware is built to run with the Call-type middlewares)
15
+ @app.call(env)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class IsSaved
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+
11
+ # Set the result to be true if the machine is suspended.
12
+ env[:result] = env[:machine].state.id == :suspended
13
+
14
+ # Call the next if we have one (but we shouldn't, since this
15
+ # middleware is built to run with the Call-type middlewares)
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class MatchMACAddress
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ raise Vagrant::Errors::VMBaseMacNotSpecified if !env[:machine].config.vm.base_mac
11
+
12
+ # Create the proc which we want to use to modify the virtual machine
13
+ env[:ui].info I18n.t("vagrant.actions.vm.match_mac.matching")
14
+ env[:machine].provider.driver.set_mac_address(env[:machine].config.vm.base_mac)
15
+
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class MessageAlreadyRunning
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info I18n.t("vagrant.commands.common.vm_already_running")
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module Parallels
3
+ module Action
4
+ class MessageNotCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info I18n.t("vagrant.commands.common.vm_not_created")
11
+ @app.call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end