corl 0.5.11 → 0.5.12

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: aa06730953a8ed3414ef34103d332b911eccf829
4
- data.tar.gz: f02ae226797584ca6bde2dd4b84c8e193148d373
3
+ metadata.gz: 5c9b999aa83da59dc7085e95caa8c0caea559168
4
+ data.tar.gz: b7f983b479ec01f6d44293b7747f43bce35e0e96
5
5
  SHA512:
6
- metadata.gz: 1d6425fa3f20d527ed3e7850782ae557eadb1f1756a7e7bea5bfc7235335875f77d98a133ae4fd1e095177c2628173a47d8e7b2b1ecd5269011a1fa26631e0fc
7
- data.tar.gz: 0e3ad718e7e4cf9700be6251b7d1dd3a65c26ec6778d0562ddaefe9337af52349618d9a94a83ec348cf9aa097b1820f8a9738acb2cba856cf4d7f1322a21ae5c
6
+ metadata.gz: 8ec5afdc6c44f8f23b7ccc97b576d098bc861f7dd7aaa0109451f4f4e28a4132b0b30586e94cf4134c39d216ab8ddd918393b0c9c54875918085fa959344a7d1
7
+ data.tar.gz: 1b04ac6e177445e9005cac13856f6eb83884099f3de09f9dba9b81ddfd6907a66a1c7dceb45939bb1c21aa7001c0a310a4195c1a68d84d353bb9779a782934f5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.11
1
+ 0.5.12
data/corl.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: corl 0.5.11 ruby lib
5
+ # stub: corl 0.5.12 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "corl"
9
- s.version = "0.5.11"
9
+ s.version = "0.5.12"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Adrian Webb"]
14
- s.date = "2015-01-18"
14
+ s.date = "2015-01-19"
15
15
  s.description = "Framework that provides a simple foundation for growing organically in the cloud"
16
16
  s.email = "adrian.webb@coralnexus.com"
17
17
  s.executables = ["corl"]
@@ -106,15 +106,15 @@ Gem::Specification.new do |s|
106
106
  "lib/facter/custom_facts.rb",
107
107
  "lib/facter/vagrant_exists.rb",
108
108
  "lib/hiera/corl_logger.rb",
109
- "lib/nucleon/action/cloud/config.rb",
110
- "lib/nucleon/action/cloud/create.rb",
111
- "lib/nucleon/action/cloud/images.rb",
112
- "lib/nucleon/action/cloud/inspect.rb",
113
- "lib/nucleon/action/cloud/machines.rb",
114
- "lib/nucleon/action/cloud/regions.rb",
115
- "lib/nucleon/action/cloud/remote.rb",
116
- "lib/nucleon/action/cloud/settings.rb",
117
- "lib/nucleon/action/cloud/vagrantfile.rb",
109
+ "lib/nucleon/action/network/config.rb",
110
+ "lib/nucleon/action/network/create.rb",
111
+ "lib/nucleon/action/network/images.rb",
112
+ "lib/nucleon/action/network/inspect.rb",
113
+ "lib/nucleon/action/network/machines.rb",
114
+ "lib/nucleon/action/network/regions.rb",
115
+ "lib/nucleon/action/network/remote.rb",
116
+ "lib/nucleon/action/network/settings.rb",
117
+ "lib/nucleon/action/network/vagrantfile.rb",
118
118
  "lib/nucleon/action/node/IP.rb",
119
119
  "lib/nucleon/action/node/SSH.rb",
120
120
  "lib/nucleon/action/node/authorize.rb",
@@ -43,12 +43,13 @@ class Identity < Nucleon.plugin_class(:CORL, :builder)
43
43
 
44
44
  unless identities.has_key?(provider_id)
45
45
  project = build_config.manage(:project, extended_config(:identity, {
46
- :directory => full_directory,
47
- :url => project_reference,
48
- :create => File.directory?(full_directory) ? false : true,
49
- :pull => true,
50
- :internal_ip => CORL.public_ip, # Needed for seeding Vagrant VMs
51
- :manage_ignore => false
46
+ :directory => full_directory,
47
+ :url => project_reference,
48
+ :create => File.directory?(full_directory) ? false : true,
49
+ :pull => true,
50
+ :internal_ip => CORL.public_ip, # Needed for seeding Vagrant VMs
51
+ :manage_ignore => false,
52
+ :nucleon_resave => true
52
53
  }))
53
54
  unless project
54
55
  warn("Identity #{cyan(name)} failed to initialize", { :i18n => false })
@@ -20,7 +20,7 @@ class Project < Nucleon.plugin_class(:CORL, :builder)
20
20
  :pull => true,
21
21
  :internal_ip => CORL.public_ip, # Needed for seeding Vagrant VMs
22
22
  :manage_ignore => false,
23
- :corl_file => false
23
+ :nucleon_file => false
24
24
  }))
25
25
  unless project
26
26
  warn("Project #{cyan(path)} failed to initialize", { :i18n => false })
@@ -44,7 +44,23 @@ module SSH
44
44
  end
45
45
 
46
46
  rescue => error
47
- warn(error, { :i18n => false })
47
+ if error.is_a?(Net::SSH::AuthenticationFailed) && ssh_config[:keypair]
48
+ key_file_base = File.join(ssh_config[:key_dir], "#{ssh_config[:key_name]}_#{ssh_config[:keypair].type}")
49
+
50
+ Util::Disk.delete(key_file_base)
51
+ Util::Disk.delete("#{key_file_base}.pub")
52
+
53
+ node.keypair = nil
54
+ ssh_config[:keypair] = nil
55
+ ssh_config[:reset_conn] = true
56
+ retry
57
+ else
58
+ message = error.message
59
+ if message.include?("Neither PUB key nor PRIV key")
60
+ message = "Authentication failed for #{user}@#{public_ip} on port #{ssh_port} (most likely wrong password entered)"
61
+ end
62
+ warn(message, { :i18n => false })
63
+ end
48
64
  success = false
49
65
  end
50
66
  success
@@ -158,7 +158,7 @@ class CloudAction < Nucleon.plugin_class(:nucleon, :action)
158
158
  network_path = ( path.nil? ? Dir.pwd : File.expand_path(path) )
159
159
  end
160
160
 
161
- if File.exists?(File.join(network_path, '.corl'))
161
+ if File.exists?(File.join(network_path, '.nucleon'))
162
162
  # Load network if it exists
163
163
  network_config = extended_config(:network, { :directory => network_path, :new => true })
164
164
  @network = CORL.network(network_path, network_config, provider)
@@ -481,11 +481,12 @@ class Node < Nucleon.plugin_class(:nucleon, :base)
481
481
 
482
482
  def lookup(property, default = nil, options = {})
483
483
  unless local?
484
- config = Config.ensure(options).import({ :property => property, :quiet => true })
484
+ config = Config.ensure(options).import({ :properties => [ property ], :quiet => true })
485
485
  result = run.node_lookup(config)
486
486
 
487
487
  if result.status == code.success
488
- return Util::Data.value(Util::Data.parse_json(result.errors), default)
488
+ result_data = Util::Data.parse_json(result.errors)
489
+ return Util::Data.value(result_data[property.to_s], default)
489
490
  end
490
491
  return default
491
492
  end
@@ -1,66 +1,66 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- module Cloud
4
+ module Network
5
5
  class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
6
-
6
+
7
7
  #-----------------------------------------------------------------------------
8
8
  # Info
9
-
9
+
10
10
  def self.describe
11
- super(:cloud, :config, 949)
11
+ super(:network, :config, 949)
12
12
  end
13
-
13
+
14
14
  #-----------------------------------------------------------------------------
15
15
  # Settings
16
-
16
+
17
17
  def configure
18
18
  super do
19
19
  codes :configuration_parse_failed,
20
20
  :configuration_save_failed,
21
21
  :configuration_delete_failed
22
-
22
+
23
23
  register_str :name
24
24
  register_array :value
25
-
26
- register_bool :array
25
+
26
+ register_bool :array
27
27
  register_bool :delete
28
28
  register_bool :append
29
-
29
+
30
30
  register_translator :input_format
31
31
  register_translator :save_format
32
32
  register_translator :format, :json
33
33
  end
34
34
  end
35
-
35
+
36
36
  #---
37
-
37
+
38
38
  def ignore
39
39
  node_ignore
40
40
  end
41
-
41
+
42
42
  def arguments
43
43
  [ :name, :value ]
44
44
  end
45
-
45
+
46
46
  #-----------------------------------------------------------------------------
47
47
  # Operations
48
-
48
+
49
49
  def execute
50
50
  super do |node|
51
51
  ensure_network do
52
52
  config_info = parse_config_reference(node, settings[:name])
53
-
53
+
54
54
  unless config_info
55
55
  myself.status = code.configuration_parse_failed
56
56
  end
57
-
57
+
58
58
  if settings.delete(:delete, false)
59
59
  delete_config_property(config_info)
60
-
60
+
61
61
  elsif config_info[:property].nil?
62
62
  render_config_properties(config_info)
63
-
63
+
64
64
  elsif ! settings[:value].empty?
65
65
  set_config_property(config_info, settings[:value])
66
66
  else
@@ -69,10 +69,10 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
69
69
  end
70
70
  end
71
71
  end
72
-
72
+
73
73
  #-----------------------------------------------------------------------------
74
74
  # Sub operations
75
-
75
+
76
76
  def render_config_properties(config_info)
77
77
  if file_labels = config_info[:rendered_files]
78
78
  info('subconfigurations', { :prefix => false })
@@ -80,93 +80,93 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
80
80
  file_labels.each do |label|
81
81
  prefixed_message(:info, ' ', label, { :i18n => false, :prefix => false })
82
82
  end
83
- info("\n", { :i18n => false })
83
+ info("\n", { :i18n => false })
84
84
  else
85
85
  format = settings[:format]
86
86
  myself.result = config_info[:config].export
87
87
  render result, :format => format
88
- end
88
+ end
89
89
  end
90
-
90
+
91
91
  #---
92
-
92
+
93
93
  def render_config_property(config_info)
94
94
  format = settings[:format]
95
95
  myself.result = config_info[:value]
96
- render result, :format => format
96
+ render result, :format => format
97
97
  end
98
-
98
+
99
99
  #---
100
-
100
+
101
101
  def delete_config_property(config_info)
102
102
  remote_text = remote_message(settings[:net_remote])
103
- config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
103
+ config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
104
104
  render_options = { :config_file => blue(config_file), :remote_text => yellow(remote_text) }
105
105
  success = false
106
-
106
+
107
107
  if config_info[:property]
108
- name = parse_property_name(config_info[:property])
108
+ name = parse_property_name(config_info[:property])
109
109
  render_options.merge({ :name => blue(name) })
110
-
110
+
111
111
  config_info[:config].delete(config_info[:property])
112
-
113
- if File.exists?(config_info[:file])
112
+
113
+ if File.exists?(config_info[:file])
114
114
  if Util::Disk.write(config_info[:file], config_info[:translator].generate(config_info[:config].export))
115
115
  success = true
116
116
  else
117
117
  error('file_save', render_options)
118
- myself.status = code.configuration_save_failed
118
+ myself.status = code.configuration_save_failed
119
119
  end
120
120
  else
121
- info('no_config_file', render_options)
121
+ info('no_config_file', render_options)
122
122
  end
123
123
  else
124
124
  if File.exists?(config_info[:file])
125
125
  if FileUtils.rm(config_info[:file])
126
126
  success = true
127
127
  else
128
- error('file_remove', render_options)
128
+ error('file_remove', render_options)
129
129
  end
130
- end
130
+ end
131
131
  end
132
-
132
+
133
133
  if success
134
134
  if network.save({ :files => config_file, :remote => settings[:net_remote], :message => "Deleting configuration #{name} from #{config_file}", :allow_empty => true })
135
135
  success('delete', render_options)
136
136
  else
137
137
  error('delete', render_options)
138
- myself.status = code.configuration_save_failed
138
+ myself.status = code.configuration_save_failed
139
139
  end
140
140
  end
141
141
  end
142
-
142
+
143
143
  #---
144
-
144
+
145
145
  def set_config_property(config_info, values)
146
- name = parse_property_name(config_info[:property])
146
+ name = parse_property_name(config_info[:property])
147
147
  remote_text = remote_message(settings[:net_remote])
148
148
  config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
149
-
149
+
150
150
  render_options = { :config_file => blue(config_file), :name => blue(name), :remote_text => yellow(remote_text) }
151
-
151
+
152
152
  config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
153
153
  input_format = settings[:input_format]
154
-
154
+
155
155
  values.each_with_index do |value, index|
156
156
  if input_format
157
- translator = CORL.translator({}, input_format)
157
+ translator = CORL.translator({}, input_format)
158
158
  values[index] = translator.parse(value)
159
159
  end
160
160
  values[index] = Util::Data.value(values[index])
161
161
  end
162
-
162
+
163
163
  if settings[:append]
164
164
  if prev_value = config_info[:value]
165
165
  prev_value = array(prev_value)
166
-
166
+
167
167
  values.each do |value|
168
168
  prev_value.push(value)
169
- end
169
+ end
170
170
  values = prev_value
171
171
  end
172
172
  else
@@ -174,60 +174,60 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
174
174
  values = array(values)
175
175
  elsif values.size == 1
176
176
  values = values[0]
177
- end
177
+ end
178
178
  end
179
-
180
- myself.result = values
179
+
180
+ myself.result = values
181
181
  config_info[:config].set(config_info[:property], result)
182
-
182
+
183
183
  FileUtils.mkdir_p(File.dirname(config_info[:file]))
184
-
184
+
185
185
  if Util::Disk.write(config_info[:file], config_info[:translator].generate(config_info[:config].export))
186
186
  if network.save({ :files => config_file, :remote => settings[:net_remote], :message => "Updating configuration #{name} in #{config_file}", :allow_empty => true })
187
187
  success('update', render_options)
188
188
  else
189
189
  error('update', render_options)
190
- myself.status = code.configuration_save_failed
190
+ myself.status = code.configuration_save_failed
191
191
  end
192
192
  else
193
193
  error('file_save', render_options)
194
- myself.status = code.configuration_save_failed
194
+ myself.status = code.configuration_save_failed
195
195
  end
196
196
  end
197
-
197
+
198
198
  #-----------------------------------------------------------------------------
199
199
  # Utilities
200
-
200
+
201
201
  def parse_config_reference(node, name)
202
202
  # @TODO: Break this method up, URGENTLY, before it gets too hideous
203
203
  # Oh wait, it's already too hideous
204
-
204
+
205
205
  info = {}
206
206
  data = {}
207
- config = CORL::Config.new({}, {}, true, false)
207
+ config = CORL::Config.new({}, {}, true, false)
208
208
  translators = CORL.loaded_plugins(:nucleon, :translator).keys
209
-
209
+
210
210
  # common@php::apache::memory_limit
211
211
  # identity/test@users::user[admin][shell]
212
212
  # servers/development/dev.loc@facts[server_environment]
213
-
213
+
214
214
  config_elements = name.split('@')
215
-
215
+
216
216
  property = config_elements.size > 1 ? config_elements.pop : nil
217
- config_elements = config_elements[0].split('/') if config_elements.size > 0
218
- config_file_name = config_elements.pop
217
+ config_elements = config_elements[0].split('/') if config_elements.size > 0
218
+ config_file_name = config_elements.pop
219
219
  config_path = File.join(network.config_directory, *config_elements)
220
220
  config_dir = config_file_name ? File.join(config_path, config_file_name) : config_path
221
221
  config_file = nil
222
222
  config_files = nil
223
223
  translator = []
224
-
224
+
225
225
  if config_file_name
226
226
  property = property.gsub(/\]$/, '').split(/\]?\[/) if property
227
-
227
+
228
228
  translators.each do |translator_name|
229
229
  config_file = File.join(config_path, "#{config_file_name}." + translator_name.to_s)
230
-
230
+
231
231
  if File.exists?(config_file)
232
232
  unless data = Util::Disk.read(config_file)
233
233
  error('file_read', { :config_file => config_file })
@@ -236,17 +236,17 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
236
236
  unless load_translator = CORL.translator({}, translator_name)
237
237
  error('translator_load', { :translator => translator_name })
238
238
  return nil
239
- end
239
+ end
240
240
  config.import(load_translator.parse(data))
241
241
  translator << load_translator
242
242
  end
243
243
  end
244
244
  end
245
-
245
+
246
246
  file_exists = translator.empty? ? false : true
247
-
247
+
248
248
  if settings[:save_format]
249
- translator = CORL.translator({}, settings[:save_format])
249
+ translator = CORL.translator({}, settings[:save_format])
250
250
  else
251
251
  if translator.empty?
252
252
  translator = CORL.translator({}, CORL.type_default(:nucleon, :translator))
@@ -254,42 +254,42 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
254
254
  translator = translator.size > 1 ? translator.shift : translator[0]
255
255
  end
256
256
  end
257
-
257
+
258
258
  config_file = File.join(config_path, "#{config_file_name}." + translator.plugin_name.to_s)
259
-
259
+
260
260
  unless file_exists
261
261
  hiera_search_path = node.hiera_configuration[:hierarchy]
262
262
  config_files = []
263
-
263
+
264
264
  if File.directory?(config_dir)
265
265
  config_files = Dir.glob("#{config_dir}/**/*").select do |file|
266
266
  is_config = false
267
-
267
+
268
268
  translators.each do |translator_name|
269
269
  is_config = true if file.match(/\.#{translator_name}/)
270
270
  end
271
271
  is_config
272
272
  end
273
-
273
+
274
274
  config_files.collect! do |file|
275
275
  file.sub(/#{network.config_directory + File::SEPARATOR}/, '')
276
276
  end
277
277
  end
278
-
278
+
279
279
  ordered_config_files = []
280
280
  rendered_config_files = []
281
-
281
+
282
282
  hiera_search_path.each do |search_path|
283
283
  search_components = search_path.split(File::SEPARATOR)
284
-
284
+
285
285
  rendered_config_files << "SEARCH: #{search_path}"
286
-
286
+
287
287
  config_files.each do |file|
288
288
  file_ext = File.extname(file)
289
289
  file_components = file.sub(/\..*$/, '').split(File::SEPARATOR)
290
290
  rendered_file_components = []
291
291
  file_match = true
292
-
292
+
293
293
  search_components.each_with_index do |search_item, index|
294
294
  if search_item.strip =~ /^%{:?:?([^}]+)}$/ && index < file_components.size
295
295
  rendered_file_components << cyan(file_components[index])
@@ -299,9 +299,9 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
299
299
  rendered_file_components << yellow(search_item)
300
300
  end
301
301
  end
302
-
302
+
303
303
  rendered_file = " #{rendered_file_components.join(File::SEPARATOR)} [ #{blue(file_ext.sub('.', ''))} ]"
304
-
304
+
305
305
  if file_match && ! ordered_config_files.include?(file)
306
306
  ordered_config_files << file
307
307
  rendered_config_files << rendered_file
@@ -309,7 +309,7 @@ class Config < Nucleon.plugin_class(:nucleon, :cloud_action)
309
309
  end
310
310
  end
311
311
  end
312
-
312
+
313
313
  {
314
314
  :translator => translator,
315
315
  :file => config_file,
@@ -1,48 +1,48 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- module Cloud
4
+ module Network
5
5
  class Create < Nucleon.plugin_class(:nucleon, :cloud_action)
6
6
 
7
7
  include Mixin::Action::Project
8
-
8
+
9
9
  #-----------------------------------------------------------------------------
10
10
  # Info
11
-
11
+
12
12
  def self.describe
13
- super(:cloud, :create, 1000)
13
+ super(:network, :create, 1000)
14
14
  end
15
-
15
+
16
16
  #-----------------------------------------------------------------------------
17
17
  # Settings
18
-
18
+
19
19
  def configure
20
- super do
21
- config.defaults(CORL.action_config(:project_create))
20
+ super do
21
+ config.defaults(CORL.action_config(:project_create))
22
22
  config[:project_reference].default = 'github:::coralnexus/network-template'
23
23
  end
24
24
  end
25
-
25
+
26
26
  #---
27
-
27
+
28
28
  def ignore
29
29
  node_ignore
30
30
  end
31
-
31
+
32
32
  def arguments
33
33
  [ :project_reference ]
34
34
  end
35
-
35
+
36
36
  #-----------------------------------------------------------------------------
37
37
  # Operations
38
-
38
+
39
39
  def execute
40
40
  super(false) do
41
41
  info('start')
42
-
42
+
43
43
  project = project_load(settings[:path], true, true)
44
44
  myself.status = code.project_failure unless project
45
-
45
+
46
46
  if project.remote(:origin) =~ /coralnexus\/network\-template/
47
47
  project.delete_remote(:origin)
48
48
  project.delete_remote(:edit)
@@ -1,49 +1,49 @@
1
1
 
2
2
  module Nucleon
3
3
  module Action
4
- module Cloud
4
+ module Network
5
5
  class Images < Nucleon.plugin_class(:nucleon, :cloud_action)
6
-
6
+
7
7
  #-----------------------------------------------------------------------------
8
8
  # Info
9
-
9
+
10
10
  def self.describe
11
- super(:cloud, :images, 850)
11
+ super(:network, :images, 850)
12
12
  end
13
13
 
14
14
  #-----------------------------------------------------------------------------
15
15
  # Settings
16
-
16
+
17
17
  def configure
18
18
  super do
19
19
  codes :node_load_failure,
20
20
  :image_load_failure
21
-
22
- register :region, :str, nil
21
+
22
+ register :region, :str, nil
23
23
  register :match_case, :bool, false
24
24
  register :require_all, :bool, true
25
25
  register :search, :array, []
26
26
  end
27
27
  end
28
-
28
+
29
29
  def node_config
30
30
  super
31
31
  config[:node_provider].default = nil
32
32
  end
33
-
33
+
34
34
  #---
35
-
35
+
36
36
  def ignore
37
37
  node_ignore - [ :node_provider ]
38
38
  end
39
-
39
+
40
40
  def arguments
41
41
  [ :node_provider, :search ]
42
42
  end
43
-
43
+
44
44
  #-----------------------------------------------------------------------------
45
45
  # Operations
46
-
46
+
47
47
  def execute
48
48
  super do |local_node|
49
49
  ensure_network do
@@ -52,7 +52,7 @@ class Images < Nucleon.plugin_class(:nucleon, :cloud_action)
52
52
  images.each do |image|
53
53
  prefixed_message(:info, ' ', node.render_image(image), { :i18n => false, :prefix => false })
54
54
  end
55
-
55
+
56
56
  myself.result = images
57
57
  success('results', { :images => images.length }) if images.length > 1
58
58
  else