corl 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Gemfile +5 -10
  2. data/Gemfile.lock +13 -11
  3. data/README.rdoc +1 -1
  4. data/Rakefile +3 -3
  5. data/VERSION +1 -1
  6. data/bin/corl +2 -54
  7. data/bootstrap/bootstrap.sh +91 -0
  8. data/bootstrap/lib/shell/LICENSE.txt +674 -0
  9. data/bootstrap/lib/shell/command.sh +214 -0
  10. data/bootstrap/lib/shell/filesystem.sh +139 -0
  11. data/bootstrap/lib/shell/load.sh +73 -0
  12. data/bootstrap/lib/shell/os.sh +67 -0
  13. data/bootstrap/lib/shell/script.sh +160 -0
  14. data/bootstrap/lib/shell/starter.sh +64 -0
  15. data/bootstrap/lib/shell/validators.sh +50 -0
  16. data/bootstrap/os/ubuntu/00_base.sh +5 -0
  17. data/bootstrap/os/ubuntu/01_git.sh +5 -0
  18. data/bootstrap/os/ubuntu/05_ruby.sh +7 -0
  19. data/bootstrap/os/ubuntu/06_puppet.sh +38 -0
  20. data/bootstrap/os/ubuntu/10_corl.sh +9 -0
  21. data/corl.gemspec +61 -124
  22. data/lib/{corl → CORL}/action/bootstrap.rb +13 -7
  23. data/lib/CORL/action/exec.rb +39 -0
  24. data/lib/CORL/action/image.rb +31 -0
  25. data/lib/{corl → CORL}/action/images.rb +1 -1
  26. data/lib/CORL/action/lookup.rb +34 -0
  27. data/lib/{corl → CORL}/action/machines.rb +1 -1
  28. data/lib/CORL/action/provision.rb +31 -0
  29. data/lib/{corl → CORL}/action/seed.rb +3 -3
  30. data/lib/{corl → CORL}/action/spawn.rb +2 -2
  31. data/lib/CORL/action/start.rb +31 -0
  32. data/lib/CORL/action/stop.rb +31 -0
  33. data/lib/{corl → CORL}/configuration/file.rb +1 -1
  34. data/lib/{corl → CORL}/event/puppet.rb +1 -1
  35. data/lib/{corl → CORL}/extension/puppetloader.rb +1 -1
  36. data/lib/{corl → CORL}/machine/fog.rb +3 -3
  37. data/lib/{corl → CORL}/machine/physical.rb +2 -2
  38. data/lib/{corl → CORL}/network/default.rb +1 -1
  39. data/lib/{corl → CORL}/node/aws.rb +0 -4
  40. data/lib/{corl → CORL}/node/google.rb +0 -4
  41. data/lib/{corl → CORL}/node/local.rb +1 -1
  42. data/lib/{corl → CORL}/node/rackspace.rb +0 -4
  43. data/lib/{corl → CORL}/provisioner/puppetnode.rb +1 -14
  44. data/lib/{corl → CORL}/provisioner/puppetnode/resource.rb +0 -0
  45. data/lib/{corl → CORL}/provisioner/puppetnode/resource_group.rb +0 -0
  46. data/lib/{corl → CORL}/template/environment.rb +1 -1
  47. data/lib/core/facade.rb +49 -0
  48. data/lib/{corl_core → core}/mixin/action/keypair.rb +10 -10
  49. data/lib/{corl_core → core}/mixin/lookup.rb +0 -0
  50. data/lib/{corl_core → core}/mod/hiera_backend.rb +0 -0
  51. data/lib/{corl_core/mixin/action/node.rb → core/plugin/action.rb} +66 -33
  52. data/lib/{corl_core → core}/plugin/configuration.rb +2 -2
  53. data/lib/{corl/node → core/plugin}/fog.rb +5 -1
  54. data/lib/{corl_core → core}/plugin/machine.rb +2 -2
  55. data/lib/{corl_core → core}/plugin/network.rb +4 -4
  56. data/lib/{corl_core → core}/plugin/node.rb +11 -9
  57. data/lib/{corl_core → core}/plugin/provisioner.rb +2 -2
  58. data/lib/{corl_core → core}/util/ssh.rb +1 -1
  59. data/lib/corl.rb +53 -112
  60. data/lib/puppet/parser/functions/ensure.rb +0 -4
  61. data/locales/en.yml +55 -148
  62. metadata +84 -222
  63. data/lib/corl/action/add.rb +0 -69
  64. data/lib/corl/action/clone.rb +0 -40
  65. data/lib/corl/action/create.rb +0 -55
  66. data/lib/corl/action/exec.rb +0 -41
  67. data/lib/corl/action/extract.rb +0 -49
  68. data/lib/corl/action/image.rb +0 -30
  69. data/lib/corl/action/lookup.rb +0 -35
  70. data/lib/corl/action/provision.rb +0 -37
  71. data/lib/corl/action/remove.rb +0 -51
  72. data/lib/corl/action/save.rb +0 -53
  73. data/lib/corl/action/start.rb +0 -37
  74. data/lib/corl/action/stop.rb +0 -30
  75. data/lib/corl/action/update.rb +0 -37
  76. data/lib/corl/command/shell.rb +0 -164
  77. data/lib/corl/event/regex.rb +0 -52
  78. data/lib/corl/project/git.rb +0 -465
  79. data/lib/corl/project/github.rb +0 -108
  80. data/lib/corl/template/json.rb +0 -16
  81. data/lib/corl/template/wrapper.rb +0 -16
  82. data/lib/corl/template/yaml.rb +0 -16
  83. data/lib/corl/translator/json.rb +0 -27
  84. data/lib/corl/translator/yaml.rb +0 -27
  85. data/lib/corl_core/codes.rb +0 -107
  86. data/lib/corl_core/config.rb +0 -337
  87. data/lib/corl_core/config/collection.rb +0 -57
  88. data/lib/corl_core/config/options.rb +0 -70
  89. data/lib/corl_core/core.rb +0 -59
  90. data/lib/corl_core/corl.rb +0 -254
  91. data/lib/corl_core/errors.rb +0 -84
  92. data/lib/corl_core/facade.rb +0 -126
  93. data/lib/corl_core/gems.rb +0 -72
  94. data/lib/corl_core/manager.rb +0 -425
  95. data/lib/corl_core/mixin/action/commit.rb +0 -58
  96. data/lib/corl_core/mixin/action/project.rb +0 -53
  97. data/lib/corl_core/mixin/action/push.rb +0 -52
  98. data/lib/corl_core/mixin/config/collection.rb +0 -53
  99. data/lib/corl_core/mixin/config/ops.rb +0 -53
  100. data/lib/corl_core/mixin/config/options.rb +0 -39
  101. data/lib/corl_core/mixin/macro/object_interface.rb +0 -361
  102. data/lib/corl_core/mixin/macro/plugin_interface.rb +0 -380
  103. data/lib/corl_core/mixin/settings.rb +0 -46
  104. data/lib/corl_core/mixin/sub_config.rb +0 -148
  105. data/lib/corl_core/mod/hash.rb +0 -29
  106. data/lib/corl_core/plugin/action.rb +0 -381
  107. data/lib/corl_core/plugin/base.rb +0 -374
  108. data/lib/corl_core/plugin/command.rb +0 -98
  109. data/lib/corl_core/plugin/event.rb +0 -53
  110. data/lib/corl_core/plugin/extension.rb +0 -12
  111. data/lib/corl_core/plugin/project.rb +0 -927
  112. data/lib/corl_core/plugin/template.rb +0 -80
  113. data/lib/corl_core/plugin/translator.rb +0 -38
  114. data/lib/corl_core/util/cli.rb +0 -352
  115. data/lib/corl_core/util/data.rb +0 -404
  116. data/lib/corl_core/util/disk.rb +0 -114
  117. data/lib/corl_core/util/git.rb +0 -47
  118. data/lib/corl_core/util/interface.rb +0 -319
  119. data/lib/corl_core/util/liquid.rb +0 -17
  120. data/lib/corl_core/util/package.rb +0 -93
  121. data/lib/corl_core/util/shell.rb +0 -239
  122. data/spec/corl_core/interface_spec.rb +0 -489
@@ -1,80 +0,0 @@
1
-
2
- module CORL
3
- module Plugin
4
- class Template < Base
5
-
6
- #-----------------------------------------------------------------------------
7
- # Template plugin interface
8
-
9
-
10
- #-----------------------------------------------------------------------------
11
- # Property accessor / modifiers
12
-
13
- #-----------------------------------------------------------------------------
14
- # Operations
15
-
16
- def process(value)
17
- case value
18
- when String, Symbol
19
- return nil if Util::Data.undef?(value)
20
- return 'false' if value == false
21
- return 'true' if value == true
22
- return value.to_s if value.is_a?(Symbol)
23
-
24
- when Hash
25
- results = {}
26
- value.each do |key, item|
27
- result = process(item)
28
- unless result.nil?
29
- results[key] = result
30
- end
31
- value = results
32
- end
33
-
34
- when Array
35
- results = []
36
- value.each_with_index do |item, index|
37
- result = process(item)
38
- unless result.nil?
39
- results << result
40
- end
41
- end
42
- value = results
43
- end
44
- return value
45
- end
46
-
47
- #---
48
-
49
- def render(data)
50
- normalize = get(:normalize_template, true)
51
- interpolate = get(:interpolate_template, true)
52
-
53
- logger.debug("Rendering data: normalize: #{normalize.inspect}; interpolate: #{interpolate.inspect}: #{data.inspect}")
54
-
55
- if normalize
56
- data = Config.normalize(data, nil, config)
57
- logger.debug("Pre-rendering data normalization: #{data.inspect}")
58
- end
59
-
60
- if normalize && interpolate
61
- data = Util::Data.interpolate(data, data, export)
62
- logger.debug("Pre-rendering data interpolation: #{data.inspect}")
63
- end
64
- return render_processed(process(data))
65
- end
66
-
67
- #---
68
-
69
- def render_processed(data)
70
- logger.debug("Rendering #{plugin_provider} data: #{data.inspect}")
71
-
72
- output = ''
73
- output = yield(output) if block_given?
74
-
75
- logger.debug("Completed rendering of #{plugin_provider} data: #{output}")
76
- return output
77
- end
78
- end
79
- end
80
- end
@@ -1,38 +0,0 @@
1
-
2
- module CORL
3
- module Plugin
4
- class Translator < Base
5
-
6
- #-----------------------------------------------------------------------------
7
- # Translator plugin interface
8
-
9
- #-----------------------------------------------------------------------------
10
- # Property accessor / modifiers
11
-
12
- #-----------------------------------------------------------------------------
13
- # Operations
14
-
15
- def parse(raw)
16
- logger.debug("Parsing raw data: #{raw}")
17
-
18
- properties = {}
19
- properties = yield(properties) if block_given?
20
-
21
- logger.debug("Completed parsing data: #{properties.inspect}")
22
- return properties
23
- end
24
-
25
- #---
26
-
27
- def generate(properties)
28
- logger.debug("Generating output data: #{properties.inspect}")
29
-
30
- output = ''
31
- output = yield(output) if block_given?
32
-
33
- logger.debug("Completed generating data: #{output}")
34
- return output
35
- end
36
- end
37
- end
38
- end
@@ -1,352 +0,0 @@
1
- module CORL
2
- module Util
3
- module CLI
4
-
5
- #-------------------------------------------------------------------------
6
- # Utilities
7
-
8
- def self.message(name, default = nil)
9
- if default.nil?
10
- default = :none
11
- end
12
- return I18n.t(name.to_s, :default_value => default.to_s)
13
- end
14
-
15
- #---
16
-
17
- def self.encode(data)
18
- Base64.encode64(Util::Data.to_json(data, false))
19
- end
20
-
21
- def self.decode(encoded_string)
22
- Util::Data.symbol_map(Util::Data.parse_json(Base64.decode64(encoded_string)))
23
- end
24
-
25
- #-------------------------------------------------------------------------
26
- # Parser
27
-
28
- class Parser
29
-
30
- attr_accessor :parser
31
- attr_accessor :options
32
- attr_accessor :arguments
33
- attr_accessor :processed
34
-
35
- #---
36
-
37
- def initialize(args, banner = '', help = '')
38
-
39
- @parser = OptionParser.new
40
-
41
- self.options = {}
42
- self.arguments = {}
43
- self.processed = false
44
-
45
- @arg_settings = []
46
-
47
- self.banner = banner
48
- self.help = help
49
-
50
- yield(self) if block_given?
51
-
52
- parse_command(args)
53
- end
54
-
55
- #---
56
-
57
- def self.split(args, banner, separator = '')
58
- main_args = nil
59
- sub_command = nil
60
- sub_args = []
61
-
62
- args.each_index do |index|
63
- if !args[index].start_with?('-')
64
- main_args = args[0, index]
65
- sub_command = args[index]
66
- sub_args = args[index + 1, args.length - index + 1]
67
- break
68
- end
69
- end
70
-
71
- main_args = args.dup if main_args.nil?
72
- results = [ Parser.new(main_args, banner, separator) ]
73
-
74
- if sub_command
75
- results << [ sub_command, sub_args ]
76
- end
77
-
78
- return results.flatten
79
- end
80
-
81
- #---
82
-
83
- def banner=banner
84
- parser.banner = banner
85
- end
86
-
87
- #---
88
-
89
- def help
90
- return parser.help
91
- end
92
-
93
- def help=help
94
- if help.is_a?(Array)
95
- help.each do |line|
96
- parser.separator line
97
- end
98
- else
99
- parser.separator help
100
- end
101
- end
102
-
103
- #---
104
-
105
- def parse_command(args)
106
- args = args.dup
107
- error = false
108
-
109
- self.processed = false
110
-
111
- option_str(:log_level, nil,
112
- '--log_level STR',
113
- 'corl.core.util.cli.options.log_level'
114
- )
115
- option_str(:encoded_params, false,
116
- '--encoded STR',
117
- 'corl.core.util.cli.options.encoded'
118
- )
119
- parser.on_tail('-h', '--help', CLI.message('corl.core.util.cli.options.help')) do
120
- options[:help] = true
121
- return
122
- end
123
-
124
- parser.parse!(args)
125
-
126
- CORL.log_level = options[:log_level] if options[:log_level]
127
- parse_encoded
128
-
129
- remaining_args = args.dup
130
- arg_messages = []
131
-
132
- if arguments.empty?
133
- @arg_settings.each_with_index do |settings, index|
134
- if index >= args.length
135
- value = nil
136
- else
137
- value = Util::Data.value(args[index])
138
- end
139
-
140
- if !value.nil? && settings.has_key?(:allowed)
141
- allowed = settings[:allowed]
142
- case allowed
143
- when Class
144
- if (allowed == Array)
145
- value = remaining_args
146
- remaining_args = []
147
- end
148
- unless value.is_a?(allowed)
149
- arg_messages << CLI.message(settings[:message])
150
- error = true
151
- end
152
- when Array
153
- unless allowed.include(value)
154
- arg_messages << CLI.message(settings[:message])
155
- error = true
156
- end
157
- end
158
- end
159
-
160
- if value.nil?
161
- if settings.has_key?(:default)
162
- value = settings[:default]
163
- else
164
- error = true
165
- end
166
- end
167
-
168
- if !value.nil? && settings.has_key?(:block)
169
- value = settings[:block].call(value)
170
- error = true if value.nil?
171
- end
172
-
173
- break if error
174
-
175
- remaining_args.shift unless remaining_args.empty?
176
- self.arguments[settings[:name]] = value
177
- end
178
- end
179
-
180
- if error
181
- if ! arg_messages.empty?
182
- parser.warn(CLI.message('corl.core.util.cli.parse.error') + "\n\n" + arg_messages.join("\n") + "\n\n" + parser.help)
183
- else
184
- parser.warn(CLI.message('corl.core.util.cli.parse.error') + "\n\n" + parser.help)
185
- end
186
- else
187
- self.processed = true
188
- end
189
-
190
- rescue OptionParser::InvalidOption => e
191
- parser.warn(e.message + "\n\n" + parser.help)
192
- end
193
-
194
- #---
195
-
196
- def parse_encoded
197
- if options[:encoded_params]
198
- encoded_properties = CLI.decode(options[:encoded_params])
199
-
200
- @arg_settings.each do |settings|
201
- if encoded_properties.has_key?(settings[:name].to_sym)
202
- self.arguments[settings[:name]] = encoded_properties.delete(settings[:name].to_sym)
203
- end
204
- end
205
-
206
- encoded_properties.each do |name, value|
207
- self.options[name] = value unless options.has_key?(name)
208
- end
209
- end
210
- options.delete(:encoded_params)
211
- end
212
-
213
- #---
214
-
215
- def option(name, default, option_str, allowed_values, message_id, config = {})
216
- config = Config.ensure(config)
217
- name = name.to_sym
218
- options[name] = config.get(name, default)
219
-
220
- message_name = name.to_s + '_message'
221
- message = CLI.message(message_id, options[name])
222
-
223
- option_str = Util::Data.array(option_str)
224
-
225
- if allowed_values
226
- parser.on(*option_str, allowed_values, config.get(message_name.to_sym, message)) do |value|
227
- value = yield(value) if block_given?
228
- options[name] = value unless value.nil?
229
- end
230
- else
231
- parser.on(*option_str, config.get(message_name.to_sym, message)) do |value|
232
- value = yield(value) if block_given?
233
- options[name] = value unless value.nil?
234
- end
235
- end
236
- end
237
-
238
- #---
239
-
240
- def arg(name, default, allowed_values, message_id, config = {}, &block)
241
- config = Config.ensure(config)
242
- name = name.to_sym
243
-
244
- message_name = name.to_s + '_message'
245
- message = CLI.message(message_id, arguments[name])
246
-
247
- settings = {
248
- :name => name,
249
- :default => config.get(name, default),
250
- :message => config.get(message_name.to_sym, message)
251
- }
252
- settings[:allowed] = allowed_values if allowed_values
253
- settings[:block] = block if block
254
-
255
- settings.delete(:default) if settings[:default].nil?
256
-
257
- @arg_settings << settings
258
- end
259
-
260
- #---
261
-
262
- def option_bool(name, default, option_str, message_id, config = {})
263
- option(name, default, option_str, nil, message_id, config) do |value|
264
- value = Util::Data.value(value)
265
- if value == true || value == false
266
- block_given? ? yield(value) : value
267
- else
268
- nil
269
- end
270
- end
271
- end
272
-
273
- #---
274
-
275
- def arg_bool(name, default, message_id, config = {})
276
- arg(name, default, nil, message_id, config) do |value|
277
- value = Util::Data.value(value)
278
- if value == true || value == false
279
- block_given? ? yield(value) : value
280
- else
281
- nil
282
- end
283
- end
284
- end
285
-
286
- #---
287
-
288
- def option_int(name, default, option_str, message_id, config = {})
289
- option(name, default, option_str, Integer, message_id, config) do |value|
290
- block_given? ? yield(value) : value
291
- end
292
- end
293
-
294
- #---
295
-
296
- def arg_int(name, default, message_id, config = {})
297
- arg(name, default, Integer, message_id, config) do |value|
298
- block_given? ? yield(value) : value
299
- end
300
- end
301
-
302
- #---
303
-
304
- def option_float(name, default, option_str, message_id, config = {})
305
- option(name, default, option_str, Float, message_id, config) do |value|
306
- block_given? ? yield(value) : value
307
- end
308
- end
309
-
310
- #---
311
-
312
- def arg_float(name, default, message_id, config = {})
313
- arg(name, default, Float, message_id, config) do |value|
314
- block_given? ? yield(value) : value
315
- end
316
- end
317
-
318
- #---
319
-
320
- def option_str(name, default, option_str, message_id, config = {})
321
- option(name, default, option_str, nil, message_id, config) do |value|
322
- block_given? ? yield(value) : value
323
- end
324
- end
325
-
326
- #---
327
-
328
- def arg_str(name, default, message_id, config = {})
329
- arg(name, default, nil, message_id, config) do |value|
330
- block_given? ? yield(value) : value
331
- end
332
- end
333
-
334
- #---
335
-
336
- def option_array(name, default, option_str, message_id, config = {})
337
- option(name, default, option_str, Array, message_id, config) do |value|
338
- block_given? ? yield(value) : value
339
- end
340
- end
341
-
342
- #---
343
-
344
- def arg_array(name, default, message_id, config = {})
345
- arg(name, default, Array, message_id, config) do |value|
346
- block_given? ? yield(value) : value
347
- end
348
- end
349
- end
350
- end
351
- end
352
- end