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,57 +0,0 @@
1
-
2
- module CORL
3
- class Config
4
- class Collection
5
-
6
- #-----------------------------------------------------------------------------
7
- # Property accessor / modifiers
8
-
9
- @@properties = {}
10
-
11
- #---
12
-
13
- def self.all
14
- return @@properties
15
- end
16
-
17
- #---
18
-
19
- def self.get(name)
20
- return @@properties[name.to_sym]
21
- end
22
-
23
- #---
24
-
25
- def self.set(name, value)
26
- @@properties[name.to_sym] = value
27
- end
28
-
29
- #---
30
-
31
- def self.delete(name)
32
- @@properties.delete(name.to_sym)
33
- end
34
-
35
- #---
36
-
37
- def self.clear
38
- @@properties = {}
39
- end
40
-
41
- #---
42
-
43
- def self.save
44
- log_options = Options.get(:corl_log)
45
-
46
- unless Util::Data.empty?(log_options[:config_log])
47
- config_log = log_options[:config_log]
48
-
49
- if log_options[:config_store]
50
- Util::Disk.write(config_log, MultiJson.dump(@@properties, :pretty => true))
51
- Util::Disk.close(config_log)
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,70 +0,0 @@
1
-
2
- module CORL
3
- class Config
4
- class Options
5
-
6
- #-----------------------------------------------------------------------------
7
- # Property accessors / modifiers
8
-
9
- @@options = {}
10
-
11
- #---
12
-
13
- def self.contexts(contexts = [], hierarchy = [])
14
- contexts = [ 'all', contexts ].flatten
15
-
16
- unless hierarchy.is_a?(Array)
17
- hierarchy = ( ! Util::Data.empty?(hierarchy) ? [ hierarchy ].flatten : [] )
18
- end
19
-
20
- hierarchy.each do |group|
21
- group_contexts = Util::Data.prefix(group, contexts)
22
- contexts = [ contexts, group_contexts ].flatten
23
- end
24
-
25
- return contexts
26
- end
27
-
28
- #---
29
-
30
- def self.get(contexts, force = true)
31
- options = {}
32
-
33
- unless contexts.is_a?(Array)
34
- contexts = ( ! Util::Data.empty?(contexts) ? [ contexts ].flatten : [] )
35
- end
36
- contexts.each do |name|
37
- name = name.to_sym
38
- if @@options.has_key?(name)
39
- options = Util::Data.merge([ options, @@options[name] ], force)
40
- end
41
- end
42
- return options
43
- end
44
-
45
- #---
46
-
47
- def self.set(contexts, options, force = true)
48
- unless contexts.is_a?(Array)
49
- contexts = ( ! Util::Data.empty?(contexts) ? [ contexts ].flatten : [] )
50
- end
51
- contexts.each do |name|
52
- name = name.to_sym
53
- current_options = ( @@options.has_key?(name) ? @@options[name] : {} )
54
- @@options[name] = Util::Data.merge([ current_options, Config.symbol_map(options) ], force)
55
- end
56
- end
57
-
58
- #---
59
-
60
- def self.clear(contexts)
61
- unless contexts.is_a?(Array)
62
- contexts = [ contexts ]
63
- end
64
- contexts.each do |name|
65
- @@options.delete(name.to_sym)
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,59 +0,0 @@
1
-
2
- module CORL
3
- class Core < Config
4
-
5
- #-----------------------------------------------------------------------------
6
- # Properties
7
-
8
- @@ui = Util::Interface.new("core")
9
-
10
- #-----------------------------------------------------------------------------
11
- # Constructor / Destructor
12
-
13
- def initialize(data = {}, defaults = {}, force = true)
14
- super(data, defaults, force)
15
-
16
- class_label = self.class.to_s.downcase.gsub(/^corl::/, '')
17
- logger_name = delete(:logger, class_label)
18
- interface_config = Config.new(export).defaults({ :logger => logger_name, :resource => class_label })
19
-
20
- @ui = Util::Interface.new(interface_config)
21
- logger.debug("Initialized instance interface")
22
- end
23
-
24
- #-----------------------------------------------------------------------------
25
- # Accessor / Modifiers
26
-
27
- attr_accessor :ui
28
-
29
- #---
30
-
31
- def self.ui
32
- return @@ui
33
- end
34
-
35
- #---
36
-
37
- def self.logger
38
- return @@ui.logger
39
- end
40
-
41
- #---
42
-
43
- def logger
44
- return @ui.logger
45
- end
46
-
47
- #-----------------------------------------------------------------------------
48
- # General utilities
49
-
50
- def ui_group(resource)
51
- ui_resource = ui.resource
52
- ui.resource = resource
53
- yield
54
-
55
- ensure
56
- ui.resource = ui_resource
57
- end
58
- end
59
- end
@@ -1,254 +0,0 @@
1
-
2
- module CORL
3
-
4
- VERSION = File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION'))
5
-
6
- #-----------------------------------------------------------------------------
7
-
8
- def self.ui
9
- Core.ui
10
- end
11
-
12
- #---
13
-
14
- def self.logger
15
- Core.logger
16
- end
17
-
18
- #---
19
-
20
- def self.add_log_levels(*levels)
21
- Util::Interface.add_log_levels(levels)
22
- end
23
-
24
- def self.log_level
25
- Util::Interface.log_level
26
- end
27
-
28
- def self.log_level=log_level
29
- Util::Interface.log_level = log_level
30
- end
31
-
32
- #-----------------------------------------------------------------------------
33
-
34
- def self.admin?
35
- is_admin = ( ENV['USER'] == 'root' )
36
- ext_admin = exec(:check_admin) do |op, results|
37
- if op == :reduce
38
- results.values.include?(true)
39
- else
40
- results ? true : false
41
- end
42
- end
43
- is_admin || ext_admin ? true : false
44
- end
45
-
46
- #-----------------------------------------------------------------------------
47
- # Status codes
48
-
49
- @@codes = Codes.new
50
-
51
- def self.code
52
- @@codes
53
- end
54
-
55
- def self.codes(*codes)
56
- Codes.codes(*codes)
57
- end
58
-
59
- #-----------------------------------------------------------------------------
60
- # Initialization
61
-
62
- def self.initialize
63
- current_time = Time.now
64
-
65
- Celluloid.logger = logger
66
-
67
- logger.info("Initializing the CORL plugin system at #{current_time}")
68
- Config.set_property('time', current_time.to_i)
69
-
70
- connection = Manager.connection
71
-
72
- connection.define_type :extension => nil, # Core
73
- :configuration => :file, # Core
74
- :action => :update, # Core
75
- :project => :git, # Core
76
- :network => :default, # Cluster
77
- :node => :local, # Cluster
78
- :machine => :physical, # Cluster
79
- :provisioner => :puppetnode, # Cluster
80
- :command => :shell, # Cluster
81
- :event => :regex, # Utility
82
- :template => :json, # Utility
83
- :translator => :json # Utility
84
-
85
- connection.load_plugins(true)
86
-
87
- logger.info("Finished initializing CORL plugin system at #{Time.now}")
88
- end
89
-
90
- #-----------------------------------------------------------------------------
91
- # Core plugin interface
92
-
93
- def self.plugin_load(type, provider, options = {})
94
- config = Config.ensure(options)
95
- name = config.get(:name, nil)
96
-
97
- logger.info("Fetching plugin #{type} provider #{provider} at #{Time.now}")
98
- logger.debug("Plugin options: #{config.export.inspect}")
99
-
100
- connection = Manager.connection
101
-
102
- if name
103
- logger.debug("Looking up existing instance of #{name}")
104
-
105
- existing_instance = connection.get(type, name)
106
- logger.info("Using existing instance of #{type}, #{name}") if existing_instance
107
- end
108
-
109
- return existing_instance if existing_instance
110
- connection.create(type, provider, config.export)
111
- end
112
-
113
- #---
114
-
115
- def self.plugin(type, provider, options = {})
116
- default_provider = Manager.connection.type_default(type)
117
-
118
- if options.is_a?(Hash) || options.is_a?(CORL::Config)
119
- config = Config.ensure(options)
120
- provider = config.get(:provider, provider)
121
- options = config.export
122
- end
123
- provider = default_provider unless provider # Sanity checking (see plugins)
124
-
125
- plugin_load(type, provider, options)
126
- end
127
-
128
- #---
129
-
130
- def self.plugins(type, data, build_hash = false, keep_array = false)
131
- logger.info("Fetching multiple plugins of #{type} at #{Time.now}")
132
-
133
- group = ( build_hash ? {} : [] )
134
- klass = class_const([ 'CORL', :plugin, type ])
135
- data = klass.build_info(type, data) if klass.respond_to?(:build_info)
136
-
137
- logger.debug("Translated plugin data: #{data.inspect}")
138
-
139
- data.each do |options|
140
- if plugin = plugin(type, options[:provider], options)
141
- if build_hash
142
- group[plugin.plugin_name] = plugin
143
- else
144
- group << plugin
145
- end
146
- end
147
- end
148
- return group.shift if ! build_hash && group.length == 1 && ! keep_array
149
- group
150
- end
151
-
152
- #---
153
-
154
- def self.get_plugin(type, name)
155
- Manager.connection.get(type, name)
156
- end
157
-
158
- #---
159
-
160
- def self.remove_plugin(plugin)
161
- Manager.connection.remove(plugin)
162
- end
163
-
164
- #-----------------------------------------------------------------------------
165
- # Plugin extensions
166
-
167
- def self.exec(method, options = {})
168
- Manager.connection.exec(method, options) do |op, data|
169
- data = yield(op, data) if block_given?
170
- data
171
- end
172
- end
173
-
174
- #---
175
-
176
- def self.config(type, options = {})
177
- Manager.connection.config(method, options)
178
- end
179
-
180
- #---
181
-
182
- def self.check(method, options = {})
183
- Manager.connection.check(method, options)
184
- end
185
-
186
- #---
187
-
188
- def self.value(method, value, options = {})
189
- Manager.connection.value(method, value, options)
190
- end
191
-
192
- #-----------------------------------------------------------------------------
193
- # External execution
194
-
195
- def self.run
196
- begin
197
- logger.debug("Running contained process at #{Time.now}")
198
- yield
199
-
200
- rescue Exception => error
201
- logger.error("CORL run experienced an error! Details:")
202
- logger.error(error.inspect)
203
- logger.error(error.message)
204
- logger.error(Util::Data.to_yaml(error.backtrace))
205
-
206
- ui.error(error.message) if error.message
207
- raise
208
- end
209
- end
210
-
211
- #-----------------------------------------------------------------------------
212
- # Utilities
213
-
214
- def self.class_name(name, separator = '::', want_array = FALSE)
215
- components = []
216
-
217
- case name
218
- when String, Symbol
219
- components = name.to_s.split(separator)
220
- when Array
221
- components = name
222
- end
223
-
224
- components.collect! do |value|
225
- next value if value.to_s == 'CORL'
226
- value.to_s.strip.capitalize
227
- end
228
-
229
- if want_array
230
- return components
231
- end
232
- components.join(separator)
233
- end
234
-
235
- #---
236
-
237
- def self.class_const(name, separator = '::')
238
- components = class_name(name, separator, TRUE)
239
- constant = Object
240
-
241
- components.each do |component|
242
- constant = constant.const_defined?(component) ?
243
- constant.const_get(component) :
244
- constant.const_missing(component)
245
- end
246
- constant
247
- end
248
-
249
- #---
250
-
251
- def self.sha1(data)
252
- Digest::SHA1.hexdigest(Util::Data.to_json(data, false))
253
- end
254
- end
@@ -1,84 +0,0 @@
1
-
2
- module CORL
3
- module Errors
4
-
5
- #-----------------------------------------------------------------------------
6
- # Base error (based on VagrantError)
7
-
8
- class CORLError < StandardError
9
-
10
- #---------------------------------------------------------------------------
11
- # Error constructor / destructor
12
-
13
- def initialize(*args)
14
- key = args.shift if args.first.is_a?(Symbol)
15
- message = args.shift if args.first.is_a?(Hash)
16
- message ||= {}
17
-
18
- @extra_data = message.dup
19
-
20
- message[:key] ||= error_key
21
- message[:namespace] ||= error_namespace
22
- message[:key] = key if key
23
-
24
- if message[:key]
25
- message = translate_error(message)
26
- else
27
- message = error_message
28
- end
29
-
30
- super(message)
31
- end
32
-
33
- #---------------------------------------------------------------------------
34
- # Property accessor / modifiers
35
-
36
- attr_accessor :extra_data
37
-
38
- #---
39
-
40
- def self.error_key(key = nil, namespace = nil)
41
- define_method(:error_key) { key }
42
- error_namespace(namespace) if namespace
43
- end
44
- def error_key; nil; end # Default
45
-
46
- #---
47
-
48
- def self.error_message(message)
49
- define_method(:error_message) { message }
50
- end
51
- def error_message; "No error message"; end # Default
52
-
53
- #---
54
-
55
- def self.error_namespace(namespace)
56
- define_method(:error_namespace) { namespace }
57
- end
58
- def error_namespace; "corl.errors"; end # Default
59
-
60
- #---
61
-
62
- def self.status_code(code)
63
- define_method(:status_code) { code }
64
- end
65
- def status_code; 1; end # Default
66
-
67
- #---------------------------------------------------------------------------
68
- # Utilities
69
-
70
- def translate_error(options)
71
- return nil unless options[:key]
72
- I18n.t("#{options[:namespace]}.#{options[:key]}", options)
73
- end
74
- protected :translate_error
75
- end
76
-
77
- #-----------------------------------------------------------------------------
78
- # Specialized errors
79
-
80
- class BatchError < CORLError
81
- error_key(:batch_error)
82
- end
83
- end
84
- end