vagrant-skytap 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.byebug_history +218 -0
- data/CHANGELOG.md +14 -0
- data/README.md +35 -45
- data/bar +6 -0
- data/eng-10269-cleanup.diff +247 -0
- data/eng-10269-tmp.diff +361 -0
- data/eng-10269.diff +577 -0
- data/eng-10269.diff.1 +455 -0
- data/lib/vagrant-skytap/action/initial_state.rb +20 -0
- data/lib/vagrant-skytap/action/is_parallelized.rb +21 -0
- data/lib/vagrant-skytap/action/message_resuming.rb +16 -0
- data/lib/vagrant-skytap/action/run_environment.rb +9 -3
- data/lib/vagrant-skytap/action/wait_for_communicator.rb +1 -1
- data/lib/vagrant-skytap/action.rb +74 -16
- data/lib/vagrant-skytap/api/environment.rb +4 -0
- data/lib/vagrant-skytap/api/runstate_operations.rb +9 -4
- data/lib/vagrant-skytap/command/start_mixins.rb +47 -0
- data/lib/vagrant-skytap/command/up.rb +126 -0
- data/lib/vagrant-skytap/plugin.rb +6 -1
- data/lib/vagrant-skytap/version.rb +1 -1
- data/locales/en.yml +4 -2
- data/spec/acceptance/provider/up_spec.rb +40 -0
- metadata +43 -31
data/eng-10269-tmp.diff
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
# HG changeset patch
|
2
|
+
# Parent 3713c076cd219f51dd1ec0e9bc6409b8bedae26f
|
3
|
+
# Parent 3c74e38a2da6d728e18975b99f87943a20209c10
|
4
|
+
[mq]: tmp
|
5
|
+
* * *
|
6
|
+
[mq]: 2015-11-19_20-26-00_r88+.diff
|
7
|
+
|
8
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/action.rb
|
9
|
+
--- a/lib/vagrant-skytap/action.rb Thu Nov 19 21:24:32 2015 -0800
|
10
|
+
+++ b/lib/vagrant-skytap/action.rb Thu Nov 19 21:25:06 2015 -0800
|
11
|
+
@@ -168,6 +168,11 @@
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
+ # Some middlewares perform further actions after the succeeding
|
16
|
+
+ # middleware returns. Provision and SyncedFolders, specifically,
|
17
|
+
+ # both require the machine to be booted. This requirement can be
|
18
|
+
+ # satisfied by putting the WaitForCommunicator middleware further
|
19
|
+
+ # down in the sequence.
|
20
|
+
def self.action_prepare_boot
|
21
|
+
Vagrant::Action::Builder.new.tap do |b|
|
22
|
+
b.use PrepareNFSSettings
|
23
|
+
@@ -188,27 +193,11 @@
|
24
|
+
def self.action_up
|
25
|
+
Vagrant::Action::Builder.new.tap do |b|
|
26
|
+
b.use action_create
|
27
|
+
-
|
28
|
+
- b.use Call, IsStopped do |env, b1|
|
29
|
+
- if env[:result]
|
30
|
+
- # this has some kind of hook that executes
|
31
|
+
- # when #action returns
|
32
|
+
- b1.use action_prepare_boot
|
33
|
+
- end
|
34
|
+
- end
|
35
|
+
-
|
36
|
+
- b.use Call, IsRunning do |env, b1|
|
37
|
+
- if env[:result]
|
38
|
+
- b1.use MessageAlreadyRunning
|
39
|
+
- next
|
40
|
+
- end
|
41
|
+
- b1.use RunVm
|
42
|
+
- b1.use WaitForCommunicator
|
43
|
+
- end
|
44
|
+
+ b.use action_run_vm
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
- # Pulled out of action_up to allow
|
49
|
+
+ # This action is called by our modified "up" command.
|
50
|
+
def self.action_create
|
51
|
+
Vagrant::Action::Builder.new.tap do |b|
|
52
|
+
b.use HandleBox
|
53
|
+
@@ -237,11 +226,49 @@
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
- def self.action_run_environment
|
58
|
+
+# # This action is called by our modified "up" command.
|
59
|
+
+# def self.action_update_properties
|
60
|
+
+# Vagrant::Action::Builder.new.tap do |b|
|
61
|
+
+# b.use InitializeAPIClient
|
62
|
+
+# b.use FetchEnvironment
|
63
|
+
+# b.use Call, IsStopped do |env, b1|
|
64
|
+
+# if env[:result]
|
65
|
+
+# b1.use UpdateHardware
|
66
|
+
+# b1.use SetHostname
|
67
|
+
+# end
|
68
|
+
+# end
|
69
|
+
+# end
|
70
|
+
+# end
|
71
|
+
+
|
72
|
+
+ # This action is called by our modified "up" command after
|
73
|
+
+ # all the VMs have been created. The action is called once
|
74
|
+
+ # for each machine, but by default, the RunEnvironment
|
75
|
+
+ # middleware will run all the machines in parallel; after
|
76
|
+
+ # the first invocation, RunEnvironment is a no-op.
|
77
|
+
+ def self.action_run_vm
|
78
|
+
Vagrant::Action::Builder.new.tap do |b|
|
79
|
+
b.use InitializeAPIClient
|
80
|
+
b.use FetchEnvironment
|
81
|
+
- b.use RunEnvironment
|
82
|
+
+ b.use Call, InitialState do |env, b1|
|
83
|
+
+ case env[:result]
|
84
|
+
+ when :running
|
85
|
+
+ b1.use MessageAlreadyRunning
|
86
|
+
+ next
|
87
|
+
+ when :suspended
|
88
|
+
+ b1.use Message, "The machine will be resumed"
|
89
|
+
+ when :stopped
|
90
|
+
+ b1.use action_prepare_boot
|
91
|
+
+ end
|
92
|
+
+
|
93
|
+
+ b1.use Call, IsParallelized do |env2, b2|
|
94
|
+
+ if env2[:result]
|
95
|
+
+ b2.use RunEnvironment
|
96
|
+
+ else
|
97
|
+
+ b2.use RunVm
|
98
|
+
+ end
|
99
|
+
+ end
|
100
|
+
+ end
|
101
|
+
+ b.use WaitForCommunicator
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
@@ -272,6 +299,8 @@
|
106
|
+
autoload :ExistenceCheck, action_root.join("existence_check")
|
107
|
+
autoload :FetchEnvironment, action_root.join("fetch_environment")
|
108
|
+
autoload :InitializeAPIClient, action_root.join("initialize_api_client")
|
109
|
+
+ autoload :InitialState, action_root.join("initial_state")
|
110
|
+
+ autoload :IsParallelized, action_root.join("is_parallelized")
|
111
|
+
autoload :IsRunning, action_root.join("is_running")
|
112
|
+
autoload :IsStopped, action_root.join("is_stopped")
|
113
|
+
autoload :IsSuspended, action_root.join("is_suspended")
|
114
|
+
@@ -284,6 +313,7 @@
|
115
|
+
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
116
|
+
autoload :ReadSSHInfo, action_root.join("read_ssh_info")
|
117
|
+
autoload :ReadState, action_root.join("read_state")
|
118
|
+
+ autoload :RequiresBoot, action_root.join("requires_boot")
|
119
|
+
autoload :RunEnvironment, action_root.join("run_environment")
|
120
|
+
autoload :RunVm, action_root.join("run_vm")
|
121
|
+
autoload :SetHostname, action_root.join("set_hostname")
|
122
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/action/initial_state.rb
|
123
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
124
|
+
+++ b/lib/vagrant-skytap/action/initial_state.rb Thu Nov 19 21:25:06 2015 -0800
|
125
|
+
@@ -0,0 +1,20 @@
|
126
|
+
+module VagrantPlugins
|
127
|
+
+ module Skytap
|
128
|
+
+ module Action
|
129
|
+
+ # This is specifically for the "up" action. When we run in parallel, we have
|
130
|
+
+ # to know which machines were initially powered off so we can set up operations
|
131
|
+
+ # which will happen after the machine is ready
|
132
|
+
+ class InitialState
|
133
|
+
+ def initialize(app, env)
|
134
|
+
+ @app = app
|
135
|
+
+ @logger = Log4r::Logger.new("vagrant_skytap::action::initial_state")
|
136
|
+
+ end
|
137
|
+
+
|
138
|
+
+ def call(env)
|
139
|
+
+ env[:result] = env[:initial_states][env[:machine].id]
|
140
|
+
+ @app.call(env)
|
141
|
+
+ end
|
142
|
+
+ end
|
143
|
+
+ end
|
144
|
+
+ end
|
145
|
+
+end
|
146
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/action/is_parallelized.rb
|
147
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
148
|
+
+++ b/lib/vagrant-skytap/action/is_parallelized.rb Thu Nov 19 21:25:06 2015 -0800
|
149
|
+
@@ -0,0 +1,21 @@
|
150
|
+
+module VagrantPlugins
|
151
|
+
+ module Skytap
|
152
|
+
+ module Action
|
153
|
+
+ # This can be used with "Call" built-in to check if the action
|
154
|
+
+ # is being performed as part of a parallel operation.
|
155
|
+
+ class IsParallelized
|
156
|
+
+ def initialize(app, env)
|
157
|
+
+ @app = app
|
158
|
+
+ @logger = Log4r::Logger.new("vagrant_skytap::action::is_parallelized")
|
159
|
+
+ end
|
160
|
+
+
|
161
|
+
+ def call(env)
|
162
|
+
+ env[:result] = env[:parallel]
|
163
|
+
+ @logger.info("Parallelization is #{env[:result] ? 'on' : 'off'}")
|
164
|
+
+
|
165
|
+
+ @app.call(env)
|
166
|
+
+ end
|
167
|
+
+ end
|
168
|
+
+ end
|
169
|
+
+ end
|
170
|
+
+end
|
171
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/action/requires_boot.rb
|
172
|
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
173
|
+
+++ b/lib/vagrant-skytap/action/requires_boot.rb Thu Nov 19 21:25:06 2015 -0800
|
174
|
+
@@ -0,0 +1,20 @@
|
175
|
+
+module VagrantPlugins
|
176
|
+
+ module Skytap
|
177
|
+
+ module Action
|
178
|
+
+ # This can be used with "Call" built-in to check if the machine
|
179
|
+
+ # was stopped at the beginning of the command and needs the prepare_boot
|
180
|
+
+ # action. If this information is not captured,
|
181
|
+
+ class RequiresBoot
|
182
|
+
+ def initialize(app, env)
|
183
|
+
+ @app = app
|
184
|
+
+ @logger = Log4r::Logger.new("vagrant_skytap::action::requires_boot")
|
185
|
+
+ end
|
186
|
+
+
|
187
|
+
+ def call(env)
|
188
|
+
+ env[:result] = env[:require_boot].collect(&:id).include?(env[:machine].id)
|
189
|
+
+ @app.call(env)
|
190
|
+
+ end
|
191
|
+
+ end
|
192
|
+
+ end
|
193
|
+
+ end
|
194
|
+
+end
|
195
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/action/run_environment.rb
|
196
|
+
--- a/lib/vagrant-skytap/action/run_environment.rb Thu Nov 19 21:24:32 2015 -0800
|
197
|
+
+++ b/lib/vagrant-skytap/action/run_environment.rb Thu Nov 19 21:25:06 2015 -0800
|
198
|
+
@@ -3,7 +3,8 @@
|
199
|
+
module VagrantPlugins
|
200
|
+
module Skytap
|
201
|
+
module Action
|
202
|
+
- # Runs the Skytap environment.
|
203
|
+
+ # Runs multiple VMs in parallel. The :first_machine flag is used to prevent
|
204
|
+
+ # redundant REST calls on subsequent invocations.
|
205
|
+
class RunEnvironment
|
206
|
+
include Vagrant::Util::Retryable
|
207
|
+
|
208
|
+
@@ -16,10 +17,14 @@
|
209
|
+
end
|
210
|
+
|
211
|
+
def call(env)
|
212
|
+
- env[:ui].info(I18n.t("vagrant_skytap.running_environment"))
|
213
|
+
- vm_ids = env[:machines].try(:collect, &:id)
|
214
|
+
- @logger.info("Running VMs: #{vm_ids}")
|
215
|
+
- env[:environment].run!(vm_ids)
|
216
|
+
+ # Since the middleware sequence is called for each machine, use a
|
217
|
+
+ # flag to ensure that we only make the request once.
|
218
|
+
+ if env[:first_machine]
|
219
|
+
+ env[:ui].info(I18n.t("vagrant_skytap.running_environment"))
|
220
|
+
+ vm_ids = env[:machines].try(:collect, &:id)
|
221
|
+
+ @logger.info("Running VMs: #{vm_ids}")
|
222
|
+
+ env[:environment].run!(vm_ids)
|
223
|
+
+ end
|
224
|
+
|
225
|
+
@app.call(env)
|
226
|
+
end
|
227
|
+
diff -r 3713c076cd21 lib/vagrant-skytap/command/up.rb
|
228
|
+
--- a/lib/vagrant-skytap/command/up.rb Thu Nov 19 21:24:32 2015 -0800
|
229
|
+
+++ b/lib/vagrant-skytap/command/up.rb Thu Nov 19 21:25:06 2015 -0800
|
230
|
+
@@ -1,24 +1,23 @@
|
231
|
+
require 'optparse'
|
232
|
+
|
233
|
+
require "vagrant"
|
234
|
+
-require 'byebug'
|
235
|
+
+require "byebug"
|
236
|
+
|
237
|
+
require_relative 'start_mixins'
|
238
|
+
|
239
|
+
-# This is a copy of Vagrant's built-in "up" command which handles
|
240
|
+
-# parallel runstate changes by invoking the run_environment action
|
241
|
+
-# once for all machines: runstate operations lock the environment,
|
242
|
+
-# and are therefore not thread-safe.
|
243
|
+
+# This is a modified copy of the built-in "up" command, which alters how
|
244
|
+
+# parallelization is implemented. Instead of making concurrent requests to run
|
245
|
+
+# individual VMs, we make a single REST call to update the runstates of
|
246
|
+
+# multiple VMs within the containing Skytap environment.
|
247
|
+
|
248
|
+
module VagrantPlugins
|
249
|
+
module Skytap
|
250
|
+
module Command
|
251
|
+
- #class Up < VagrantPlugins::CommandUp::Command
|
252
|
+
class Up < Vagrant.plugin("2", :command)
|
253
|
+
include StartMixins
|
254
|
+
|
255
|
+
def self.synopsis
|
256
|
+
- "starts and provisions the vagrant environment (with parallel runstate support)"
|
257
|
+
+ "starts and provisions the vagrant environment"
|
258
|
+
end
|
259
|
+
|
260
|
+
def execute
|
261
|
+
@@ -61,9 +60,7 @@
|
262
|
+
# Go over each VM and bring it up
|
263
|
+
@logger.debug("'Up' each target VM...")
|
264
|
+
|
265
|
+
-
|
266
|
+
- # Begin modified section
|
267
|
+
-
|
268
|
+
+ # Create the VMs, then pass all the machines to the run action
|
269
|
+
machines = []
|
270
|
+
names = argv
|
271
|
+
if names.empty?
|
272
|
+
@@ -79,41 +76,42 @@
|
273
|
+
names = nil if autostart && names.empty?
|
274
|
+
end
|
275
|
+
|
276
|
+
- with_target_vms(names, provider: options[:provider]) do |machine|
|
277
|
+
- @env.ui.info(I18n.t(
|
278
|
+
- "vagrant.commands.up.upping",
|
279
|
+
- name: machine.name,
|
280
|
+
- provider: machine.provider_name))
|
281
|
+
+ if names
|
282
|
+
+ with_target_vms(names, provider: options[:provider]) do |machine|
|
283
|
+
+ @env.ui.info(I18n.t(
|
284
|
+
+ "vagrant.commands.up.upping",
|
285
|
+
+ name: machine.name,
|
286
|
+
+ provider: machine.provider_name))
|
287
|
+
|
288
|
+
- machines << machine
|
289
|
+
+ machines << machine
|
290
|
+
+ machine.action(:create, options)
|
291
|
+
+ end
|
292
|
+
|
293
|
+
- if options[:parallel]
|
294
|
+
- machine.action(:create, options)
|
295
|
+
- else
|
296
|
+
- machine.action(:up, options)
|
297
|
+
+ # Capture states before the parallel runstate operation.
|
298
|
+
+ # Checking state is relatively expensive. we should be smarter
|
299
|
+
+ # about what information to capture. For example, we can
|
300
|
+
+ # determine which machines were newly created, and put them in
|
301
|
+
+ # the :stopped collection. Or call them :created? No, that
|
302
|
+
+ # would likely be confusing
|
303
|
+
+ #require_boot = machines.select{|m| m.state.id == :stopped}
|
304
|
+
+ initial_states = machines.inject({}) do |acc, m|
|
305
|
+
+ acc[m.id] = m.state.id
|
306
|
+
+ acc
|
307
|
+
+ end
|
308
|
+
+
|
309
|
+
+ machines.each_with_index do |machine, i|
|
310
|
+
+ machine.action(:run_vm, options.merge(
|
311
|
+
+ first_machine: i == 0,
|
312
|
+
+ machines: machines,
|
313
|
+
+ #require_boot: require_boot,
|
314
|
+
+ initial_states: initial_states
|
315
|
+
+ ))
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
- if options[:parallel]
|
320
|
+
- @env.action_runner.run(VagrantPlugins::Skytap::Action.action_run_environment,
|
321
|
+
- local_data_path: @env.local_data_path,
|
322
|
+
- machines: machines,
|
323
|
+
- machine: machines.first,
|
324
|
+
- base_url: nil,
|
325
|
+
- username: nil,
|
326
|
+
- api_token: nil,
|
327
|
+
- ui: @env.ui
|
328
|
+
- )
|
329
|
+
- end
|
330
|
+
-
|
331
|
+
- # End modified section
|
332
|
+
-
|
333
|
+
-
|
334
|
+
if machines.empty?
|
335
|
+
@env.ui.info(I18n.t("vagrant.up_no_machines"))
|
336
|
+
return 0
|
337
|
+
- else
|
338
|
+
-
|
339
|
+
end
|
340
|
+
|
341
|
+
# Output the post-up messages that we have, if any
|
342
|
+
@@ -137,3 +135,4 @@
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
+
|
347
|
+
diff -r 3713c076cd21 locales/en.yml
|
348
|
+
--- a/locales/en.yml Thu Nov 19 21:24:32 2015 -0800
|
349
|
+
+++ b/locales/en.yml Thu Nov 19 21:25:06 2015 -0800
|
350
|
+
@@ -53,6 +53,11 @@
|
351
|
+
vm_url_required:
|
352
|
+
The URL of a Skytap VM must be specified via "vm_url"
|
353
|
+
|
354
|
+
+ commands:
|
355
|
+
+ up:
|
356
|
+
+ creating: |-
|
357
|
+
+ Creating machine '%{name}' with '%{provider}' provider...
|
358
|
+
+
|
359
|
+
errors:
|
360
|
+
instance_ready_timeout: |-
|
361
|
+
The instance never became "ready" in Skytap. The timeout currently
|