vagrant-veertu 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +11 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +31 -0
  5. data/Rakefile +5 -0
  6. data/lib/vagrant-veertu.rb +18 -0
  7. data/lib/vagrant-veertu/action.rb +330 -0
  8. data/lib/vagrant-veertu/action/boot.rb +21 -0
  9. data/lib/vagrant-veertu/action/check_accessible.rb +22 -0
  10. data/lib/vagrant-veertu/action/check_created.rb +21 -0
  11. data/lib/vagrant-veertu/action/check_running.rb +21 -0
  12. data/lib/vagrant-veertu/action/check_veertu.rb +22 -0
  13. data/lib/vagrant-veertu/action/clear_forwarded_ports.rb +20 -0
  14. data/lib/vagrant-veertu/action/clear_network_interfaces.rb +31 -0
  15. data/lib/vagrant-veertu/action/created.rb +20 -0
  16. data/lib/vagrant-veertu/action/customize.rb +44 -0
  17. data/lib/vagrant-veertu/action/destroy.rb +19 -0
  18. data/lib/vagrant-veertu/action/discard_state.rb +20 -0
  19. data/lib/vagrant-veertu/action/export.rb +41 -0
  20. data/lib/vagrant-veertu/action/forced_halt.rb +25 -0
  21. data/lib/vagrant-veertu/action/forward_ports.rb +91 -0
  22. data/lib/vagrant-veertu/action/import.rb +96 -0
  23. data/lib/vagrant-veertu/action/is_paused.rb +20 -0
  24. data/lib/vagrant-veertu/action/is_running.rb +20 -0
  25. data/lib/vagrant-veertu/action/is_saved.rb +20 -0
  26. data/lib/vagrant-veertu/action/message_already_running.rb +16 -0
  27. data/lib/vagrant-veertu/action/message_not_created.rb +16 -0
  28. data/lib/vagrant-veertu/action/message_not_running.rb +16 -0
  29. data/lib/vagrant-veertu/action/message_will_not_destroy.rb +17 -0
  30. data/lib/vagrant-veertu/action/network.rb +556 -0
  31. data/lib/vagrant-veertu/action/network_fix_ipv6.rb +81 -0
  32. data/lib/vagrant-veertu/action/package.rb +44 -0
  33. data/lib/vagrant-veertu/action/package_vagrantfile.rb +33 -0
  34. data/lib/vagrant-veertu/action/prepare_forwarded_port_collision_params.rb +35 -0
  35. data/lib/vagrant-veertu/action/prepare_nfs_settings.rb +119 -0
  36. data/lib/vagrant-veertu/action/prepare_nfs_valid_ids.rb +17 -0
  37. data/lib/vagrant-veertu/action/resume.rb +21 -0
  38. data/lib/vagrant-veertu/action/sane_defaults.rb +89 -0
  39. data/lib/vagrant-veertu/action/set_name.rb +55 -0
  40. data/lib/vagrant-veertu/action/setup_package_files.rb +51 -0
  41. data/lib/vagrant-veertu/action/snapshot_delete.rb +32 -0
  42. data/lib/vagrant-veertu/action/snapshot_restore.rb +28 -0
  43. data/lib/vagrant-veertu/action/snapshot_save.rb +25 -0
  44. data/lib/vagrant-veertu/action/suspend.rb +20 -0
  45. data/lib/vagrant-veertu/cap.rb +23 -0
  46. data/lib/vagrant-veertu/cap/public_address.rb +15 -0
  47. data/lib/vagrant-veertu/config.rb +199 -0
  48. data/lib/vagrant-veertu/driver/base.rb +240 -0
  49. data/lib/vagrant-veertu/driver/meta.rb +143 -0
  50. data/lib/vagrant-veertu/driver/version_5_0.rb +284 -0
  51. data/lib/vagrant-veertu/errors.rb +18 -0
  52. data/lib/vagrant-veertu/model/forwarded_port.rb +70 -0
  53. data/lib/vagrant-veertu/plugin.rb +76 -0
  54. data/lib/vagrant-veertu/provider.rb +121 -0
  55. data/lib/vagrant-veertu/synced_folder.rb +120 -0
  56. data/lib/vagrant-veertu/util/compile_forwarded_ports.rb +35 -0
  57. data/lib/vagrant-veertu/version.rb +5 -0
  58. data/locales/en.yml +19 -0
  59. data/vagrant-veertu.gemspec +22 -0
  60. metadata +130 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: baf61d2628adfc5abce3e9f64f026bfb9336f40d
4
+ data.tar.gz: 919a93f225c02cf7909cd735ca8116bbaf1b405c
5
+ SHA512:
6
+ metadata.gz: 37469e495849349516bf405c54c2bec7e281f13adc5361a40233ddacda3505ce69b80b58d268df4fc99ab2b7e9047932935387b91c45e3e834904251f9f17a33
7
+ data.tar.gz: 15b8caf2ac85f0411b7b380eec795251dce13aa852c9f58aa46ab2af539ed75a94fa7e30a45af0218817f48b503c2a41c71708189b5e10355f3cf80bde1d7998
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ source "file:///Users/alexf/vagrant-veertu"
4
+
5
+ group :development do
6
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "vagrant-veertu", path: "."
11
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Veertu Labs
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Vagrant::Veertu
2
+
3
+ A Vagrant provider for Veertu
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'vagrant-veertu'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install vagrant-veertu
20
+
21
+ ## Usage
22
+
23
+ Just install it like virtualbox
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/vagrant-veertu/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+ Bundler::GemHelper.install_tasks
5
+
@@ -0,0 +1,18 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-veertu/plugin"
4
+
5
+ module VagrantPlugins
6
+ module ProviderVeertu
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-veertu", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,330 @@
1
+ require "vagrant/action/builder"
2
+ require "log4r"
3
+
4
+ module VagrantPlugins
5
+ module ProviderVeertu
6
+ module Action
7
+ autoload :Boot, File.expand_path("../action/boot", __FILE__)
8
+ autoload :CheckAccessible, File.expand_path("../action/check_accessible", __FILE__)
9
+ autoload :CheckCreated, File.expand_path("../action/check_created", __FILE__)
10
+ autoload :CheckRunning, File.expand_path("../action/check_running", __FILE__)
11
+ autoload :CheckVeertu, File.expand_path("../action/check_veertu", __FILE__)
12
+ autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__)
13
+ autoload :Created, File.expand_path("../action/created", __FILE__)
14
+ autoload :Customize, File.expand_path("../action/customize", __FILE__)
15
+ autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
16
+ autoload :DiscardState, File.expand_path("../action/discard_state", __FILE__)
17
+ autoload :Export, File.expand_path("../action/export", __FILE__)
18
+ autoload :ForcedHalt, File.expand_path("../action/forced_halt", __FILE__)
19
+ autoload :ForwardPorts, File.expand_path("../action/forward_ports", __FILE__)
20
+ autoload :Import, File.expand_path("../action/import", __FILE__)
21
+ autoload :IsPaused, File.expand_path("../action/is_paused", __FILE__)
22
+ autoload :IsRunning, File.expand_path("../action/is_running", __FILE__)
23
+ autoload :IsSaved, File.expand_path("../action/is_saved", __FILE__)
24
+ autoload :MessageAlreadyRunning, File.expand_path("../action/message_already_running", __FILE__)
25
+ autoload :MessageNotCreated, File.expand_path("../action/message_not_created", __FILE__)
26
+ autoload :MessageNotRunning, File.expand_path("../action/message_not_running", __FILE__)
27
+ autoload :MessageWillNotDestroy, File.expand_path("../action/message_will_not_destroy", __FILE__)
28
+ autoload :Network, File.expand_path("../action/network", __FILE__)
29
+ autoload :NetworkFixIPv6, File.expand_path("../action/network_fix_ipv6", __FILE__)
30
+ autoload :Package, File.expand_path("../action/package", __FILE__)
31
+ autoload :PackageVagrantfile, File.expand_path("../action/package_vagrantfile", __FILE__)
32
+ autoload :PrepareCloneSnapshot, File.expand_path("../action/prepare_clone_snapshot", __FILE__)
33
+ autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
34
+ autoload :PrepareNFSValidIds, File.expand_path("../action/prepare_nfs_valid_ids", __FILE__)
35
+ autoload :PrepareForwardedPortCollisionParams, File.expand_path("../action/prepare_forwarded_port_collision_params", __FILE__)
36
+ autoload :Resume, File.expand_path("../action/resume", __FILE__)
37
+ autoload :SaneDefaults, File.expand_path("../action/sane_defaults", __FILE__)
38
+ autoload :SetName, File.expand_path("../action/set_name", __FILE__)
39
+ autoload :SetupPackageFiles, File.expand_path("../action/setup_package_files", __FILE__)
40
+ autoload :Suspend, File.expand_path("../action/suspend", __FILE__)
41
+
42
+ # Include the built-in modules so that we can use them as top-level
43
+ # things.
44
+ include Vagrant::Action::Builtin
45
+
46
+ # This action boots the VM, assuming the VM is in a state that requires
47
+ # a bootup (i.e. not saved).
48
+ def self.action_boot
49
+ Vagrant::Action::Builder.new.tap do |b|
50
+ b.use CheckAccessible
51
+ b.use SetName
52
+ b.use ClearForwardedPorts
53
+ b.use Provision
54
+ b.use EnvSet, port_collision_repair: true
55
+ b.use PrepareForwardedPortCollisionParams
56
+ b.use HandleForwardedPortCollisions
57
+ b.use Network
58
+ b.use NetworkFixIPv6
59
+ b.use ForwardPorts
60
+ b.use SetHostname
61
+ b.use SaneDefaults
62
+ b.use Customize, "pre-boot"
63
+ b.use Boot
64
+ b.use Customize, "post-boot"
65
+ b.use WaitForCommunicator, [:starting, :suspending, :running, :stopped]
66
+ b.use Customize, "post-comm"
67
+ end
68
+ end
69
+
70
+ # This is the action that is primarily responsible for completely
71
+ # freeing the resources of the underlying virtual machine.
72
+ def self.action_destroy
73
+ Vagrant::Action::Builder.new.tap do |b|
74
+ b.use CheckVeertu
75
+ b.use Call, Created do |env1, b2|
76
+ if !env1[:result]
77
+ b2.use MessageNotCreated
78
+ next
79
+ end
80
+
81
+ b2.use Call, DestroyConfirm do |env2, b3|
82
+ if env2[:result]
83
+ b3.use ConfigValidate
84
+ b3.use ProvisionerCleanup, :before
85
+ b3.use CheckAccessible
86
+ b3.use EnvSet, force_halt: true
87
+ b3.use action_halt
88
+ b3.use Destroy
89
+ # b3.use DestroyUnusedNetworkInterfaces
90
+ b3.use PrepareNFSValidIds
91
+ b3.use SyncedFolderCleanup
92
+ else
93
+ b3.use MessageWillNotDestroy
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ # This is the action that is primarily responsible for halting
101
+ # the virtual machine, gracefully or by force.
102
+ def self.action_halt
103
+ Vagrant::Action::Builder.new.tap do |b|
104
+ b.use CheckVeertu
105
+ b.use Call, Created do |env, b2|
106
+ if env[:result]
107
+ b2.use CheckAccessible
108
+ b2.use DiscardState
109
+
110
+ b2.use Call, IsPaused do |env2, b3|
111
+ next if !env2[:result]
112
+ b3.use Resume
113
+ end
114
+
115
+ b2.use Call, GracefulHalt, :stopped, :running do |env2, b3|
116
+ if !env2[:result]
117
+ b3.use ForcedHalt
118
+ end
119
+ end
120
+ else
121
+ b2.use MessageNotCreated
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ # This action packages the virtual machine into a single box file.
128
+ def self.action_package
129
+ Vagrant::Action::Builder.new.tap do |b|
130
+ b.use CheckVeertu
131
+ b.use Call, Created do |env1, b2|
132
+ if !env1[:result]
133
+ b2.use MessageNotCreated
134
+ next
135
+ end
136
+
137
+ b2.use SetupPackageFiles
138
+ b2.use CheckAccessible
139
+ b2.use action_halt
140
+ b2.use ClearForwardedPorts
141
+ b2.use PrepareNFSValidIds
142
+ b2.use SyncedFolderCleanup
143
+ b2.use Package
144
+ b2.use Export
145
+ b2.use PackageVagrantfile
146
+ end
147
+ end
148
+ end
149
+
150
+ # This action just runs the provisioners on the machine.
151
+ def self.action_provision
152
+ Vagrant::Action::Builder.new.tap do |b|
153
+ b.use CheckVeertu
154
+ b.use ConfigValidate
155
+ b.use Call, Created do |env1, b2|
156
+ if !env1[:result]
157
+ b2.use MessageNotCreated
158
+ next
159
+ end
160
+
161
+ b2.use Call, IsRunning do |env2, b3|
162
+ if !env2[:result]
163
+ b3.use MessageNotRunning
164
+ next
165
+ end
166
+
167
+ b3.use CheckAccessible
168
+ b3.use Provision
169
+ end
170
+ end
171
+ end
172
+ end
173
+
174
+ # This action is responsible for reloading the machine, which
175
+ # brings it down, sucks in new configuration, and brings the
176
+ # machine back up with the new configuration.
177
+ def self.action_reload
178
+ Vagrant::Action::Builder.new.tap do |b|
179
+ b.use CheckVeertu
180
+ b.use Call, Created do |env1, b2|
181
+ if !env1[:result]
182
+ b2.use MessageNotCreated
183
+ next
184
+ end
185
+
186
+ b2.use ConfigValidate
187
+ b2.use action_halt
188
+ b2.use action_start
189
+ end
190
+ end
191
+ end
192
+
193
+ # This is the action that is primarily responsible for resuming
194
+ # suspended machines.
195
+ def self.action_resume
196
+ Vagrant::Action::Builder.new.tap do |b|
197
+ b.use CheckVeertu
198
+ b.use Call, Created do |env, b2|
199
+ if env[:result]
200
+ b2.use CheckAccessible
201
+ b2.use EnvSet, port_collision_repair: false
202
+ b2.use Resume
203
+ b2.use Provision
204
+ b2.use WaitForCommunicator, [:stopped, :paused, :suspending, :running, :starting]
205
+ else
206
+ b2.use MessageNotCreated
207
+ end
208
+ end
209
+ end
210
+ end
211
+
212
+
213
+ # This is the action that will exec into an SSH shell.
214
+ def self.action_ssh
215
+ Vagrant::Action::Builder.new.tap do |b|
216
+ b.use CheckVeertu
217
+ b.use CheckCreated
218
+ b.use CheckAccessible
219
+ b.use CheckRunning
220
+ b.use SSHExec
221
+ end
222
+ end
223
+
224
+ # This is the action that will run a single SSH command.
225
+ def self.action_ssh_run
226
+ Vagrant::Action::Builder.new.tap do |b|
227
+ b.use CheckVeertu
228
+ b.use CheckCreated
229
+ b.use CheckAccessible
230
+ b.use CheckRunning
231
+ b.use SSHRun
232
+ end
233
+ end
234
+
235
+ # This action starts a VM, assuming it is already imported and exists.
236
+ # A precondition of this action is that the VM exists.
237
+ def self.action_start
238
+ Vagrant::Action::Builder.new.tap do |b|
239
+ b.use CheckVeertu
240
+ b.use ConfigValidate
241
+ b.use BoxCheckOutdated
242
+ b.use Call, IsRunning do |env, b2|
243
+ # If the VM is running, then our work here is done, exit
244
+ if env[:result]
245
+ b2.use MessageAlreadyRunning
246
+ next
247
+ end
248
+
249
+ b2.use Call, IsSaved do |env2, b3|
250
+ if env2[:result]
251
+ # The VM is saved, so just resume it
252
+ b3.use action_resume
253
+ next
254
+ end
255
+
256
+ b3.use Call, IsPaused do |env3, b4|
257
+ if env3[:result]
258
+ b4.use Resume
259
+ next
260
+ end
261
+
262
+ # The VM is not saved, so we must have to boot it up
263
+ # like normal. Boot!
264
+ b4.use action_boot
265
+ end
266
+ end
267
+ end
268
+ end
269
+ end
270
+
271
+ # This is the action that is primarily responsible for suspending
272
+ # the virtual machine.
273
+ def self.action_suspend
274
+ Vagrant::Action::Builder.new.tap do |b|
275
+ b.use CheckVeertu
276
+ b.use Call, Created do |env, b2|
277
+ if env[:result]
278
+ b2.use CheckAccessible
279
+ b2.use Suspend
280
+ else
281
+ b2.use MessageNotCreated
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ # This is the action that is called to sync folders to a running
288
+ # machine without a reboot.
289
+ def self.action_sync_folders
290
+ Vagrant::Action::Builder.new.tap do |b|
291
+ b.use PrepareNFSValidIds
292
+ b.use SyncedFolders
293
+ b.use PrepareNFSSettings
294
+ end
295
+ end
296
+
297
+ # This action brings the machine up from nothing, including importing
298
+ # the box, configuring metadata, and booting.
299
+ def self.action_up
300
+ @logger = Log4r::Logger.new("vagrant::provider::veertu_5_0")
301
+ Vagrant::Action::Builder.new.tap do |b|
302
+ b.use CheckVeertu
303
+
304
+ # Handle box_url downloading early so that if the Vagrantfile
305
+ # references any files in the box or something it all just
306
+ # works fine.
307
+ b.use Call, Created do |env, b2|
308
+ if !env[:result]
309
+ b2.use HandleBox
310
+ end
311
+ end
312
+
313
+ b.use ConfigValidate
314
+ @logger.debug("after config validate")
315
+ b.use Call, Created do |env, b2|
316
+ # If the VM is NOT created yet, then do the setup steps
317
+ if !env[:result]
318
+ b2.use CheckAccessible
319
+ b2.use Customize, "pre-import"
320
+ b2.use Import
321
+ b2.use DiscardState
322
+ end
323
+ end
324
+ @logger.debug("before action start")
325
+ b.use action_start
326
+ end
327
+ end
328
+ end
329
+ end
330
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module ProviderVeertu
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
+ boot_mode = @env[:machine].provider_config.gui ? "gui" : "headless"
12
+
13
+ # Start up the VM and wait for it to boot.
14
+ env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
15
+ env[:machine].provider.driver.start(boot_mode)
16
+ @app.call(env)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end