zergrush 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWUwZWU4OTlhNDkwZGYyNjJmMTM5ODAzMjJmNGJlMDlkZjYwOWFlMg==
4
+ NmRiYzkxMDc5YWM3YWQ5NThmOTRjYWNiMGM4MmUxNzA1NmQyYzVjOA==
5
5
  data.tar.gz: !binary |-
6
- OTAwZDMzODdlNGFiM2E0YWQ4ZDViZWVkMjBhZGNiODNjNjRjMDc1MQ==
6
+ ZDJhZjNkZDhhNGQyYTU4MWY0ODQxZWJjNThmY2RkNDQ4YWQ3YjkwOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzQ4YjY0MTkzZTEyZDJlNzQxNTQ4YmZlZTA5N2FkZWUzNDE2Y2M1OWExMDA2
10
- ZWZiZThkMTUwOGMxMDM5Zjc2N2FkOTZjZjE2YTI3ZmVhZjNmYTc2MjU2OWZm
11
- OWRiMDJjZjVmNTc5OTUwMWQ3ZWViNGFjNzEyOTc5ZDQyYTRlZjQ=
9
+ NDNmNjBiYzQ3OWQxMGNjMzUxZmQxMTlkOGQwMjZkYTI2YzNlMWNhNTJmMjk2
10
+ MDVlYWRjODIzNTg0YWUwMmJkYmU2OTJhY2EyMjczZjNjZmM0ZWQxMzM5MjM3
11
+ NGYxZmZhMjY1YmQ3MWZkYTc3MzAxNjIwMWExMTg2NDA5NzY4Mjk=
12
12
  data.tar.gz: !binary |-
13
- YTdlMGVkZmQzYTU0MmRlYjBhMjUwMjg4ZmE2NDg3YTMyZTNmYzFkMjc5MmVj
14
- N2VmOTczYjYzODEzNGVmN2M3MTdmNzg3NjkzMDEyY2NjMDQ5ODY1ODYyNTkw
15
- MjA3YTU0YzgyNTkyYWUyNTE0ZThmNWNiZjM0ZWNiODdlMWM2OTI=
13
+ ZWJlYzQzNDhhOTY3NzUyOWE2MjM5MzQ1ZDk5ZjU4NjNlNjVkMzYwMWI5NTk4
14
+ ZGVhYjhjNTc5ZTlkZjVlNDQwYTY0NmFhMjMzMjFkZDQwOTliZTI3OWJiMDBl
15
+ ZmM5NTQ2Y2M2Zjg5ZmFjZTQzMzYzM2I3OWYyNmI1MzA3MjkyYzA=
data/data/ke.schema CHANGED
@@ -133,7 +133,29 @@
133
133
  ],
134
134
  "additionalProperties": false
135
135
  }
136
- }
136
+ },
137
+ "additional_files": {
138
+ "type": "array",
139
+ "items": {
140
+ "properties": {
141
+ "file": {
142
+ "type": "object",
143
+ "properties": {
144
+ "from": {
145
+ "type": "string"
146
+ },
147
+ "to": {
148
+ "type": "string"
149
+ }
150
+ },
151
+ "required": [
152
+ "from",
153
+ "to"
154
+ ]
155
+ }
156
+ }
157
+ }
158
+ }
137
159
  },
138
160
  "required": [
139
161
  "driver",
@@ -6,8 +6,8 @@ Feature: Hive
6
6
  Scenario: Initializing hive
7
7
  When I run `zerg init`
8
8
  Then the following files should exist:
9
- | .hive/helloworld.ke | .hive/helloaws.ke |
10
- Then the file ".hive/helloworld.ke" should contain:
9
+ | .hive/helloworld/helloworld.ke | .hive/helloaws/helloaws.ke |
10
+ Then the file ".hive/helloworld/helloworld.ke" should contain:
11
11
  """
12
12
  {
13
13
  "num_instances": 3,
@@ -73,7 +73,7 @@ Feature: Hive
73
73
  }
74
74
  """
75
75
 
76
- Then the file ".hive/helloaws.ke" should contain:
76
+ Then the file ".hive/helloaws/helloaws.ke" should contain:
77
77
  """
78
78
  {
79
79
  "num_instances": 3,
@@ -214,8 +214,8 @@ Feature: Hive
214
214
  | HIVE_CWD | ./overriden/hive/dir |
215
215
  When I run `zerg init`
216
216
  Then the following files should exist:
217
- | overriden/hive/dir/.hive/helloworld.ke | overriden/hive/dir/.hive/helloaws.ke |
218
- Then the file "overriden/hive/dir/.hive/helloworld.ke" should contain:
217
+ | overriden/hive/dir/.hive/helloworld/helloworld.ke | overriden/hive/dir/.hive/helloaws/helloaws.ke |
218
+ Then the file "overriden/hive/dir/.hive/helloworld/helloworld.ke" should contain:
219
219
  """
220
220
  {
221
221
  "num_instances": 3,
@@ -281,7 +281,7 @@ Feature: Hive
281
281
  }
282
282
  """
283
283
 
284
- Then the file "overriden/hive/dir/.hive/helloaws.ke" should contain:
284
+ Then the file "overriden/hive/dir/.hive/helloaws/helloaws.ke" should contain:
285
285
  """
286
286
  {
287
287
  "num_instances": 3,
@@ -40,8 +40,8 @@ module Zerg
40
40
 
41
41
  def copy_sample_task
42
42
  load_path = (ENV['HIVE_CWD'] == nil) ? File.join("#{Dir.pwd}", ".hive") : File.join("#{ENV['HIVE_CWD']}", ".hive")
43
- template("template.ke", "#{File.join(load_path, "helloworld.ke")}")
44
- template("awstemplate.ke", "#{File.join(load_path, "helloaws.ke")}")
43
+ template("template.ke", "#{File.join(load_path, "helloworld", "helloworld.ke")}")
44
+ template("awstemplate.ke", "#{File.join(load_path, "helloaws", "helloaws.ke")}")
45
45
  end
46
46
  end
47
47
  end
data/lib/zerg/hive.rb CHANGED
@@ -48,7 +48,7 @@ module Zerg
48
48
 
49
49
  # load all .ke files into one big hash
50
50
  @hive = Hash.new
51
- Dir.glob(File.join("#{@load_path}", "*.ke")) do |ke_file|
51
+ Dir["#{File.join(@load_path, "**/*.ke")}"].each { |ke_file|
52
52
  # do work on files ending in .rb in the desired directory
53
53
  begin
54
54
  ke_file_hash = JSON.parse( IO.read(ke_file) )
@@ -56,11 +56,16 @@ module Zerg
56
56
  rescue JSON::ParserError
57
57
  abort("ERROR: Could not parse #{ke_file}. Likely invalid JSON.")
58
58
  end
59
- end
59
+ }
60
60
 
61
61
  @loaded = true
62
62
  end
63
63
 
64
+ def self.copy_with_path(src, dst)
65
+ FileUtils.mkdir_p(File.dirname(dst))
66
+ FileUtils.cp(src, dst)
67
+ end
68
+
64
69
  def self.list
65
70
  instance.load
66
71
 
@@ -85,7 +90,7 @@ module Zerg
85
90
  def self.verify
86
91
  instance.load
87
92
 
88
- Dir.glob(File.join("#{instance.load_path}", "*.ke")) do |ke_file|
93
+ Dir["#{File.join("#{instance.load_path}", "**/*.ke")}"].each { |ke_file|
89
94
  begin
90
95
  ke_file_hash = JSON.parse( File.open(ke_file, 'r').read )
91
96
 
@@ -112,7 +117,7 @@ module Zerg
112
117
  rescue ZergGemPlugin::PluginNotLoaded
113
118
  abort("ERROR: driver #{ke_file_hash["vm"]["driver"]["drivertype"]} not found. Did you install the plugin gem?")
114
119
  end
115
- end
120
+ }
116
121
 
117
122
  puts "SUCCESS!"
118
123
  end
@@ -120,7 +125,7 @@ module Zerg
120
125
  def self.import(file, force)
121
126
  instance.load
122
127
  abort("ERROR: '#{file}' not found!") unless File.exist?(file)
123
- abort("ERROR: '#{File.basename(file)}' already exists in hive!") unless !File.exist?(File.join(instance.load_path, File.basename(file))) || force == true
128
+ abort("ERROR: '#{File.basename(file)}' already exists in hive!") unless !File.directory?(File.join(instance.load_path, File.basename(file))) || force == true
124
129
 
125
130
  # check the file against schema.
126
131
  begin
@@ -145,7 +150,26 @@ module Zerg
145
150
  errors = JSON::Validator.fully_validate(full_schema, ke_file_hash, :errors_as_objects => true)
146
151
  abort("ERROR: #{file} failed validation. Errors: #{errors.ai}") unless errors.empty?
147
152
 
148
- FileUtils.cp(file, File.join(instance.load_path, File.basename(file)))
153
+ # copy the .ke file
154
+ copy_with_path(file, File.join(instance.load_path, File.basename(file, ".*"), File.basename(file)))
155
+
156
+ # copy additonal files
157
+ if ke_file_hash["vm"]["additional_files"] != nil
158
+ ke_file_hash["vm"]["additional_files"].each { |additonal_file|
159
+ additonal_file_path = additonal_file["from"]
160
+
161
+ # eval possible environment variables
162
+ if additonal_file_path =~ /^ENV\['.+'\]$/
163
+ additonal_file_path = eval(additonal_file_path)
164
+ end
165
+
166
+ # determine if a relative path or a full path is provided. relative path should be relative to
167
+ # location of the .ke file
168
+ additonal_file_path = ((Pathname.new additonal_file_path).absolute?) ? additonal_file_path : File.expand_path(File.dirname(additonal_file_path), file)
169
+ abort("ERROR: '#{additonal_file_path}' not found!") unless File.exist?(additonal_file_path)
170
+ copy_with_path(additonal_file_path, File.join(instance.load_path, File.basename(file, ".*"), additonal_file["to"]))
171
+ }
172
+ end
149
173
  rescue JSON::ParserError => err
150
174
  abort("ERROR: Could not parse #{file}. Likely invalid JSON.")
151
175
  end
@@ -154,10 +178,7 @@ module Zerg
154
178
 
155
179
  def self.remove(taskname, force)
156
180
  instance.load
157
- abort("ERROR: '#{taskname}' not found!") unless File.exist?(File.join(instance.load_path, "#{taskname}.ke"))
158
-
159
- # check the file against schema.
160
- taskfile = File.join(instance.load_path, "#{taskname}.ke")
181
+ abort("ERROR: '#{taskname}' not found!") unless File.directory?(File.join(instance.load_path, "#{taskname}"))
161
182
 
162
183
  agreed = true
163
184
  if force != true
@@ -167,7 +188,7 @@ module Zerg
167
188
  abort("Cancelled!") unless agreed == true
168
189
 
169
190
  FileUtils.rm_rf(File.join(instance.load_path, "driver", taskname))
170
- FileUtils.rm(File.join(instance.load_path, "#{taskname}.ke"))
191
+ FileUtils.rm_rf(File.join(instance.load_path, "#{taskname}"))
171
192
 
172
193
  puts "SUCCESS!"
173
194
  end
data/lib/zerg/version.rb CHANGED
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Zerg
25
- VERSION = "0.0.8"
25
+ VERSION = "0.0.9"
26
26
  end
data/zerg.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency "thor"
28
28
  s.add_dependency "highline"
29
29
  s.add_dependency "zergrush_vagrant", ">= 0.0.4"
30
- s.add_dependency "zergrush_cf", ">= 0.0.1"
30
+ s.add_dependency "zergrush_cf", ">= 0.0.2"
31
31
 
32
32
  s.files = `git ls-files`.split("\n")
33
33
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
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.8
4
+ version: 0.0.9
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-03-14 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
- version: 0.0.1
173
+ version: 0.0.2
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ! '>='
179
179
  - !ruby/object:Gem::Version
180
- version: 0.0.1
180
+ version: 0.0.2
181
181
  description: Zerg is a tool for launching an arbitrary number of virtual machines
182
182
  and running a task on all of them at once
183
183
  email: