vagrant-vmware-free 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/.gitignore +5 -0
  2. data/.ruby-version +1 -0
  3. data/Gemfile +7 -0
  4. data/Gemfile.lock +57 -0
  5. data/LICENSE +21 -0
  6. data/README.md +10 -0
  7. data/Rakefile +3 -0
  8. data/lib/vagrant_vmware_free.rb +5 -0
  9. data/lib/vagrant_vmware_free/action.rb +214 -0
  10. data/lib/vagrant_vmware_free/action/boot.rb +23 -0
  11. data/lib/vagrant_vmware_free/action/check_accessible.rb +23 -0
  12. data/lib/vagrant_vmware_free/action/check_created.rb +21 -0
  13. data/lib/vagrant_vmware_free/action/check_guest_additions.rb +45 -0
  14. data/lib/vagrant_vmware_free/action/check_running.rb +21 -0
  15. data/lib/vagrant_vmware_free/action/check_virtualbox.rb +22 -0
  16. data/lib/vagrant_vmware_free/action/clean_machine_folder.rb +43 -0
  17. data/lib/vagrant_vmware_free/action/clear_forwarded_ports.rb +18 -0
  18. data/lib/vagrant_vmware_free/action/clear_network_interfaces.rb +31 -0
  19. data/lib/vagrant_vmware_free/action/clear_shared_folders.rb +17 -0
  20. data/lib/vagrant_vmware_free/action/created.rb +20 -0
  21. data/lib/vagrant_vmware_free/action/customize.rb +43 -0
  22. data/lib/vagrant_vmware_free/action/destroy.rb +19 -0
  23. data/lib/vagrant_vmware_free/action/destroy_unused_network_interfaces.rb +23 -0
  24. data/lib/vagrant_vmware_free/action/discard_state.rb +20 -0
  25. data/lib/vagrant_vmware_free/action/export.rb +57 -0
  26. data/lib/vagrant_vmware_free/action/forced_halt.rb +25 -0
  27. data/lib/vagrant_vmware_free/action/forward_ports.rb +89 -0
  28. data/lib/vagrant_vmware_free/action/get_network_address.rb +27 -0
  29. data/lib/vagrant_vmware_free/action/import.rb +56 -0
  30. data/lib/vagrant_vmware_free/action/is_paused.rb +20 -0
  31. data/lib/vagrant_vmware_free/action/is_running.rb +20 -0
  32. data/lib/vagrant_vmware_free/action/is_saved.rb +20 -0
  33. data/lib/vagrant_vmware_free/action/match_mac_address.rb +21 -0
  34. data/lib/vagrant_vmware_free/action/message_already_running.rb +16 -0
  35. data/lib/vagrant_vmware_free/action/message_not_created.rb +16 -0
  36. data/lib/vagrant_vmware_free/action/message_not_running.rb +16 -0
  37. data/lib/vagrant_vmware_free/action/message_will_not_destroy.rb +17 -0
  38. data/lib/vagrant_vmware_free/action/network.rb +424 -0
  39. data/lib/vagrant_vmware_free/action/package.rb +20 -0
  40. data/lib/vagrant_vmware_free/action/package_vagrantfile.rb +33 -0
  41. data/lib/vagrant_vmware_free/action/prepare_forwarded_port_collision_params.rb +35 -0
  42. data/lib/vagrant_vmware_free/action/prepare_nfs_settings.rb +69 -0
  43. data/lib/vagrant_vmware_free/action/prune_nfs_exports.rb +20 -0
  44. data/lib/vagrant_vmware_free/action/resume.rb +26 -0
  45. data/lib/vagrant_vmware_free/action/sane_defaults.rb +91 -0
  46. data/lib/vagrant_vmware_free/action/set_name.rb +52 -0
  47. data/lib/vagrant_vmware_free/action/set_network.rb +17 -0
  48. data/lib/vagrant_vmware_free/action/setup_package_files.rb +51 -0
  49. data/lib/vagrant_vmware_free/action/share_folders.rb +128 -0
  50. data/lib/vagrant_vmware_free/action/suspend.rb +20 -0
  51. data/lib/vagrant_vmware_free/action/wait_for_vm_tools.rb +19 -0
  52. data/lib/vagrant_vmware_free/config.rb +38 -0
  53. data/lib/vagrant_vmware_free/driver/base.rb +14 -0
  54. data/lib/vagrant_vmware_free/driver/fusion.rb +17 -0
  55. data/lib/vagrant_vmware_free/driver/fusion_6.rb +188 -0
  56. data/lib/vagrant_vmware_free/driver/meta.rb +122 -0
  57. data/lib/vagrant_vmware_free/driver/vix.rb +19 -0
  58. data/lib/vagrant_vmware_free/driver/vix/functions.rb +38 -0
  59. data/lib/vagrant_vmware_free/driver/vix/helpers.rb +63 -0
  60. data/lib/vagrant_vmware_free/driver/vix/types.rb +143 -0
  61. data/lib/vagrant_vmware_free/errors.rb +9 -0
  62. data/lib/vagrant_vmware_free/plugin.rb +43 -0
  63. data/lib/vagrant_vmware_free/provider.rb +62 -0
  64. data/lib/vagrant_vmware_free/util/vmx.rb +48 -0
  65. data/vagrant-vmware-free.gemspec +21 -0
  66. metadata +190 -0
@@ -0,0 +1,5 @@
1
+ Vagrantfile
2
+ .vagrant
3
+ *.sublime-*
4
+ .DS_Store
5
+ *.gem
@@ -0,0 +1 @@
1
+ 1.9.3-p448
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'vagrant', github: 'mitchellh/vagrant'
7
+ end
@@ -0,0 +1,57 @@
1
+ GIT
2
+ remote: git://github.com/mitchellh/vagrant.git
3
+ revision: bf2b06e1bebddb9d035020fa04e6f6d2f06cff75
4
+ specs:
5
+ vagrant (1.3.6.dev)
6
+ childprocess (~> 0.3.7)
7
+ erubis (~> 2.7.0)
8
+ i18n (~> 0.6.0)
9
+ log4r (~> 1.1.9)
10
+ net-scp (~> 1.1.0)
11
+ net-ssh (~> 2.6.6)
12
+
13
+ PATH
14
+ remote: .
15
+ specs:
16
+ vagrant-vmware-free (0.0.1)
17
+ CFPropertyList (~> 2.0)
18
+ ffi (~> 1.9.3)
19
+
20
+ GEM
21
+ remote: https://rubygems.org/
22
+ specs:
23
+ CFPropertyList (2.2.4)
24
+ childprocess (0.3.9)
25
+ ffi (~> 1.0, >= 1.0.11)
26
+ coderay (1.1.0)
27
+ columnize (0.3.6)
28
+ debugger (1.6.2)
29
+ columnize (>= 0.3.1)
30
+ debugger-linecache (~> 1.2.0)
31
+ debugger-ruby_core_source (~> 1.2.3)
32
+ debugger-linecache (1.2.0)
33
+ debugger-ruby_core_source (1.2.4)
34
+ erubis (2.7.0)
35
+ ffi (1.9.3)
36
+ i18n (0.6.5)
37
+ log4r (1.1.10)
38
+ method_source (0.8.2)
39
+ net-scp (1.1.2)
40
+ net-ssh (>= 2.6.5)
41
+ net-ssh (2.6.8)
42
+ pry (0.9.12.3)
43
+ coderay (~> 1.0)
44
+ method_source (~> 0.8)
45
+ slop (~> 3.4)
46
+ rake (10.1.0)
47
+ slop (3.4.7)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ debugger
54
+ pry
55
+ rake
56
+ vagrant!
57
+ vagrant-vmware-free!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Ori Shavit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ A free VMware provider for Vagrant
2
+ =========
3
+
4
+ A Vagrant provider is used to deploy your Vagrant boxes and configuration on some infrastructure. This plugin creates and manages vagrant deployments on VMware Workstaion and Fusion. The work is not even mature enough to be called Alpha, though, so use at your own risk.
5
+
6
+ This plugin is not related in any way to Hashicorp or their VMware offering. Their plugin is probably much better, if you need VMware support for your project, you should use their product, as this thing barely works, and comes with no support.
7
+
8
+ Since this is a new project, a good knowledge of Vagrant plugins and VMware is required to use.
9
+
10
+ The code is provided under the MIT license (just like Vagrant).
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,5 @@
1
+ require 'vagrant_vmware_free/plugin'
2
+
3
+ module VagrantPlugins
4
+
5
+ end
@@ -0,0 +1,214 @@
1
+ require 'vagrant/action/builder'
2
+
3
+ module VagrantPlugins
4
+ module ProviderVMwareFree
5
+ module Action
6
+ [:Boot,
7
+ :CheckAccessible,
8
+ :CheckCreated,
9
+ :CheckGuestAdditions,
10
+ :CheckRunning,
11
+ :CheckVirtualbox,
12
+ :CleanMachineFolder,
13
+ :ClearForwardedPorts,
14
+ :ClearNetworkInterfaces,
15
+ :ClearSharedFolders,
16
+ :Created,
17
+ :Customize,
18
+ :Destroy,
19
+ :DestroyUnusedNetworkInterfaces,
20
+ :DiscardState,
21
+ :Export,
22
+ :ForcedHalt,
23
+ :ForwardPorts,
24
+ :Import,
25
+ :IsPaused,
26
+ :IsRunning,
27
+ :IsSaved,
28
+ :MatchMACAddress,
29
+ :MessageAlreadyRunning,
30
+ :MessageNotCreated,
31
+ :MessageNotRunning,
32
+ :MessageWillNotDestroy,
33
+ :Network,
34
+ :Package,
35
+ :PackageVagrantfile,
36
+ :PrepareNFSSettings,
37
+ :PrepareForwardedPortCollisionParams,
38
+ :PruneNFSExports,
39
+ :Resume,
40
+ :SaneDefaults,
41
+ :SetName,
42
+ :SetupPackageFiles,
43
+ :ShareFolders,
44
+ :Suspend,
45
+
46
+ :WaitForVMTools,
47
+ :SetNetwork,
48
+ :GetNetworkAddress].each do |sym|
49
+ filename = sym.to_s.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
50
+
51
+ autoload sym, File.expand_path("../action/#{filename}", __FILE__)
52
+ end
53
+
54
+ include Vagrant::Action::Builtin
55
+
56
+ # re-use some virtualbox provider actions
57
+
58
+ def self.action_boot
59
+ Vagrant::Action::Builder.new.tap do |b|
60
+ b.use CheckAccessible
61
+ b.use SetName
62
+ b.use SetNetwork
63
+ b.use Provision
64
+ b.use EnvSet, :port_collision_repair => true
65
+ # b.use PrepareForwardedPortCollisionParams
66
+ # b.use HandleForwardedPortCollisions
67
+ # b.use PruneNFSExports
68
+ # b.use NFS
69
+ # b.use PrepareNFSSettings
70
+ # b.use ClearSharedFolders
71
+ # b.use ShareFolders
72
+ # b.use ClearNetworkInterfaces
73
+ # b.use Network
74
+ # b.use ForwardPorts
75
+ b.use SetHostname
76
+ # b.use SaneDefaults
77
+ # b.use Customize, "pre-boot"
78
+ b.use Boot
79
+ b.use WaitForVMTools
80
+ b.use GetNetworkAddress
81
+ # b.use Customize, "post-boot"
82
+ b.use WaitForCommunicator, [:starting, :running]
83
+ # b.use CheckGuestAdditions
84
+ end
85
+ end
86
+
87
+ def self.action_ssh
88
+ Vagrant::Action::Builder.new.tap do |b|
89
+ b.use CheckCreated
90
+ b.use CheckAccessible
91
+ b.use CheckRunning
92
+ b.use GetNetworkAddress
93
+ b.use SSHExec
94
+ end
95
+ end
96
+
97
+ def self.action_ssh_run
98
+ Vagrant::Action::Builder.new.tap do |b|
99
+ b.use CheckCreated
100
+ b.use CheckAccessible
101
+ b.use CheckRunning
102
+ b.use GetNetworkAddress
103
+ b.use SSHRun
104
+ end
105
+ end
106
+
107
+ def self.action_start
108
+ Vagrant::Action::Builder.new.tap do |b|
109
+ b.use ConfigValidate
110
+ b.use Call, IsRunning do |env, b2|
111
+ # If the VM is running, then our work here is done, exit
112
+ if env[:result]
113
+ b2.use MessageAlreadyRunning
114
+ next
115
+ end
116
+
117
+ b2.use Call, IsSaved do |env2, b3|
118
+ if env2[:result]
119
+ # The VM is saved, so just resume it
120
+ b3.use action_resume
121
+ next
122
+ end
123
+
124
+ b3.use Call, IsPaused do |env3, b4|
125
+ if env3[:result]
126
+ b4.use Resume
127
+ next
128
+ end
129
+
130
+ # The VM is not saved, so we must have to boot it up
131
+ # like normal. Boot!
132
+ b4.use action_boot
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+
139
+ def self.action_up
140
+ Vagrant::Action::Builder.new.tap do |b|
141
+ b.use Call, Created do |env, b2|
142
+ if !env[:result]
143
+ b2.use HandleBoxUrl
144
+ end
145
+ end
146
+
147
+ b.use ConfigValidate
148
+ b.use Call, Created do |env, b2|
149
+ if !env[:result]
150
+ b2.use CheckAccessible
151
+ # b2.use Customize, 'pre-import'
152
+ b2.use Import
153
+ # b2.use MatchMACAddress
154
+ end
155
+ end
156
+
157
+ b.use action_start
158
+ end
159
+ end
160
+
161
+ def self.action_halt
162
+ Vagrant::Action::Builder.new.tap do |b|
163
+ b.use Call, Created do |env, b2|
164
+ if env[:result]
165
+ b2.use CheckAccessible
166
+
167
+ b2.use Call, IsPaused do |env2, b3|
168
+ next if !env2[:result]
169
+ b3.use Resume
170
+ end
171
+
172
+ b.use WaitForVMTools
173
+ b.use GetNetworkAddress
174
+
175
+ b2.use Call, GracefulHalt, :poweroff, :running do |env2, b3|
176
+ if !env2[:result]
177
+ b3.use ForcedHalt
178
+ end
179
+ end
180
+ else
181
+ b2.use MessageNotCreated
182
+ end
183
+ end
184
+ end
185
+ end
186
+
187
+ def self.action_destroy
188
+ Vagrant::Action::Builder.new.tap do |b|
189
+ b.use Call, Created do |env1, b2|
190
+ if !env1[:result]
191
+ b2.use MessageNotCreated
192
+ next
193
+ end
194
+
195
+ b2.use Call, DestroyConfirm do |env2, b3|
196
+ if env2[:result]
197
+ b3.use ConfigValidate
198
+ b3.use CheckAccessible
199
+ b3.use EnvSet, :force_halt => true
200
+ b3.use action_halt
201
+ # b3.use PruneNFSExports
202
+ b3.use Destroy
203
+ # b3.use DestroyUnusedNetworkInterfaces
204
+ # b3.use ProvisionerCleanup
205
+ else
206
+ b3.use MessageWillNotDestroy
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module ProviderVMwareFree
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
+ boot_mode = @env[:machine].provider_config.gui ? "gui" : "headless"
13
+
14
+ # Start up the VM and wait for it to boot.
15
+ env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
16
+ env[:machine].provider.driver.start(boot_mode)
17
+
18
+ @app.call(env)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module ProviderVMwareFree
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 ProviderVMwareFree
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,45 @@
1
+ module VagrantPlugins
2
+ module ProviderVMwareFree
3
+ module Action
4
+ class CheckGuestAdditions
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
+ version = env[:machine].provider.driver.read_guest_additions_version
13
+ if !version
14
+ env[:ui].warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
15
+ else
16
+ # Read the versions
17
+ versions = [version, env[:machine].provider.driver.version]
18
+
19
+ # Strip of any -OSE or _OSE and read only the first two parts
20
+ # of the version such as "4.2" in "4.2.0"
21
+ versions.map! do |v|
22
+ v = v.gsub(/[-_]ose/i, '')
23
+ match = /^(\d+\.\d+)\.(\d+)/.match(v)
24
+ v = match[1] if match
25
+ v
26
+ end
27
+
28
+ guest_version = versions[0]
29
+ vb_version = versions[1]
30
+
31
+ if guest_version != vb_version
32
+ env[:ui].warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
33
+ :guest_version => version,
34
+ :virtualbox_version => vb_version))
35
+ end
36
+ end
37
+
38
+ # Continue
39
+ @app.call(env)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end