lorj 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/example/students_1/process/students.rb +1 -1
  4. data/example/students_1/student_v1.md +2 -0
  5. data/example/students_1/students.rb +2 -1
  6. data/example/students_2/process/students.rb +1 -1
  7. data/example/students_2/students.rb +4 -2
  8. data/example/students_3/controller/yaml_students_def.rb +1 -1
  9. data/example/students_3/process/students.rb +1 -1
  10. data/example/students_3/student_v3.md +5 -3
  11. data/example/students_3/students.rb +5 -3
  12. data/example/students_4/controller/yaml_students_def.rb +1 -1
  13. data/example/students_4/process/students/definition/students.rb +1 -1
  14. data/example/students_4/students.rb +5 -3
  15. data/example/students_5/controller/yaml_students.rb +1 -1
  16. data/example/students_5/process/students.rb +1 -1
  17. data/example/students_5/student_v5.md +4 -4
  18. data/example/students_5/students.rb +8 -7
  19. data/example/yaml_students/students.rb +4 -4
  20. data/lib/core/core.rb +110 -64
  21. data/lib/core/core_internal.rb +110 -15
  22. data/lib/core/core_object_data.rb +4 -4
  23. data/lib/core/core_process_setup.rb +3 -30
  24. data/lib/core/lorj_data.rb +1 -1
  25. data/lib/core/lorj_keypath.rb +3 -1
  26. data/lib/core/process.rb +67 -0
  27. data/lib/lorj/version.rb +2 -1
  28. data/lib/lorj.rb +3 -4
  29. data/lib/lorj_account.rb +6 -5
  30. data/lib/lorj_config.rb +3 -2
  31. data/lib/providers/templates/compute.rb +1 -1
  32. data/lorj-spec/controllers/mock/mock.rb +144 -0
  33. data/lorj-spec/data.yaml +0 -0
  34. data/lorj-spec/process/mock2_process.rb +48 -0
  35. data/lorj-spec/process/mock_process.rb +48 -0
  36. data/lorj-spec/providers/mock2/mock2.rb +0 -0
  37. data/lorj.gemspec +2 -4
  38. data/spec/05_lorj_keypath_spec.rb +78 -0
  39. data/spec/20_lorj_meta_spec.rb +1 -1
  40. data/spec/21_lorj_processes_spec.rb +115 -0
  41. metadata +27 -42
  42. data/lib/core_process/cloud/process/common.rb +0 -60
  43. data/lib/core_process/cloud/process/connection.rb +0 -92
  44. data/lib/core_process/cloud/process/external_network.rb +0 -90
  45. data/lib/core_process/cloud/process/flavor.rb +0 -97
  46. data/lib/core_process/cloud/process/images.rb +0 -99
  47. data/lib/core_process/cloud/process/internet_network.rb +0 -33
  48. data/lib/core_process/cloud/process/internet_server.rb +0 -29
  49. data/lib/core_process/cloud/process/keypairs.rb +0 -332
  50. data/lib/core_process/cloud/process/network.rb +0 -107
  51. data/lib/core_process/cloud/process/public_ip.rb +0 -102
  52. data/lib/core_process/cloud/process/router.rb +0 -267
  53. data/lib/core_process/cloud/process/rules.rb +0 -120
  54. data/lib/core_process/cloud/process/security_groups.rb +0 -120
  55. data/lib/core_process/cloud/process/server.rb +0 -126
  56. data/lib/core_process/cloud/process/server_log.rb +0 -34
  57. data/lib/core_process/cloud/process/subnetwork.rb +0 -96
  58. data/lib/core_process/cloud_process.rb +0 -30
  59. data/lib/prc_base_config.rb +0 -300
  60. data/lib/prc_core_config.rb +0 -1258
  61. data/lib/prc_section_config.rb +0 -90
  62. data/lib/providers/hpcloud/compute.rb +0 -105
  63. data/lib/providers/hpcloud/hpcloud.rb +0 -462
  64. data/lib/providers/hpcloud/network.rb +0 -115
  65. data/lib/providers/hpcloud/security_groups.rb +0 -68
  66. data/lib/providers/openstack/openstack.rb +0 -410
  67. data/lib/providers/openstack/openstack_create.rb +0 -205
  68. data/lib/providers/openstack/openstack_delete.rb +0 -28
  69. data/lib/providers/openstack/openstack_get.rb +0 -39
  70. data/lib/providers/openstack/openstack_process.rb +0 -26
  71. data/lib/providers/openstack/openstack_query.rb +0 -96
  72. data/lib/providers/openstack/openstack_update.rb +0 -35
  73. data/lib/rh.rb +0 -426
  74. data/spec/01_hash_rh_spec.rb +0 -282
  75. data/spec/02_prc_base_config_spec.rb +0 -227
  76. data/spec/03_prc_section_config_spec.rb +0 -196
  77. data/spec/04_prc_core_config_spec.rb +0 -325
@@ -1,325 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- # (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- # require 'byebug'
19
-
20
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
21
-
22
- require 'rh.rb'
23
- require 'prc.rb'
24
- require 'prc_base_config.rb'
25
- require 'prc_core_config.rb'
26
-
27
- describe 'class: PRC::CoreConfig,' do
28
- context 'when creating a new instance' do
29
- before(:all) do
30
- @config = PRC::CoreConfig.new
31
- end
32
-
33
- it 'should be loaded' do
34
- expect(@config).to be
35
- end
36
-
37
- it 'runtime set works' do
38
- expect(@config[:test] = :toto).to eq(:toto)
39
- expect(@config.exist?(:test)).to eq(true)
40
- expect(@config[:test]).to eq(:toto)
41
- end
42
- end
43
-
44
- context 'from a child class, with local layer set to :test => :found_local, '\
45
- ':test2 => {:test => :subhash} and runtime layer' do
46
- before(:all) do
47
- # Child class definition for rSpec.
48
- class Test1 < PRC::CoreConfig
49
- def initialize
50
- local = PRC::BaseConfig.new(:test => :found_local,
51
- :test2 => { :test => :subhash })
52
- layers = []
53
- layers << PRC::CoreConfig.define_layer(:name => 'local',
54
- :config => local)
55
- layers << PRC::CoreConfig.define_layer # runtime
56
-
57
- initialize_layers(layers)
58
- end
59
-
60
- def iexist?(options)
61
- p_exist?(options)
62
- end
63
-
64
- def set(options)
65
- p_set(options)
66
- end
67
-
68
- def get(options)
69
- p_get(options)
70
- end
71
- end
72
- @config = Test1.new
73
- end
74
-
75
- it 'should be loaded' do
76
- expect(@config).to be
77
- expect(@config.layers).to eq(%w(runtime local))
78
- end
79
-
80
- it 'config.version("local") return nil' do
81
- expect(@config.version('local')).to equal(nil)
82
- end
83
-
84
- it 'config.version("runtime") return nil' do
85
- expect(@config.version('runtime')).to equal(nil)
86
- end
87
-
88
- it 'config.version["inexistent"] return nil' do
89
- expect(@config.version('inexistent')).to equal(nil)
90
- end
91
-
92
- it 'only config.version_set("local") = "1"' do
93
- expect(@config.version_set('local', '1')).to eq('1')
94
- end
95
-
96
- it 'only config.version("local") return "1"' do
97
- expect(@config.version('local')).to eq('1')
98
- expect(@config.version('runtime')).to equal(nil)
99
- expect(@config.version('inexistent')).to equal(nil)
100
- end
101
-
102
- it 'config.exist?(:test) returns true' do
103
- expect(@config.exist?(:test)).to equal(true)
104
- end
105
-
106
- it 'config.p_exist?(:keys => [:test]) returns true' do
107
- expect(@config.iexist?(:keys => [:test])).to equal(true)
108
- end
109
-
110
- it 'config.p_exist?(:keys => [:test], :name => "runtime") returns false' do
111
- expect(@config.iexist?(:keys => [:test],
112
- :name => 'runtime')).to equal(false)
113
- end
114
-
115
- it 'config.p_exist?(:keys => [:test], :names => ["runtime"])'\
116
- ' returns false' do
117
- expect(@config.iexist?(:keys => [:test],
118
- :names => ['runtime'])).to equal(false)
119
- end
120
-
121
- it 'config.p_exist?(:keys => [:test], :names => ["local"]) returns true' do
122
- expect(@config.iexist?(:keys => [:test],
123
- :names => ['local'])).to equal(true)
124
- end
125
-
126
- it 'config.exist?(:test2, :test) returns true' do
127
- expect(@config.exist?(:test2, :test)).to equal(true)
128
- end
129
-
130
- it 'config.where?(:test) should be ["local"]' do
131
- expect(@config.where?(:test)).to eq(['local'])
132
- end
133
-
134
- it 'config.where?(:test2) should be ["local"]' do
135
- expect(@config.where?(:test2)).to eq(['local'])
136
- end
137
-
138
- it 'config.where?(:test2, :test) should be ["local"]' do
139
- expect(@config.where?(:test2, :test)).to eq(['local'])
140
- end
141
-
142
- it 'config.[:test] = :where set in "runtime".' do
143
- expect(@config[:test] = :where).to eq(:where)
144
- expect(@config.where?(:test)).to eq(%w(runtime local))
145
- expect(@config[:test]).to equal(:where)
146
- end
147
-
148
- it 'config.del(:test) remove the data from runtime, '\
149
- 'and restore from local.' do
150
- expect(@config.del(:test)).to eq(:where)
151
- expect(@config[:test]).to equal(:found_local)
152
- end
153
-
154
- it 'PRC::CoreConfig.define_layer(...) return a valid standalone layer' do
155
- config = PRC::BaseConfig.new
156
- layer = PRC::CoreConfig.define_layer(:name => 'instant',
157
- :config => config)
158
- expect(layer).to be
159
- expect(layer[:name]).to eq('instant')
160
- expect(layer[:config]).to eq(config)
161
- expect(layer[:set]).to equal(true)
162
- expect(layer[:load]).to equal(false)
163
- expect(layer[:save]).to equal(false)
164
- expect(layer[:file_set]).to equal(false)
165
- end
166
-
167
- it "config.layer_add(:name => 'instant') return true if layer is added" do
168
- layer = PRC::CoreConfig.define_layer(:name => 'instant')
169
- expect(@config.layer_add layer).to equal(true)
170
- end
171
-
172
- it 'config.layers return %w(instant runtime local)' do
173
- expect(@config.layers).to eq(%w(instant runtime local))
174
- end
175
-
176
- it 'config.layer_add(layer) return nil if layer name already exist '\
177
- 'in layers' do
178
- config = PRC::BaseConfig.new
179
- layer = PRC::CoreConfig.define_layer(:name => 'instant',
180
- :config => config)
181
- expect(@config.layers).to eq(%w(instant runtime local))
182
- expect(@config.layer_add layer).to equal(nil)
183
- expect(@config.layers).to eq(%w(instant runtime local))
184
- end
185
-
186
- it "config['test'] = 'toto' is added in the 'instant' layer" do
187
- @config['test'] = 'toto'
188
- expect(@config.where?('test')).to eq(%w(instant))
189
- end
190
-
191
- it "config.layer_remove(:name => 'instant') return true" do
192
- expect(@config.layer_remove(:name => 'instant')).to equal(true)
193
- end
194
-
195
- it "config.where?('test') return false - The layer is inexistent." do
196
- expect(@config.where?('test')).to equal(false)
197
- end
198
-
199
- it "config.layer_remove(:name => 'runtime') return nil"\
200
- ' - Unable to remove a layer not added at runtime' do
201
- expect(@config.layers).to eq(%w(runtime local))
202
- expect(@config.layer_remove(:name => 'runtime')).to equal(nil)
203
- expect(@config.layers).to eq(%w(runtime local))
204
- end
205
-
206
- it 'a child set(keys, value, name => "local") works.' do
207
- value = { :data1 => 'test_data1', :data2 => 'test_data2' }
208
- expect(@config.set(:keys => [:merge1],
209
- :value => value,
210
- :name => 'local')).to eq(value)
211
- expect(@config.where?(:merge1)).to eq(%w(local))
212
- end
213
-
214
- it 'a child set(keys, value, names => ["local"]) works '\
215
- 'but set in runtime. :names is ignored.' do
216
- value = { :data1 => 'test_data1', :data2 => 'test_data3' }
217
- expect(@config.set(:keys => [:merge1],
218
- :value => value,
219
- :names => ['local'])).to eq(value)
220
- expect(@config.where?(:merge1)).to eq(%w(runtime local))
221
- end
222
-
223
- it 'a child set(keys, value, name => "runtime") works.' do
224
- value = { :data2 => 'value_runtime', :test_runtime => true }
225
- expect(@config.set(:keys => [:merge1],
226
- :value => value,
227
- :name => 'runtime')).to eq(value)
228
- expect(@config.where?(:merge1)).to eq(%w(runtime local))
229
- expect(@config[:merge1]).to eq(value)
230
- end
231
-
232
- it 'a child get(keys, name) can do merge '\
233
- 'even with only one layer selected.' do
234
- value_local = { :data1 => 'test_data1', :data2 => 'test_data2' }
235
- expect(@config.get(:keys => [:merge1], :merge => true,
236
- :names => ['local'])).to eq(value_local)
237
- value_runtime = { :data2 => 'value_runtime', :test_runtime => true }
238
- expect(@config.get(:keys => [:merge1], :merge => true,
239
- :names => ['runtime'])).to eq(value_runtime)
240
- end
241
-
242
- context "with config[:merge1] = {:data2 => {:test_runtime => true} }\n"\
243
- 'and local: :merge1: => {:data1: test_data1, :data2: test_data3}' do
244
- before(:all) do
245
- @config[:merge1] = { :data2 => { :test_runtime => true } }
246
- value = { :data1 => 'test_data1', :data2 => 'test_data3' }
247
- @config.set(:keys => [:merge1], :value => value, :name => 'local')
248
- end
249
-
250
- it 'config.mergeable?(:keys => [:merge1, :data2]) return false, '\
251
- 'because the first found in the deepest layers is not a Hash/Array.' do
252
- expect(@config.where?(:merge1, :data2)).to eq(%w(runtime local))
253
- expect(@config.mergeable?(:keys => [:merge1, :data2])).to equal(false)
254
- end
255
-
256
- it 'config.mergeable?(:keys => [:merge1, :data2], '\
257
- ':exclusive => true) return false '\
258
- '- "runtime" layer :data2 is not a Hash' do
259
- expect(@config.where?(:merge1, :data2)).to eq(%w(runtime local))
260
- expect(@config.mergeable?(:keys => [:merge1, :data2],
261
- :exclusive => true)).to equal(false)
262
- end
263
-
264
- it 'config.merge() return "test_data3" a single data, first found in '\
265
- 'the deepest layers.' do
266
- expect(@config.merge(:merge1, :data2)).to eq('test_data3')
267
- end
268
- end
269
-
270
- context "with config[:merge1] = {:data2 => :test_runtime}\n"\
271
- 'and local: :merge1: => {:data2 => {:test => :test_data2} }' do
272
- before(:all) do
273
- @config[:merge1] = { :data2 => :test_runtime }
274
- value = { :data2 => { :test => :test_data2 } }
275
- @config.set(:keys => [:merge1], :value => value, :name => 'local')
276
- end
277
-
278
- it 'config.mergeable?(:keys => [:merge1, :data2]) return true, '\
279
- 'because the first found in the deepest layers is a Hash.' do
280
- expect(@config.where?(:merge1)).to eq(%w(runtime local))
281
- expect(@config.mergeable?(:keys => [:merge1, :data2])).to equal(true)
282
- end
283
-
284
- it 'config.mergeable?(:keys => [:merge1, :data2], '\
285
- ':exclusive => true) return false '\
286
- '- "runtime" layer :data2 is not a Hash' do
287
- expect(@config.mergeable?(:keys => [:merge1, :data2],
288
- :exclusive => true)).to equal(false)
289
- end
290
-
291
- it 'config.merge() return a single data, first found in the '\
292
- 'deepest layers.' do
293
- expect(@config.merge(:merge1, :data2)).to eq(:test => :test_data2)
294
- end
295
- end
296
-
297
- context "with config[:merge1] = {:data2 => {:test_runtime => true} }\n"\
298
- 'and local: :merge1: => {:data2 => {:test => :test_data2} }' do
299
- before(:all) do
300
- @config[:merge1] = { :data2 => { :test_runtime => true } }
301
- value = { :data2 => { :test => :test_data2 } }
302
- @config.set(:keys => [:merge1], :value => value, :name => 'local')
303
- end
304
-
305
- it 'config.mergeable?(:keys => [:merge1, :data2]) return true, '\
306
- 'because the first found in the deepest layers is a Hash.' do
307
- expect(@config.where?(:merge1, :data2)).to eq(%w(runtime local))
308
- expect(@config.mergeable?(:keys => [:merge1, :data2])).to equal(true)
309
- end
310
-
311
- it 'config.mergeable?(:keys => [:merge1, :data2], '\
312
- ':exclusive => true) return true '\
313
- '- All layers data found are Hash type.' do
314
- expect(@config.mergeable?(:keys => [:merge1, :data2],
315
- :exclusive => true)).to equal(true)
316
- end
317
-
318
- it 'config.merge() return a single data, first found in the '\
319
- 'deepest layers.' do
320
- expect(@config.merge(:merge1, :data2)).to eq(:test_runtime => true,
321
- :test => :test_data2)
322
- end
323
- end
324
- end
325
- end