lorj 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.gitreview +4 -0
  4. data/Gemfile +25 -0
  5. data/Gemfile.lock +34 -0
  6. data/LICENSE.txt +14 -0
  7. data/README.md +652 -0
  8. data/Rakefile +24 -0
  9. data/bin/cloud_test.rb +81 -0
  10. data/example/students_1/process/Students.rb +20 -0
  11. data/example/students_1/students.rb +16 -0
  12. data/example/students_2/process/Students.rb +27 -0
  13. data/example/students_2/students.rb +36 -0
  14. data/example/students_3/controller/yaml_students.rb +94 -0
  15. data/example/students_3/controller/yaml_students_controller.rb +123 -0
  16. data/example/students_3/process/students.rb +118 -0
  17. data/example/students_3/students.rb +93 -0
  18. data/example/students_4/controller/yaml_students.rb +82 -0
  19. data/example/students_4/controller/yaml_students_controller.rb +141 -0
  20. data/example/students_4/process/students.rb +112 -0
  21. data/example/students_4/students.rb +103 -0
  22. data/example/yaml_students/students.rb +78 -0
  23. data/example/yaml_students/yaml_students.rb +115 -0
  24. data/lib/concept.md +111 -0
  25. data/lib/core/core.rb +723 -0
  26. data/lib/core/definition.rb +505 -0
  27. data/lib/core/definition_internal.rb +338 -0
  28. data/lib/core/lorj-basecontroller.rb +90 -0
  29. data/lib/core/lorj-basedefinition.rb +1079 -0
  30. data/lib/core/lorj-baseprocess.rb +231 -0
  31. data/lib/core/lorj-data.rb +567 -0
  32. data/lib/core/lorj-keypath.rb +115 -0
  33. data/lib/core_process/CloudProcess.rb +334 -0
  34. data/lib/core_process/global_process.rb +406 -0
  35. data/lib/core_process/network_process.rb +603 -0
  36. data/lib/img/.directory +4 -0
  37. data/lib/img/account_data_access.png +0 -0
  38. data/lib/img/config_data_access.png +0 -0
  39. data/lib/img/forj-lib-concept.png +0 -0
  40. data/lib/lorj/version.rb +3 -0
  41. data/lib/lorj.rb +51 -0
  42. data/lib/prc-account.rb +339 -0
  43. data/lib/prc-config.rb +1023 -0
  44. data/lib/prc-logging.rb +183 -0
  45. data/lib/prc.rb +108 -0
  46. data/lib/providers/hpcloud/Hpcloud.rb +419 -0
  47. data/lib/providers/hpcloud/compute.rb +108 -0
  48. data/lib/providers/hpcloud/network.rb +117 -0
  49. data/lib/providers/hpcloud/security_groups.rb +67 -0
  50. data/lib/providers/mock/Mock.rb +141 -0
  51. data/lib/providers/openstack/Openstack.rb +47 -0
  52. data/lib/providers/templates/compute.rb +42 -0
  53. data/lib/providers/templates/core.rb +61 -0
  54. data/lib/providers/templates/network.rb +33 -0
  55. data/lorj-spec/defaults.yaml +26 -0
  56. data/lorj.gemspec +39 -0
  57. data/spec/forj-account_spec.rb +75 -0
  58. data/spec/forj-config_spec.rb +196 -0
  59. metadata +164 -0
@@ -0,0 +1,75 @@
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 'rubygems'
19
+ require 'bundler/setup'
20
+
21
+ $APP_PATH = File.dirname(__FILE__)
22
+ $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
23
+
24
+ $LOAD_PATH << $LIB_PATH
25
+
26
+ require 'lorj' # Load lorj framework
27
+
28
+ PrcLib.log_file = 'lorj-rspec.log'
29
+ PrcLib.level = Logger::FATAL
30
+ PrcLib.app_name = 'lorj-spec'
31
+ PrcLib.app_defaults = 'lorj-spec'
32
+
33
+ describe "class: Lorj::Account," do
34
+ context "when creating a new instance," do
35
+
36
+ it 'should be loaded' do
37
+ oForjAccount = Lorj::Account.new()
38
+ expect(oForjAccount).to be
39
+ end
40
+
41
+ it 'should store log data in lorj-rspec.log' do
42
+ expect(PrcLib.log_file).to eq(File.expand_path('lorj-rspec.log'))
43
+ end
44
+
45
+ end
46
+
47
+ context "when starting," do
48
+ before(:all) do
49
+ File.open(File.join(PrcLib.data_path, 'config.yaml'), 'w+') { |file| file.write("default:\n keypair_name: nova_local\n") }
50
+ File.open(File.join(PrcLib.data_path, 'accounts', 'test1'), 'w+') { |file| file.write("credentials:\n keypair_name: nova_test1\n :tenant_name: test\n") }
51
+
52
+ config = Lorj::Config.new()
53
+ config[:account_name] = 'test1'
54
+ @ForjAccount = Lorj::Account.new(config)
55
+ @ForjAccount.ac_load()
56
+ end
57
+
58
+ it 'should be able to read account data' do
59
+ expect(@ForjAccount[:keypair_name]).to eq('nova_test1')
60
+ end
61
+
62
+ it 'should be able to create a key/value in the account config' do
63
+ @ForjAccount.set(:test1, 'value')
64
+ expect(@ForjAccount.get(:test1)).to eq('value')
65
+ @ForjAccount.set(:keypair_name, 'value')
66
+ expect(@ForjAccount.get(:keypair_name)).to eq('value')
67
+ end
68
+
69
+ it 'should be able to delete a key/value in the account config and get default back.' do
70
+ @ForjAccount.del(:keypair_name)
71
+ expect(@ForjAccount.get(:keypair_name)).to eq('nova_local')
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,196 @@
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
+
19
+ $APP_PATH = File.dirname(__FILE__)
20
+ $LIB_PATH = File.expand_path(File.join(File.dirname($APP_PATH),'lib'))
21
+
22
+ $LOAD_PATH << './lib'
23
+
24
+ require 'lorj' # Load lorj framework
25
+
26
+ PrcLib.log_file = 'lorj-rspec.log'
27
+ PrcLib.level = Logger::FATAL
28
+ PrcLib.app_name = 'lorj-spec'
29
+ PrcLib.app_defaults = 'lorj-spec'
30
+
31
+
32
+ describe "class: Lorj::Config," do
33
+ context "when creating a new instance" do
34
+
35
+ it 'should be loaded' do
36
+ @test_config = Lorj::Config.new()
37
+ expect(@test_config).to be
38
+ end
39
+
40
+ end
41
+
42
+ context "when starting, Lorj::Config" do
43
+ before(:all) do
44
+ @config = Lorj::Config.new()
45
+ end
46
+
47
+ it 'should be able to create a key/value in local config' do
48
+ @config.localSet(:test1,'value')
49
+ expect(@config.localGet(:test1)).to eq('value')
50
+ end
51
+
52
+ it 'should be able to remove the previously created key/value from local config' do
53
+ @config.localDel(:test1)
54
+ expect(@config.exist?(:test1)).to equal(false)
55
+ end
56
+ end
57
+
58
+ context "while updating local config file, forj-config" do
59
+ before(:all) do
60
+ @config = Lorj::Config.new()
61
+ end
62
+
63
+ after(:all) do
64
+ @config.localDel(:test1)
65
+ @config.saveConfig()
66
+ end
67
+
68
+ it 'should save a key/value in local config' do
69
+ @config.localSet(:test1,'value')
70
+ expect(@config.saveConfig()).to equal(true)
71
+
72
+ oConfig = Lorj::Config.new()
73
+ expect(@config.localGet(:test1)).to eq('value')
74
+ end
75
+
76
+ end
77
+
78
+ context "With another config file - test1.yaml, forj-config" do
79
+
80
+ before(:all) do
81
+ if File.exists?(File.join(PrcLib.data_path, 'test.yaml'))
82
+ File.delete(File.join(PrcLib.data_path, 'test.yaml'))
83
+ end
84
+ File.open(File.join(PrcLib.data_path, 'test1.yaml'), 'w+') { |file| file.write(":default:\n") }
85
+ @config = Lorj::Config.new('test.yaml')
86
+ @config2 = Lorj::Config.new('test1.yaml')
87
+ end
88
+
89
+ after(:all) do
90
+ File.delete(File.join(PrcLib.data_path, 'test1.yaml'))
91
+ end
92
+
93
+ it 'won\'t create a new file If we request to load \'test.yaml\'' do
94
+ expect(File.exists?(File.join(PrcLib.data_path, 'test.yaml'))).to equal(false)
95
+ end
96
+
97
+ it 'will load the default config file if we request to load \'test.yaml\'' do
98
+ expect(File.basename(@config.sConfigName)).to eq('config.yaml')
99
+ end
100
+
101
+ it 'will confirm \'test1.yaml\' config to be loaded.' do
102
+ expect(File.basename(@config2.sConfigName)).to eq('test1.yaml')
103
+ end
104
+
105
+ it 'can save \'test2=value\'' do
106
+ @config2.localSet('test2','value')
107
+ expect(@config2.saveConfig()).to equal(true)
108
+ config3 = Lorj::Config.new('test1.yaml')
109
+ expect(config3.localGet('test2')).to eq('value')
110
+ end
111
+
112
+ end
113
+
114
+ context "with get/set/exists?," do
115
+ before(:all) do
116
+ @config = Lorj::Config.new()
117
+ @url = @config.get('maestro_url')
118
+ end
119
+
120
+ it 'can set and get data,' do
121
+ expect(@config.set(nil, nil)).to equal(false)
122
+ expect(@config.set(:test, nil)).to equal(true)
123
+ expect(@config.get(:test)).to equal(nil)
124
+
125
+ expect(@config.set(:test, 'data')).to equal(true)
126
+ expect(@config.get(:test)).to eq('data')
127
+ end
128
+
129
+ context 'from defaults,' do
130
+ it 'can get application defaults' do
131
+ expect(@config.get(:maestro_url).class).to equal(String)
132
+ expect(@config.getAppDefault(:default, :maestro_url).class).to equal(String)
133
+ expect(@config.getAppDefault(:description, 'FORJ_HPC').class).to equal(String)
134
+
135
+ end
136
+ it 'can get Local defaults instead of application' do
137
+ expect(@config.localSet(:maestro_url,'local')).to equal(true)
138
+ expect(@config.localGet(:maestro_url)).to eq('local')
139
+ expect(@config.get(:maestro_url)).to eq('local')
140
+ end
141
+
142
+ it 'can get runtime defaults instead of Local/application' do
143
+ expect(@config.set(:maestro_url, 'runtime')).to equal(true)
144
+ expect(@config.get(:maestro_url)).to eq('runtime')
145
+ expect(@config.localGet(:maestro_url)).to eq('local')
146
+ end
147
+
148
+ it 'can get runtime defaults instead of application' do
149
+ expect(@config.localDel(:maestro_url)).to equal(true)
150
+ expect(@config.get(:maestro_url)).to eq('runtime')
151
+ expect(@config.localGet(:maestro_url)).to equal(nil)
152
+ end
153
+
154
+ it 'can get defaults if no key' do
155
+ expect(@config.set(:test1, nil)).to equal(true)
156
+ expect(@config.get(:test1, 'default')).to eq('default')
157
+ expect(@config.get(:test1, nil)).to equal(nil)
158
+ expect(@config.set(:maestro_url,nil)).to equal(true)
159
+ expect(@config.get(:maestro_url)).to eq(@url)
160
+ end
161
+ end
162
+
163
+ end
164
+ end
165
+
166
+ describe 'Recursive Hash functions,' do
167
+ context "With recursive Hash functions" do
168
+ it 'can create a 3 levels of hash' do
169
+ yYAML = Lorj.rhSet(nil, 'level4', :level1, :level2, :level3)
170
+ expect(yYAML[:level1][:level2][:level3]).to eq('level4')
171
+ end
172
+
173
+ it 'can add a 3 levels of hash in an existing hash' do
174
+ yYAML = Lorj.rhSet(nil, 'level4', :level1, :level2, :level3)
175
+ yYAML = Lorj.rhSet(yYAML, 'level1.1', :level1_1)
176
+ expect(yYAML[:level1][:level2][:level3]).to eq('level4')
177
+ expect(yYAML[:level1_1]).to eq('level1.1')
178
+ end
179
+
180
+ it 'can get each levels of hash data' do
181
+ yYAML = Lorj.rhSet(nil, 'level4', :level1, :level2, :level3)
182
+ expect(Lorj.rhGet(yYAML, :level1).class).to equal(Hash)
183
+ expect(Lorj.rhGet(yYAML, :level1, :level2).class).to equal(Hash)
184
+ expect(Lorj.rhGet(yYAML, :level1, :level2, :level3).class).to equal(String)
185
+ end
186
+
187
+ it 'can check existence of each levels of hash data' do
188
+ yYAML = Lorj.rhSet(nil, 'level4', :level1, :level2, :level3)
189
+ expect(Lorj.rhExist?(yYAML, :level1)).to eq(1)
190
+ expect(Lorj.rhExist?(yYAML, :level1, :level2)).to eq(2)
191
+ expect(Lorj.rhExist?(yYAML, :level1, :level2, :level3)).to eq(3)
192
+ expect(Lorj.rhExist?(yYAML, :level1_1, :level2, :level3)).to eq(0)
193
+
194
+ end
195
+ end
196
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lorj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - forj team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: ansi
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.4.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.4.3
69
+ description: Framework to create/maintain uniform process, against any kind of controller.
70
+ email:
71
+ - forj@forj.io
72
+ executables:
73
+ - cloud_test.rb
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .gitreview
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/cloud_test.rb
85
+ - example/students_1/process/Students.rb
86
+ - example/students_1/students.rb
87
+ - example/students_2/process/Students.rb
88
+ - example/students_2/students.rb
89
+ - example/students_3/controller/yaml_students.rb
90
+ - example/students_3/controller/yaml_students_controller.rb
91
+ - example/students_3/process/students.rb
92
+ - example/students_3/students.rb
93
+ - example/students_4/controller/yaml_students.rb
94
+ - example/students_4/controller/yaml_students_controller.rb
95
+ - example/students_4/process/students.rb
96
+ - example/students_4/students.rb
97
+ - example/yaml_students/students.rb
98
+ - example/yaml_students/yaml_students.rb
99
+ - lib/concept.md
100
+ - lib/core/core.rb
101
+ - lib/core/definition.rb
102
+ - lib/core/definition_internal.rb
103
+ - lib/core/lorj-basecontroller.rb
104
+ - lib/core/lorj-basedefinition.rb
105
+ - lib/core/lorj-baseprocess.rb
106
+ - lib/core/lorj-data.rb
107
+ - lib/core/lorj-keypath.rb
108
+ - lib/core_process/CloudProcess.rb
109
+ - lib/core_process/global_process.rb
110
+ - lib/core_process/network_process.rb
111
+ - lib/img/.directory
112
+ - lib/img/account_data_access.png
113
+ - lib/img/config_data_access.png
114
+ - lib/img/forj-lib-concept.png
115
+ - lib/lorj.rb
116
+ - lib/lorj/version.rb
117
+ - lib/prc-account.rb
118
+ - lib/prc-config.rb
119
+ - lib/prc-logging.rb
120
+ - lib/prc.rb
121
+ - lib/providers/hpcloud/Hpcloud.rb
122
+ - lib/providers/hpcloud/compute.rb
123
+ - lib/providers/hpcloud/network.rb
124
+ - lib/providers/hpcloud/security_groups.rb
125
+ - lib/providers/mock/Mock.rb
126
+ - lib/providers/openstack/Openstack.rb
127
+ - lib/providers/templates/compute.rb
128
+ - lib/providers/templates/core.rb
129
+ - lib/providers/templates/network.rb
130
+ - lorj-spec/defaults.yaml
131
+ - lorj.gemspec
132
+ - spec/forj-account_spec.rb
133
+ - spec/forj-config_spec.rb
134
+ homepage: https://github.com/forj-oss/lorj
135
+ licenses:
136
+ - Apache License, Version 2.0.
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options:
140
+ - --title
141
+ - Lorj - The Process Controllers framework system
142
+ - --main
143
+ - README.md
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.1.11
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Process Controllers framework system
162
+ test_files:
163
+ - spec/forj-account_spec.rb
164
+ - spec/forj-config_spec.rb