zergrush 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +1 -1
- data/data/ke.schema +4 -0
- data/features/support/setup.rb +1 -1
- data/features/task.feature +55 -0
- data/lib/zerg/cli.rb +5 -0
- data/lib/zerg/runner.rb +44 -18
- data/lib/zerg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 844bb8bd048291c52f73b059cf340e77bed04a10
|
4
|
+
data.tar.gz: 8f0f0fcc66cf2f8b343069e5584bb06f8a2c1094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93e4655161b2f76b6d4ed89c36c31cf25c1be5dcb62eae005adc66cff9ec69530a81cd5db3bb0746ea175c975ece829fe1948b8b414663ce257020d7dc1044dd
|
7
|
+
data.tar.gz: 9c936ece2eb8ae857e74c32dc402c1396430311873cd4c7a8673e9a0add222716a9872a942c8909bf7fb64afaa7cddd28b68cc9ae0e65ee2ec7a59a147b780f3
|
data/Gemfile.lock
CHANGED
data/data/ke.schema
CHANGED
data/features/support/setup.rb
CHANGED
data/features/task.feature
CHANGED
@@ -29,3 +29,58 @@ Feature: Tasks
|
|
29
29
|
ERROR:
|
30
30
|
"""
|
31
31
|
And the exit status should be 1
|
32
|
+
|
33
|
+
Scenario: Running a task
|
34
|
+
When I run `zerg init`
|
35
|
+
When I run `zerg rush helloworld`
|
36
|
+
Then the output should contain:
|
37
|
+
"""
|
38
|
+
SUCCESS!
|
39
|
+
"""
|
40
|
+
And the exit status should be 0
|
41
|
+
|
42
|
+
Scenario: Halting a task with keepalive
|
43
|
+
Given a file named "arubatask.ke" with:
|
44
|
+
"""
|
45
|
+
{
|
46
|
+
"instances": 1,
|
47
|
+
"tasks": [
|
48
|
+
{
|
49
|
+
"type": "shell",
|
50
|
+
"inline": "echo \"ZERG RUSH!\""
|
51
|
+
}
|
52
|
+
],
|
53
|
+
"vm": {
|
54
|
+
"driver": {
|
55
|
+
"drivertype": "vagrant",
|
56
|
+
"providertype": "virtualbox",
|
57
|
+
"provider_options": [
|
58
|
+
"virtualbox.gui = false",
|
59
|
+
"virtualbox.memory = 256"
|
60
|
+
]
|
61
|
+
},
|
62
|
+
"keepalive": true,
|
63
|
+
"basebox": "http://files.vagrantup.com/precise32.box",
|
64
|
+
"private_network": false
|
65
|
+
}
|
66
|
+
}
|
67
|
+
"""
|
68
|
+
|
69
|
+
When I run `zerg init`
|
70
|
+
When I run `zerg hive import arubatask.ke`
|
71
|
+
When I run `zerg rush arubatask`
|
72
|
+
Then the output should contain:
|
73
|
+
"""
|
74
|
+
Will leave instances running.
|
75
|
+
SUCCESS!
|
76
|
+
"""
|
77
|
+
And the exit status should be 0
|
78
|
+
|
79
|
+
When I run `zerg halt arubatask`
|
80
|
+
Then the output should contain:
|
81
|
+
"""
|
82
|
+
[zergling_0] Attempting graceful shutdown of VM...
|
83
|
+
SUCCESS!
|
84
|
+
"""
|
85
|
+
And the exit status should be 0
|
86
|
+
|
data/lib/zerg/cli.rb
CHANGED
@@ -78,6 +78,11 @@ module Zerg
|
|
78
78
|
desc "clean [TASK]", "cleans a task"
|
79
79
|
def clean(task)
|
80
80
|
puts Zerg::Runner.clean(task, options[:debug])
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "halt [TASK]", "stops all task vm instances"
|
84
|
+
def halt(task)
|
85
|
+
puts Zerg::Runner.halt(task, options[:debug])
|
81
86
|
end
|
82
87
|
|
83
88
|
register(HiveCLI, 'hive', 'hive [COMMAND]', 'Manage hive - a collection of task descriptions.')
|
data/lib/zerg/runner.rb
CHANGED
@@ -56,7 +56,7 @@ module Zerg
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# cross platform way of checking if command is available in PATH
|
59
|
-
def which(cmd)
|
59
|
+
def self.which(cmd)
|
60
60
|
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
61
61
|
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
62
62
|
exts.each { |ext|
|
@@ -95,11 +95,11 @@ module Zerg
|
|
95
95
|
end
|
96
96
|
}
|
97
97
|
|
98
|
-
|
98
|
+
|
99
|
+
run(taskname, task["vm"]["driver"]["drivertype"], task["vm"]["driver"]["providertype"], task["instances"], (task["vm"]["keepalive"] == nil) ? false : task["vm"]["keepalive"], debug)
|
99
100
|
end
|
100
101
|
|
101
102
|
def cleanup(taskname, task, debug)
|
102
|
-
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
103
103
|
puts ("Will cleanup task #{taskname}...")
|
104
104
|
|
105
105
|
# TODO: generalize for multiple drivers
|
@@ -136,10 +136,25 @@ module Zerg
|
|
136
136
|
Process.wait(cleanup_pid)
|
137
137
|
end
|
138
138
|
|
139
|
-
def
|
140
|
-
|
141
|
-
|
139
|
+
def halt(taskname, driver, provider, instances, debug)
|
140
|
+
puts("Halting all vagrant virtual machines...")
|
141
|
+
debug_string = (debug == true) ? " --debug" : ""
|
142
|
+
|
143
|
+
# halt all machines
|
144
|
+
halt_pid = nil
|
145
|
+
for index in 0..instances - 1
|
146
|
+
halt_pid = Process.spawn(
|
147
|
+
{
|
148
|
+
"VAGRANT_CWD" => File.join("#{Dir.pwd}", ".hive", "driver", driver, taskname),
|
149
|
+
"VAGRANT_DEFAULT_PROVIDER" => "#{provider}"
|
150
|
+
},
|
151
|
+
"vagrant halt zergling_#{index}#{debug_string}")
|
152
|
+
Process.wait(halt_pid)
|
153
|
+
abort("ERROR: vagrant halt failed on machine zergling_#{index}!") unless $?.exitstatus == 0
|
154
|
+
end
|
155
|
+
end
|
142
156
|
|
157
|
+
def run(taskname, driver, provider, instances, keepalive, debug)
|
143
158
|
check_provider(driver, provider)
|
144
159
|
|
145
160
|
debug_string = (debug == true) ? " --debug" : ""
|
@@ -187,18 +202,10 @@ module Zerg
|
|
187
202
|
}.join
|
188
203
|
}
|
189
204
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
halt_pid = Process.spawn(
|
195
|
-
{
|
196
|
-
"VAGRANT_CWD" => File.join("#{Dir.pwd}", ".hive", "driver", driver, taskname),
|
197
|
-
"VAGRANT_DEFAULT_PROVIDER" => "#{provider}"
|
198
|
-
},
|
199
|
-
"vagrant halt zergling_#{index}#{debug_string}")
|
200
|
-
Process.wait(halt_pid)
|
201
|
-
abort("ERROR: vagrant halt failed on machine zergling_#{index}!") unless $?.exitstatus == 0
|
205
|
+
if keepalive == false
|
206
|
+
halt(taskname, driver, provider, instances, debug)
|
207
|
+
else
|
208
|
+
puts "Will leave instances running."
|
202
209
|
end
|
203
210
|
|
204
211
|
abort("ERROR: Finished with errors in: #{errors.to_s}") unless errors.length == 0
|
@@ -206,6 +213,8 @@ module Zerg
|
|
206
213
|
end
|
207
214
|
|
208
215
|
def self.rush(task, debug)
|
216
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
217
|
+
|
209
218
|
# load the hive first
|
210
219
|
Zerg::Hive.instance.load
|
211
220
|
|
@@ -217,7 +226,24 @@ module Zerg
|
|
217
226
|
runner.process(task, Zerg::Hive.instance.hive[task], debug);
|
218
227
|
end
|
219
228
|
|
229
|
+
def self.halt(task, debug)
|
230
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
231
|
+
|
232
|
+
# load the hive first
|
233
|
+
Zerg::Hive.instance.load
|
234
|
+
|
235
|
+
puts "Loaded hive. Looking for task #{task}..."
|
236
|
+
abort("ERROR: Task #{task} not found in current hive!") unless Zerg::Hive.instance.hive.has_key?(task)
|
237
|
+
|
238
|
+
# halt!
|
239
|
+
runner = Runner.new
|
240
|
+
runner.halt(task, Zerg::Hive.instance.hive[task]["vm"]["driver"]["drivertype"], Zerg::Hive.instance.hive[task]["vm"]["driver"]["providertype"], Zerg::Hive.instance.hive[task]["instances"], debug)
|
241
|
+
puts("SUCCESS!")
|
242
|
+
end
|
243
|
+
|
220
244
|
def self.clean(task, debug)
|
245
|
+
abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
|
246
|
+
|
221
247
|
# load the hive first
|
222
248
|
Zerg::Hive.instance.load
|
223
249
|
|
data/lib/zerg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zergrush
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MTN Satellite Communications
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|