caterer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/caterer/command/base.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'oj'
|
2
|
+
require 'multi_json'
|
3
|
+
|
1
4
|
module Caterer
|
2
5
|
module Command
|
3
6
|
class Base < Vli::Command::Base
|
@@ -16,6 +19,9 @@ module Caterer
|
|
16
19
|
opts.on('-P PORT', '--port PORT', 'assumes 22') do |p|
|
17
20
|
options[:port] = p
|
18
21
|
end
|
22
|
+
opts.on('-d JSON', '--data JSON', 'json data that the provisioner may use' )do |d|
|
23
|
+
options[:data] = d
|
24
|
+
end
|
19
25
|
opts.on('-i IMAGE', '--image IMAGE', 'corresponds to a image in Caterfile') do |i|
|
20
26
|
options[:image] = i
|
21
27
|
end
|
@@ -86,6 +92,14 @@ module Caterer
|
|
86
92
|
opts[:port] = options[:port] || member.port
|
87
93
|
opts[:images] = image_list(options) || member.images || group.images
|
88
94
|
|
95
|
+
opts[:data] = begin
|
96
|
+
data = nil
|
97
|
+
if json = options[:data]
|
98
|
+
data = MultiJson.load json rescue nil
|
99
|
+
end
|
100
|
+
data || member.data || group.data
|
101
|
+
end
|
102
|
+
|
89
103
|
Server.new(@env, opts)
|
90
104
|
end
|
91
105
|
|
data/lib/caterer/config/group.rb
CHANGED
@@ -197,7 +197,11 @@ module Caterer
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def json_config
|
200
|
-
MultiJson.dump(
|
200
|
+
MultiJson.dump(config_data)
|
201
|
+
end
|
202
|
+
|
203
|
+
def config_data
|
204
|
+
config.json.merge(server.data).merge({:run_list => config.run_list})
|
201
205
|
end
|
202
206
|
|
203
207
|
def json_config_path
|
data/lib/caterer/server.rb
CHANGED
@@ -13,6 +13,7 @@ module Caterer
|
|
13
13
|
@host = opts[:host]
|
14
14
|
@port = opts[:port]
|
15
15
|
@images = opts[:images] || []
|
16
|
+
@data = opts[:data] || {}
|
16
17
|
end
|
17
18
|
|
18
19
|
def bootstrap(opts={})
|
@@ -96,6 +97,12 @@ module Caterer
|
|
96
97
|
@port || 22
|
97
98
|
end
|
98
99
|
|
100
|
+
def data
|
101
|
+
@data_hash ||= begin
|
102
|
+
(@data.is_a? Hash) ? @data : {}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
99
106
|
def run_action(name, options=nil)
|
100
107
|
options = {
|
101
108
|
:server => self,
|
data/lib/caterer/version.rb
CHANGED