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,227 +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' # Load PRC_core framework
25
-
26
- describe 'class: PRC::BaseConfig,' do
27
- context 'when creating a new instance' do
28
- it 'should be loaded' do
29
- config = PRC::BaseConfig.new
30
- expect(config).to be
31
- end
32
-
33
- it 'should be initialized with Hash data.' do
34
- config = PRC::BaseConfig.new(:test => :toto)
35
- expect(config.data).to eq(:test => :toto)
36
- end
37
- end
38
-
39
- context 'config[*keys] = value' do
40
- before(:all) do
41
- @config = PRC::BaseConfig.new
42
- end
43
-
44
- it 'should be able to create a key/value in the config object.' do
45
- @config[:test1] = 'value'
46
- expect(@config.data).to eq(:test1 => 'value')
47
- end
48
-
49
- it 'should be able to create a key tree/value in the config object.' do
50
- @config[:test1, :test2] = 'value'
51
- expect(@config.data).to eq(:test1 => { :test2 => 'value' })
52
- end
53
-
54
- it 'version = "0.1" can be set and get' do
55
- expect(@config.version).to equal(nil)
56
- @config.version = '0.1'
57
- expect(@config.version).to eq('0.1')
58
- end
59
- end
60
-
61
- context 'config.del(*keys)' do
62
- before(:all) do
63
- @config = PRC::BaseConfig.new(:test1 => 'value',
64
- :test2 => { :test2 => 'value' })
65
- end
66
-
67
- it 'should be able to delete a key/value in the config object.' do
68
- expect(@config.del(:test1)).to eq('value')
69
- expect(@config.data).to eq(:test2 => { :test2 => 'value' })
70
- end
71
-
72
- it 'should be able to delete a key/value in the config object.' do
73
- expect(@config.del(:test2)).to eq(:test2 => 'value')
74
- expect(@config.data).to eq({})
75
- end
76
- end
77
-
78
- context 'config[*keys]' do
79
- before(:all) do
80
- @config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
81
- end
82
-
83
- it 'with no parameter should return nil' do
84
- expect(@config[]).to equal(nil)
85
- end
86
-
87
- it "with keys = [:test1], should return {:test2 =>'value'}." do
88
- expect(@config[:test1]).to eq(:test2 => 'value')
89
- end
90
-
91
- it "with keys = [:test1, :test2], should return {:test2 =>'value'}." do
92
- expect(@config[:test1, :test2]).to eq('value')
93
- end
94
- end
95
-
96
- context 'config.exist?(*keys)' do
97
- before(:all) do
98
- @config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
99
- end
100
-
101
- it 'with no parameter should return nil' do
102
- expect(@config.exist?).to equal(nil)
103
- end
104
-
105
- it 'with keys = [test1], should return true.' do
106
- expect(@config.exist?(:test1)).to equal(true)
107
- end
108
-
109
- it 'with keys = [:test1, :test2], should return true.' do
110
- expect(@config.exist?(:test1, :test2)).to equal(true)
111
- end
112
-
113
- it 'with keys = [:test], should return false.' do
114
- expect(@config.exist?(:test)).to equal(false)
115
- end
116
-
117
- it 'with keys = [:test1, :test], should return false.' do
118
- expect(@config.exist?(:test1, :test)).to equal(false)
119
- end
120
-
121
- it 'with keys = [:test1, :test2, :test3], should return false.' do
122
- expect(@config.exist?(:test1, :test2, :test3)).to equal(false)
123
- end
124
- end
125
-
126
- context "config.erase on :test1 => { :test2 => 'value' }" do
127
- it 'with no parameter should return {} and cleanup internal data.' do
128
- config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
129
- config.version = '0.1'
130
-
131
- expect(config.erase).to eq({})
132
- expect(config.data).to eq({})
133
- expect(config.version).to eq(nil)
134
- end
135
- end
136
-
137
- context 'config.save and config.load' do
138
- before(:all) do
139
- @config = PRC::BaseConfig.new(:test1 => { :test2 => 'value' })
140
- end
141
-
142
- it 'save with no parameter should fail' do
143
- expect { @config.save }.to raise_error RuntimeError
144
- end
145
-
146
- it 'save with filename set, save should true' do
147
- file = '~/.lorj_rspec.yaml'
148
- @config.filename = file
149
- filename = File.expand_path(file)
150
-
151
- expect(@config.filename).to eq(filename)
152
- expect(@config.save).to equal(true)
153
-
154
- File.delete(filename)
155
- end
156
-
157
- it 'save with filename given, returns true, and file saved.' do
158
- file = '~/.lorj_rspec2.yaml'
159
- old_file = @config.filename
160
- filename = File.expand_path(file)
161
-
162
- @config.version = '1'
163
- expect(@config.save(file)).to equal(true)
164
- expect(@config.filename).not_to eq(old_file)
165
- expect(@config.filename).to eq(filename)
166
- end
167
-
168
- it 'load returns true and file is loaded.' do
169
- @config.erase
170
-
171
- expect(@config.load).to equal(true)
172
- expect(@config.data).to eq(:test1 => { :test2 => 'value' })
173
- expect(@config.version).to eq('1')
174
-
175
- File.delete(@config.filename)
176
- end
177
-
178
- it 'load raises if file given is not found.' do
179
- @config.erase
180
-
181
- expect { @config.load('~/.lorj_rspec.yaml') }.to raise_error
182
- end
183
- end
184
-
185
- context 'config.data_options(options)' do
186
- it 'with no parameter should return {} ie no options.' do
187
- config = PRC::BaseConfig.new
188
- expect(config.data_options).to eq({})
189
- end
190
-
191
- it 'with :readonly => true should return {} ie no options.' do
192
- config = PRC::BaseConfig.new
193
- expect(config.data_options(:readonly => true)).to eq(:readonly => true)
194
- end
195
-
196
- it 'with any unknown options like :section => "test" should return '\
197
- '{:section => "test"}.' do
198
- config = PRC::BaseConfig.new
199
- expect(config.data_options(:section => 'test')).to eq(:section => 'test')
200
- end
201
-
202
- it 'with any existing options set we replace it all.' do
203
- config = PRC::BaseConfig.new
204
- config.data_options(:section => 'test')
205
- expect(config.data_options(:toto => 'tata')).to eq(:toto => 'tata')
206
- end
207
-
208
- it 'with :data_readonly => true, we cannot set a data.' do
209
- config = PRC::BaseConfig.new(:test => 'toto')
210
- config.data_options(:data_readonly => true)
211
- config[:test] = 'titi'
212
- expect(config.data).to eq(:test => 'toto')
213
- end
214
-
215
- it 'with :file_readonly => true, we cannot save data to a file.' do
216
- config = PRC::BaseConfig.new(:test => 'toto')
217
- file = '~/.rspec_test.yaml'
218
- file_path = File.expand_path(file)
219
- config.data_options(:file_readonly => true)
220
- system('rm -f ~/.rspec_test.yaml')
221
- expect(config.save(file)).to equal(false)
222
- expect(config.filename).to equal(nil)
223
- expect { config.load(file) }.to raise_error
224
- expect(config.filename).to eq(file_path)
225
- end
226
- end
227
- end
@@ -1,196 +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' # Load BaseConfig parent class
25
- require 'prc_section_config.rb' # Load SectionConfig class
26
-
27
- describe 'class: PRC::SectionConfig,' do
28
- context 'PRC::SectionConfig' do
29
- it '.new created a new instance' do
30
- config = PRC::SectionConfig.new
31
- expect(config).to be
32
- end
33
-
34
- it '.new(:default => {:test => :toto},'\
35
- ':section => {:key => :value}) set expected default data' do
36
- config = PRC::SectionConfig.new(:default => { :test => :toto },
37
- :section => { :key => :value })
38
- expect(config.data).to eq(:default => { :test => :toto },
39
- :section => { :key => :value })
40
- end
41
- end
42
-
43
- context 'config = nil' do
44
- before(:all) do
45
- @config = PRC::SectionConfig.new
46
- end
47
-
48
- it 'config[:test1] = "value" set internal data to '\
49
- ':default=>{:test1=>"value"}' do
50
- @config[:test1] = 'value'
51
- expect(@config.data).to eq(:default => { :test1 => 'value' })
52
- end
53
-
54
- it 'config[:test1, :test2] = "value" set internal data to '\
55
- ':default=>{:test1 => { :test2 => "value"}}' do
56
- @config[:test1, :test2] = 'value'
57
- expect(@config.data).to eq(:default =>
58
- { :test1 => { :test2 => 'value' } })
59
- end
60
- context 'config.data_options(:section => :mysection)' do
61
- it 'return true' do
62
- expect(@config.data_options(:section => :mysection)).to eq(:section =>
63
- :mysection)
64
- end
65
-
66
- it 'config[:test1, :test2] = "value2" set '\
67
- 'mysection=>{:test1 => { :test2 => "value2"}}' do
68
- @config[:test1, :test2] = 'value2'
69
- expect(@config.data[:mysection]).to eq(:test1 => { :test2 => 'value2' })
70
- end
71
- it 'config[:test1, :test2] returns "value2"' do
72
- expect(@config[:test1, :test2]).to eq('value2')
73
- end
74
- it 'config.data_options({})' do
75
- expect(@config.data_options({})).to eq({})
76
- end
77
- it 'config[:test1, :test2] returns "value"' do
78
- expect(@config[:test1, :test2]).to eq('value')
79
- end
80
- end
81
- end
82
-
83
- context 'SectionConfig.new {:default => {:test => :toto},'\
84
- ':section => {:key => :value} }' do
85
- before(:all) do
86
- @config = PRC::SectionConfig.new(:default => { :test => :toto },
87
- :section => { :key => :value })
88
- end
89
-
90
- it 'config.del(:test) return :toto' do
91
- expect(@config.del(:test)).to eq(:toto)
92
- expect(@config.data).to eq(:default => {},
93
- :section => { :key => :value })
94
- end
95
-
96
- it 'config.del(:key) returns nil' do
97
- expect(@config.del(:key)).to equal(nil)
98
- expect(@config.data).to eq(:default => {},
99
- :section => { :key => :value })
100
- end
101
- end
102
-
103
- context 'SectionConfig.new {:test1 => { :test2 => "value" }}' do
104
- before(:all) do
105
- @config = PRC::SectionConfig.new(:test1 => { :test2 => 'value' })
106
- end
107
-
108
- it 'config[] return nil' do
109
- expect(@config[]).to equal(nil)
110
- end
111
-
112
- it 'config[:test1] returns nil.' do
113
- expect(@config[:test1]).to equal(nil)
114
- end
115
-
116
- it 'config[:test1, :test2] returns nil.' do
117
- expect(@config[:test1, :test2]).to equal(nil)
118
- end
119
-
120
- it 'config[:test2] returns nil.' do
121
- expect(@config[:test2]).to equal(nil)
122
- end
123
-
124
- it 'config[:test2] returns nil.' do
125
- expect(@config[:test2]).to equal(nil)
126
- end
127
-
128
- it 'with config.data_options({:section => :test1})' do
129
- expect(@config.data_options(:section =>
130
- :test1)).to eq(:section => :test1)
131
- end
132
-
133
- it 'config[:test1] returns nil.' do
134
- expect(@config[:test1]).to equal(nil)
135
- end
136
-
137
- it 'config[:test1, :test2] returns nil.' do
138
- expect(@config[:test1, :test2]).to equal(nil)
139
- end
140
-
141
- it "config[:test2] returns NOW 'value'." do
142
- expect(@config[:test2]).to eq('value')
143
- end
144
- end
145
-
146
- context 'SectionConfig.new {:test1 => { :test2 => "value" }}' do
147
- before(:all) do
148
- @config = PRC::SectionConfig.new(:test1 => { :test2 => 'value' })
149
- end
150
-
151
- it 'config.exist? return nil' do
152
- expect(@config.exist?).to equal(nil)
153
- end
154
-
155
- it 'config.exist?(test1) return false.' do
156
- expect(@config.exist?(:test1)).to equal(false)
157
- end
158
-
159
- it 'config.exist?(:test1, :test2) return false.' do
160
- expect(@config.exist?(:test1, :test2)).to equal(false)
161
- end
162
-
163
- it 'config.exist?(:test) return false.' do
164
- expect(@config.exist?(:test)).to equal(false)
165
- end
166
-
167
- it 'config.exist?(:test1, :test) return false.' do
168
- expect(@config.exist?(:test1, :test)).to equal(false)
169
- end
170
-
171
- it 'config.exist?(:test1, :test2, :test3) return false.' do
172
- expect(@config.exist?(:test1, :test2, :test3)).to equal(false)
173
- end
174
-
175
- it 'with config.data_options({:section => :test1})' do
176
- expect(@config.data_options(:section =>
177
- :test1)).to eq(:section => :test1)
178
- end
179
-
180
- it 'config.exist? return nil' do
181
- expect(@config.exist?).to equal(nil)
182
- end
183
-
184
- it 'config.exist?(test1) return false.' do
185
- expect(@config.exist?(:test1)).to equal(false)
186
- end
187
-
188
- it 'config.exist?(:test1, :test2) return false.' do
189
- expect(@config.exist?(:test1, :test2)).to equal(false)
190
- end
191
-
192
- it 'config.exist?(:test2) return true.' do
193
- expect(@config.exist?(:test2)).to equal(true)
194
- end
195
- end
196
- end