zergrush 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f924664a04bc1e0605d12801bca3741380730040
4
- data.tar.gz: 4a9616f8ce6752c06e2e659a8d08b13f43a43b51
3
+ metadata.gz: 844bb8bd048291c52f73b059cf340e77bed04a10
4
+ data.tar.gz: 8f0f0fcc66cf2f8b343069e5584bb06f8a2c1094
5
5
  SHA512:
6
- metadata.gz: 9df78ac67d6dd997b3b3882f822501ab0aa51df9962a15ddf47257cca166fb526236ccd1c9644adf4db96e4270811023b703fffb76260959e2062e8348977a56
7
- data.tar.gz: 0b1d6fa697102325d58567390bab7b17a82dccafa8270bd96eca3a50b31e417276c1c7c7c62388c8ffaa040669d683ac2db304d55c049aafb8f5a5ccbf03b914
6
+ metadata.gz: 93e4655161b2f76b6d4ed89c36c31cf25c1be5dcb62eae005adc66cff9ec69530a81cd5db3bb0746ea175c975ece829fe1948b8b414663ce257020d7dc1044dd
7
+ data.tar.gz: 9c936ece2eb8ae857e74c32dc402c1396430311873cd4c7a8673e9a0add222716a9872a942c8909bf7fb64afaa7cddd28b68cc9ae0e65ee2ec7a59a147b780f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zergrush (0.0.1)
4
+ zergrush (0.0.2)
5
5
  awesome_print
6
6
  highline
7
7
  json-schema
data/data/ke.schema CHANGED
@@ -306,6 +306,10 @@
306
306
  "bridge_description": {
307
307
  "type": "string",
308
308
  "id": "com.mtnsat.zerg.json.ke.vm.bridge_description"
309
+ },
310
+ "keepalive": {
311
+ "type": "boolean",
312
+ "id": "com.mtnsat.zerg.json.ke.vm.keepalive"
309
313
  }
310
314
  },
311
315
  "required": [
@@ -1,4 +1,4 @@
1
1
  require 'aruba/cucumber'
2
2
  Before do
3
- @aruba_timeout_seconds = 120
3
+ @aruba_timeout_seconds = 1200
4
4
  end
@@ -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
- run(taskname, task["vm"]["driver"]["drivertype"], task["vm"]["driver"]["providertype"], task["instances"], debug)
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 run(taskname, driver, provider, instances, debug)
140
- # TODO: generalize to multiple drivers
141
- abort("ERROR: Vagrant not installed!") unless which("vagrant") != nil
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
- puts("DONE! Halting all vagrant virtual machines...")
191
- # halt all machines
192
- halt_pid = nil
193
- for index in 0..instances - 1
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
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Zerg
25
- VERSION = "0.0.1"
25
+ VERSION = "0.0.2"
26
26
  end
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.1
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-13 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler