lorj 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/example/students_1/process/students.rb +1 -1
- data/example/students_1/student_v1.md +2 -0
- data/example/students_1/students.rb +2 -1
- data/example/students_2/process/students.rb +1 -1
- data/example/students_2/students.rb +4 -2
- data/example/students_3/controller/yaml_students_def.rb +1 -1
- data/example/students_3/process/students.rb +1 -1
- data/example/students_3/student_v3.md +5 -3
- data/example/students_3/students.rb +5 -3
- data/example/students_4/controller/yaml_students_def.rb +1 -1
- data/example/students_4/process/students/definition/students.rb +1 -1
- data/example/students_4/students.rb +5 -3
- data/example/students_5/controller/yaml_students.rb +1 -1
- data/example/students_5/process/students.rb +1 -1
- data/example/students_5/student_v5.md +4 -4
- data/example/students_5/students.rb +8 -7
- data/example/yaml_students/students.rb +4 -4
- data/lib/core/core.rb +110 -64
- data/lib/core/core_internal.rb +110 -15
- data/lib/core/core_object_data.rb +4 -4
- data/lib/core/core_process_setup.rb +3 -30
- data/lib/core/lorj_data.rb +1 -1
- data/lib/core/lorj_keypath.rb +3 -1
- data/lib/core/process.rb +67 -0
- data/lib/lorj/version.rb +2 -1
- data/lib/lorj.rb +3 -4
- data/lib/lorj_account.rb +6 -5
- data/lib/lorj_config.rb +3 -2
- data/lib/providers/templates/compute.rb +1 -1
- data/lorj-spec/controllers/mock/mock.rb +144 -0
- data/lorj-spec/data.yaml +0 -0
- data/lorj-spec/process/mock2_process.rb +48 -0
- data/lorj-spec/process/mock_process.rb +48 -0
- data/lorj-spec/providers/mock2/mock2.rb +0 -0
- data/lorj.gemspec +2 -4
- data/spec/05_lorj_keypath_spec.rb +78 -0
- data/spec/20_lorj_meta_spec.rb +1 -1
- data/spec/21_lorj_processes_spec.rb +115 -0
- metadata +27 -42
- data/lib/core_process/cloud/process/common.rb +0 -60
- data/lib/core_process/cloud/process/connection.rb +0 -92
- data/lib/core_process/cloud/process/external_network.rb +0 -90
- data/lib/core_process/cloud/process/flavor.rb +0 -97
- data/lib/core_process/cloud/process/images.rb +0 -99
- data/lib/core_process/cloud/process/internet_network.rb +0 -33
- data/lib/core_process/cloud/process/internet_server.rb +0 -29
- data/lib/core_process/cloud/process/keypairs.rb +0 -332
- data/lib/core_process/cloud/process/network.rb +0 -107
- data/lib/core_process/cloud/process/public_ip.rb +0 -102
- data/lib/core_process/cloud/process/router.rb +0 -267
- data/lib/core_process/cloud/process/rules.rb +0 -120
- data/lib/core_process/cloud/process/security_groups.rb +0 -120
- data/lib/core_process/cloud/process/server.rb +0 -126
- data/lib/core_process/cloud/process/server_log.rb +0 -34
- data/lib/core_process/cloud/process/subnetwork.rb +0 -96
- data/lib/core_process/cloud_process.rb +0 -30
- data/lib/prc_base_config.rb +0 -300
- data/lib/prc_core_config.rb +0 -1258
- data/lib/prc_section_config.rb +0 -90
- data/lib/providers/hpcloud/compute.rb +0 -105
- data/lib/providers/hpcloud/hpcloud.rb +0 -462
- data/lib/providers/hpcloud/network.rb +0 -115
- data/lib/providers/hpcloud/security_groups.rb +0 -68
- data/lib/providers/openstack/openstack.rb +0 -410
- data/lib/providers/openstack/openstack_create.rb +0 -205
- data/lib/providers/openstack/openstack_delete.rb +0 -28
- data/lib/providers/openstack/openstack_get.rb +0 -39
- data/lib/providers/openstack/openstack_process.rb +0 -26
- data/lib/providers/openstack/openstack_query.rb +0 -96
- data/lib/providers/openstack/openstack_update.rb +0 -35
- data/lib/rh.rb +0 -426
- data/spec/01_hash_rh_spec.rb +0 -282
- data/spec/02_prc_base_config_spec.rb +0 -227
- data/spec/03_prc_section_config_spec.rb +0 -196
- data/spec/04_prc_core_config_spec.rb +0 -325
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Students process
|
18
|
+
class StudentsProcess
|
19
|
+
def create_student(sObjectType, hParams)
|
20
|
+
PrcLib.state(format("Running creation process for object '%s' = '%s'",
|
21
|
+
sObjectType, hParams[:student_name]))
|
22
|
+
# byebug if ENV['BYEBUG'] # rubocop: disable Debugger
|
23
|
+
object = controller_create(sObjectType)
|
24
|
+
PrcLib.runtime_fail "Student '%s' not created.",
|
25
|
+
hParams[:student_name] if object.nil?
|
26
|
+
PrcLib.info("'%s': '%s' created with id %s",
|
27
|
+
sObjectType, hParams[:student_name], object[:id])
|
28
|
+
object
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Declaring your data model and handlers.
|
33
|
+
class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
|
34
|
+
# We need to define the student object and the handler to use while we need to
|
35
|
+
# create it.
|
36
|
+
define_obj(:student,
|
37
|
+
# The function to call in the class Students
|
38
|
+
:create_e => :create_student,
|
39
|
+
# We use predefined call to the controller query
|
40
|
+
:query_e => :controller_query,
|
41
|
+
# We use predefined call to the controller get
|
42
|
+
:get_e => :controller_get,
|
43
|
+
# We use predefined call to the controller delete
|
44
|
+
:delete_e => :controller_delete
|
45
|
+
)
|
46
|
+
|
47
|
+
obj_needs :data, :student_name, :for => [:create_e], :mapping => :name
|
48
|
+
end
|
File without changes
|
data/lorj.gemspec
CHANGED
@@ -11,6 +11,7 @@ less_than_two = ruby_conf['MAJOR'].to_i < 2
|
|
11
11
|
Gem::Specification.new do |spec|
|
12
12
|
spec.name = 'lorj'
|
13
13
|
spec.version = Lorj::VERSION
|
14
|
+
spec.date = Lorj::DATE
|
14
15
|
spec.authors = ['forj team']
|
15
16
|
spec.email = ['forj@forj.io']
|
16
17
|
spec.summary = 'Process Controllers framework system'
|
@@ -35,10 +36,7 @@ Gem::Specification.new do |spec|
|
|
35
36
|
'--title Lorj - The Process Controllers framework system' << \
|
36
37
|
'--main README.md'
|
37
38
|
|
38
|
-
|
39
|
-
# spec.add_runtime_dependency 'nokogiri', '~>1.5.11'
|
40
|
-
# spec.add_runtime_dependency 'fog', '~>1.19.0'
|
41
|
-
# spec.add_runtime_dependency 'hpcloud', '~>2.0.9'
|
39
|
+
spec.add_runtime_dependency 'config_layers', '~>0.1.0'
|
42
40
|
# spec.add_runtime_dependency 'git', '>=1.2.7'
|
43
41
|
# spec.add_runtime_dependency 'rbx-require-relative', '~>0.0.7'
|
44
42
|
spec.add_runtime_dependency 'highline', '~> 1.6.21'
|
@@ -0,0 +1,78 @@
|
|
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/core')
|
21
|
+
|
22
|
+
require 'lorj_keypath'
|
23
|
+
|
24
|
+
describe 'Lorj::KeyPath,' do
|
25
|
+
context 'initialize with :test' do
|
26
|
+
before(:all) do
|
27
|
+
@o_key = Lorj::KeyPath.new(:test)
|
28
|
+
end
|
29
|
+
it 'Test method #to_s' do
|
30
|
+
expect(@o_key.to_s).to eq('test')
|
31
|
+
end
|
32
|
+
it 'Test method #key' do
|
33
|
+
expect(@o_key.key).to eq(:test)
|
34
|
+
end
|
35
|
+
it 'Test method #key(0)' do
|
36
|
+
expect(@o_key.key(0)).to eq(:test)
|
37
|
+
end
|
38
|
+
it 'Test method #key(1)' do
|
39
|
+
expect(@o_key.key(1)).to eq(nil)
|
40
|
+
end
|
41
|
+
it 'Test method #fpath' do
|
42
|
+
expect(@o_key.fpath).to eq(':test')
|
43
|
+
end
|
44
|
+
it 'Test method #tree' do
|
45
|
+
expect(@o_key.key).to eq(:test)
|
46
|
+
end
|
47
|
+
it 'Test method #key_tree' do
|
48
|
+
expect(@o_key.key).to eq(:test)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'initialize with [:test,:test2,:test3]' do
|
53
|
+
before(:all) do
|
54
|
+
@o_key = Lorj::KeyPath.new([:test, :test2, :test3])
|
55
|
+
end
|
56
|
+
it 'Test method #to_s' do
|
57
|
+
expect(@o_key.to_s).to eq('test/test2/test3')
|
58
|
+
end
|
59
|
+
it 'Test method #key' do
|
60
|
+
expect(@o_key.key).to eq(:test3)
|
61
|
+
end
|
62
|
+
it 'Test method #key(0)' do
|
63
|
+
expect(@o_key.key(0)).to eq(:test)
|
64
|
+
end
|
65
|
+
it 'Test method #key(1)' do
|
66
|
+
expect(@o_key.key(1)).to eq(:test2)
|
67
|
+
end
|
68
|
+
it 'Test method #fpath' do
|
69
|
+
expect(@o_key.fpath).to eq(':test/:test2/:test3')
|
70
|
+
end
|
71
|
+
it 'Test method #tree' do
|
72
|
+
expect(@o_key.tree).to eq([:test, :test2, :test3])
|
73
|
+
end
|
74
|
+
it 'Test method #key_tree' do
|
75
|
+
expect(@o_key.key_tree).to eq(':test/:test2/:test3')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/20_lorj_meta_spec.rb
CHANGED
@@ -237,7 +237,7 @@ YAMLDOC
|
|
237
237
|
'returns :option1 => :value1' do
|
238
238
|
expect(@metadata.where?(:any, :kind_of, :data1, :option1)).to equal(false)
|
239
239
|
expect(@metadata.set(:any, :kind_of, :data1, :option1 => :value1
|
240
|
-
|
240
|
+
)).to eq(:option1 => :value1)
|
241
241
|
expect(@metadata.where?(:any, :kind_of, :data1,
|
242
242
|
:option1)).to eq(['controller'])
|
243
243
|
end
|
@@ -0,0 +1,115 @@
|
|
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 'byebug'
|
20
|
+
# require 'debugger'
|
21
|
+
# require 'bundler/setup'
|
22
|
+
|
23
|
+
app_path = File.dirname(__FILE__)
|
24
|
+
|
25
|
+
$LOAD_PATH << File.join(app_path, '..', 'lib')
|
26
|
+
|
27
|
+
require 'lorj' # Load lorj framework
|
28
|
+
|
29
|
+
describe 'Lorj::Process,' do
|
30
|
+
context 'with mock initialized,' do
|
31
|
+
before(:all) do
|
32
|
+
@lorj_spec = 'lorj-spec'
|
33
|
+
@process_path = File.expand_path(File.join(app_path, '..', @lorj_spec))
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'default initialization is ok' do
|
37
|
+
process_file = File.join(@process_path, 'process', 'mock_process.rb')
|
38
|
+
controllers = { 'mock' => File.join(@process_path, 'controllers',
|
39
|
+
'mock', 'mock.rb') }
|
40
|
+
default = File.join(@process_path, 'defaults.yaml')
|
41
|
+
data = File.join(@process_path, 'data.yaml')
|
42
|
+
process_data = Lorj::ProcessResource.new('mock', File.join(app_path,
|
43
|
+
'..',
|
44
|
+
@lorj_spec))
|
45
|
+
expect(process_data).to be
|
46
|
+
expect(process_data.name).to eq('mock')
|
47
|
+
expect(process_data.process).to eq(process_file)
|
48
|
+
expect(process_data.controllers).to eq(controllers)
|
49
|
+
expect(process_data.defaults_file).to eq(default)
|
50
|
+
expect(process_data.data_file).to eq(data)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'reports missing elements not set' do
|
54
|
+
process_data = Lorj::ProcessResource.new('mock', app_path)
|
55
|
+
expect(process_data).to be
|
56
|
+
expect(process_data.name).to equal(nil)
|
57
|
+
expect(process_data.process).to equal(nil)
|
58
|
+
expect(process_data.controllers).to equal(nil)
|
59
|
+
expect(process_data.defaults_file).to equal(nil)
|
60
|
+
expect(process_data.data_file).to equal(nil)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts symbol as name, but converted.' do
|
64
|
+
process_file = File.join(@process_path, 'process', 'mock_process.rb')
|
65
|
+
controllers = { 'mock' => File.join(@process_path, 'controllers',
|
66
|
+
'mock', 'mock.rb') }
|
67
|
+
default = File.join(@process_path, 'defaults.yaml')
|
68
|
+
data = File.join(@process_path, 'data.yaml')
|
69
|
+
process_data = Lorj::ProcessResource.new(:mock, File.join(app_path, '..',
|
70
|
+
@lorj_spec))
|
71
|
+
expect(process_data).to be
|
72
|
+
expect(process_data.name).to eq('mock')
|
73
|
+
expect(process_data.process).to eq(process_file)
|
74
|
+
expect(process_data.controllers).to eq(controllers)
|
75
|
+
expect(process_data.defaults_file).to eq(default)
|
76
|
+
expect(process_data.data_file).to eq(data)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'initialization with :controllers_dir is ok' do
|
80
|
+
process_file = File.join(@process_path, 'process', 'mock_process.rb')
|
81
|
+
controllers = { 'mock2' => File.join(@process_path, 'providers',
|
82
|
+
'mock2', 'mock2.rb') }
|
83
|
+
default = File.join(@process_path, 'defaults.yaml')
|
84
|
+
data = File.join(@process_path, 'data.yaml')
|
85
|
+
process_data = Lorj::ProcessResource.new('mock', @process_path,
|
86
|
+
:controllers_dir => 'providers')
|
87
|
+
expect(process_data).to be
|
88
|
+
expect(process_data.name).to eq('mock')
|
89
|
+
expect(process_data.process).to eq(process_file)
|
90
|
+
expect(process_data.controllers).to eq(controllers)
|
91
|
+
expect(process_data.defaults_file).to eq(default)
|
92
|
+
expect(process_data.data_file).to eq(data)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'can declare a module process' do
|
96
|
+
expect(Lorj.declare_process('mock', @process_path)).to be
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'kept module in Lorj.processes' do
|
100
|
+
expect(Lorj.processes.key?('mock')).to equal(true)
|
101
|
+
expect(Lorj.processes['mock'].class).to equal(Lorj::ProcessResource)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'can declare several module processes' do
|
105
|
+
expect(Lorj.declare_process('mock', @process_path)).to be
|
106
|
+
expect(Lorj.declare_process(:mock2, @process_path)).to be
|
107
|
+
expect(Lorj.declare_process('mock3', @process_path)).to equal(nil)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'all kept module processes in Lorj.processes not duplicated.' do
|
111
|
+
expect(Lorj.processes.length).to eq(2)
|
112
|
+
expect(Lorj.processes.keys).to eq(%w(mock mock2))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- forj team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: config_layers
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: highline
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +148,7 @@ extra_rdoc_files: []
|
|
134
148
|
files:
|
135
149
|
- .gitignore
|
136
150
|
- .gitreview
|
151
|
+
- .rspec
|
137
152
|
- .rubocop.yml
|
138
153
|
- Gemfile
|
139
154
|
- LICENSE.txt
|
@@ -187,23 +202,7 @@ files:
|
|
187
202
|
- lib/core/lorj_baseprocess.rb
|
188
203
|
- lib/core/lorj_data.rb
|
189
204
|
- lib/core/lorj_keypath.rb
|
190
|
-
- lib/
|
191
|
-
- lib/core_process/cloud/process/connection.rb
|
192
|
-
- lib/core_process/cloud/process/external_network.rb
|
193
|
-
- lib/core_process/cloud/process/flavor.rb
|
194
|
-
- lib/core_process/cloud/process/images.rb
|
195
|
-
- lib/core_process/cloud/process/internet_network.rb
|
196
|
-
- lib/core_process/cloud/process/internet_server.rb
|
197
|
-
- lib/core_process/cloud/process/keypairs.rb
|
198
|
-
- lib/core_process/cloud/process/network.rb
|
199
|
-
- lib/core_process/cloud/process/public_ip.rb
|
200
|
-
- lib/core_process/cloud/process/router.rb
|
201
|
-
- lib/core_process/cloud/process/rules.rb
|
202
|
-
- lib/core_process/cloud/process/security_groups.rb
|
203
|
-
- lib/core_process/cloud/process/server.rb
|
204
|
-
- lib/core_process/cloud/process/server_log.rb
|
205
|
-
- lib/core_process/cloud/process/subnetwork.rb
|
206
|
-
- lib/core_process/cloud_process.rb
|
205
|
+
- lib/core/process.rb
|
207
206
|
- lib/img/.directory
|
208
207
|
- lib/img/account_data_access.png
|
209
208
|
- lib/img/config_data_access.png
|
@@ -217,37 +216,25 @@ files:
|
|
217
216
|
- lib/lorj_meta.rb
|
218
217
|
- lib/overview.md
|
219
218
|
- lib/prc.rb
|
220
|
-
- lib/prc_base_config.rb
|
221
|
-
- lib/prc_core_config.rb
|
222
|
-
- lib/prc_section_config.rb
|
223
|
-
- lib/providers/hpcloud/compute.rb
|
224
|
-
- lib/providers/hpcloud/hpcloud.rb
|
225
|
-
- lib/providers/hpcloud/network.rb
|
226
|
-
- lib/providers/hpcloud/security_groups.rb
|
227
219
|
- lib/providers/mock/mock.rb
|
228
|
-
- lib/providers/openstack/openstack.rb
|
229
|
-
- lib/providers/openstack/openstack_create.rb
|
230
|
-
- lib/providers/openstack/openstack_delete.rb
|
231
|
-
- lib/providers/openstack/openstack_get.rb
|
232
|
-
- lib/providers/openstack/openstack_process.rb
|
233
|
-
- lib/providers/openstack/openstack_query.rb
|
234
|
-
- lib/providers/openstack/openstack_update.rb
|
235
220
|
- lib/providers/templates/compute.rb
|
236
221
|
- lib/providers/templates/mycloud.rb
|
237
222
|
- lib/providers/templates/network.rb
|
238
|
-
-
|
223
|
+
- lorj-spec/controllers/mock/mock.rb
|
224
|
+
- lorj-spec/data.yaml
|
239
225
|
- lorj-spec/defaults.yaml
|
226
|
+
- lorj-spec/process/mock2_process.rb
|
227
|
+
- lorj-spec/process/mock_process.rb
|
228
|
+
- lorj-spec/providers/mock2/mock2.rb
|
240
229
|
- lorj.gemspec
|
241
|
-
- spec/
|
242
|
-
- spec/02_prc_base_config_spec.rb
|
243
|
-
- spec/03_prc_section_config_spec.rb
|
244
|
-
- spec/04_prc_core_config_spec.rb
|
230
|
+
- spec/05_lorj_keypath_spec.rb
|
245
231
|
- spec/09_prc_spec.rb
|
246
232
|
- spec/10_lorj_log_spec.rb
|
247
233
|
- spec/11_lorj_defaults_spec.rb
|
248
234
|
- spec/12_lorj_config_spec.rb
|
249
235
|
- spec/13_lorj_account_spec.rb
|
250
236
|
- spec/20_lorj_meta_spec.rb
|
237
|
+
- spec/21_lorj_processes_spec.rb
|
251
238
|
homepage: https://github.com/forj-oss/lorj
|
252
239
|
licenses:
|
253
240
|
- Apache License, Version 2.0.
|
@@ -275,14 +262,12 @@ signing_key:
|
|
275
262
|
specification_version: 4
|
276
263
|
summary: Process Controllers framework system
|
277
264
|
test_files:
|
278
|
-
- spec/
|
279
|
-
- spec/02_prc_base_config_spec.rb
|
280
|
-
- spec/03_prc_section_config_spec.rb
|
281
|
-
- spec/04_prc_core_config_spec.rb
|
265
|
+
- spec/05_lorj_keypath_spec.rb
|
282
266
|
- spec/09_prc_spec.rb
|
283
267
|
- spec/10_lorj_log_spec.rb
|
284
268
|
- spec/11_lorj_defaults_spec.rb
|
285
269
|
- spec/12_lorj_config_spec.rb
|
286
270
|
- spec/13_lorj_account_spec.rb
|
287
271
|
- spec/20_lorj_meta_spec.rb
|
272
|
+
- spec/21_lorj_processes_spec.rb
|
288
273
|
has_rdoc:
|
@@ -1,60 +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
|
-
# It requires Core objects to be defined + default ForjProcess functions.
|
19
|
-
|
20
|
-
# Common definition
|
21
|
-
class Lorj::BaseDefinition # rubocop: disable Style/ClassAndModuleChildren
|
22
|
-
# All objects used by this process are built from a Controller
|
23
|
-
process_default :use_controller => true
|
24
|
-
end
|
25
|
-
|
26
|
-
# Class to manage retry on errors before failing
|
27
|
-
class SSLErrorMgt
|
28
|
-
def initialize(iMaxRetry = 5)
|
29
|
-
@retry = 0
|
30
|
-
@max_retry = iMaxRetry
|
31
|
-
end
|
32
|
-
|
33
|
-
def wait(message, issue = nil)
|
34
|
-
if @retry < @max_retry
|
35
|
-
sleep(2)
|
36
|
-
@retry += 1
|
37
|
-
if PrcLib.level == 0
|
38
|
-
msg = format('%s/%s try... ', @retry, @max_retry)
|
39
|
-
msg += issue unless issue.nil?
|
40
|
-
print msg
|
41
|
-
end
|
42
|
-
return false
|
43
|
-
else
|
44
|
-
PrcLib.error('Too many retry. %s', message)
|
45
|
-
return true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def error_detected(message, backtrace, e)
|
50
|
-
if message.match('SSLv2/v3 read server hello A: unknown protocol')
|
51
|
-
return wait(message, "'unknown protocol' SSL Error")
|
52
|
-
elsif e.is_a?(Excon::Errors::InternalServerError)
|
53
|
-
return wait(message, ANSI.red(e.class))
|
54
|
-
else
|
55
|
-
PrcLib.error("Exception %s: %s\n%s", e.class, message,
|
56
|
-
backtrace.join("\n"))
|
57
|
-
return true
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,92 +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
|
-
# It requires Core objects to be defined + default ForjProcess functions.
|
19
|
-
|
20
|
-
# rubocop: disable Style/ClassAndModuleChildren
|
21
|
-
|
22
|
-
# Connection process code
|
23
|
-
class CloudProcess
|
24
|
-
def connect(sCloudObj, hParams)
|
25
|
-
ssl_error_obj = SSLErrorMgt.new # Retry object
|
26
|
-
PrcLib.debug("%s:%s Connecting to '%s' "\
|
27
|
-
"- Project '%s'",
|
28
|
-
self.class, sCloudObj, config[:provider], hParams[:tenant])
|
29
|
-
begin
|
30
|
-
controller_connect(sCloudObj)
|
31
|
-
rescue => e
|
32
|
-
retry unless ssl_error_obj.error_detected(e.message, e.backtrace, e)
|
33
|
-
|
34
|
-
PrcLib.error('%s:%s: Unable to connect.\n%s',
|
35
|
-
self.class, sCloudObj, e.message)
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Define services model
|
42
|
-
class Lorj::BaseDefinition
|
43
|
-
# predefined list of objects.
|
44
|
-
# Links between objects is not predefined. To do it, use needs declaration
|
45
|
-
# in your provider class.
|
46
|
-
|
47
|
-
# object to get list of services
|
48
|
-
# Defines Process handler to call
|
49
|
-
define_obj(:services,
|
50
|
-
|
51
|
-
:create_e => :connect
|
52
|
-
)
|
53
|
-
obj_needs :data, :auth_uri
|
54
|
-
obj_needs :data, :account_id
|
55
|
-
obj_needs :data, :account_key
|
56
|
-
obj_needs :data, :tenant
|
57
|
-
|
58
|
-
undefine_attribute :id # Do not return any predefined ID
|
59
|
-
undefine_attribute :name # Do not return any predefined NAME
|
60
|
-
end
|
61
|
-
|
62
|
-
# compute_connection
|
63
|
-
class Lorj::BaseDefinition
|
64
|
-
define_obj(:compute_connection,
|
65
|
-
|
66
|
-
:create_e => :connect # Will call ForjProcess connect
|
67
|
-
)
|
68
|
-
obj_needs :data, :account_id
|
69
|
-
obj_needs :data, :account_key
|
70
|
-
obj_needs :data, :auth_uri
|
71
|
-
obj_needs :data, :tenant
|
72
|
-
obj_needs :data, :compute
|
73
|
-
|
74
|
-
undefine_attribute :id # Do not return any predefined ID
|
75
|
-
undefine_attribute :name # Do not return any predefined NAME
|
76
|
-
end
|
77
|
-
|
78
|
-
# network_connection
|
79
|
-
class Lorj::BaseDefinition
|
80
|
-
define_obj(:network_connection,
|
81
|
-
|
82
|
-
:create_e => :connect
|
83
|
-
)
|
84
|
-
obj_needs :data, :account_id
|
85
|
-
obj_needs :data, :account_key
|
86
|
-
obj_needs :data, :auth_uri
|
87
|
-
obj_needs :data, :tenant
|
88
|
-
obj_needs :data, :network
|
89
|
-
|
90
|
-
undefine_attribute :id # Do not return any predefined ID
|
91
|
-
undefine_attribute :name # Do not return any predefined NAME
|
92
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
# It requires Core objects to be defined + default ForjProcess functions.
|
18
|
-
|
19
|
-
# rubocop: disable Style/ClassAndModuleChildren
|
20
|
-
|
21
|
-
# External network process attached to a network
|
22
|
-
class CloudProcess
|
23
|
-
def forj_get_or_create_ext_net(sCloudObj, hParams)
|
24
|
-
PrcLib.state("Checking router '%s' gateway", hParams[:router, :name])
|
25
|
-
|
26
|
-
router_obj = hParams[:router]
|
27
|
-
router_name = hParams[:router, :name]
|
28
|
-
network_id = hParams[:router, :gateway_network_id]
|
29
|
-
if network_id
|
30
|
-
external_network = forj_query_external_network(sCloudObj,
|
31
|
-
{ :id => network_id },
|
32
|
-
hParams)
|
33
|
-
PrcLib.info("Router '%s' is attached to the "\
|
34
|
-
"external gateway '%s'.", router_name,
|
35
|
-
external_network[:name])
|
36
|
-
else
|
37
|
-
PrcLib.info("Router '%s' needs to be attached to an "\
|
38
|
-
'external gateway.', router_name)
|
39
|
-
PrcLib.state('Attaching')
|
40
|
-
external_network = forj_query_external_network(:network, {}, hParams)
|
41
|
-
if !external_network.empty?
|
42
|
-
router_obj[:gateway_network_id] = external_network[:id]
|
43
|
-
controller_update(:router, router_obj)
|
44
|
-
PrcLib.info("Router '%s' attached to the "\
|
45
|
-
"external network '%s'.",
|
46
|
-
router_name, external_network[:name])
|
47
|
-
else
|
48
|
-
PrcLib.fatal(1, "Unable to attach router '%s' to an external gateway. "\
|
49
|
-
'Required for boxes to get internet access. ',
|
50
|
-
get_data(:router, :name))
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Need to keep the :network object as :external_network object type.
|
55
|
-
external_network.type = sCloudObj
|
56
|
-
external_network
|
57
|
-
end
|
58
|
-
|
59
|
-
def forj_query_external_network(_sCloudObj, sQuery, _hParams)
|
60
|
-
PrcLib.state('Identifying External gateway')
|
61
|
-
begin
|
62
|
-
# Searching for external network
|
63
|
-
query = sQuery.merge(:external => true)
|
64
|
-
info = {
|
65
|
-
:notfound => 'No external network found',
|
66
|
-
:checkmatch => 'Found 1 %s. Checking if it is an %s.',
|
67
|
-
:nomatch => 'No %s identified as %s match',
|
68
|
-
:found => "Found external %s '%s'.",
|
69
|
-
:more => 'Found several %s. Searching for the first one to be an %s.'
|
70
|
-
}
|
71
|
-
networks = query_single(:network, query, 'external network', info)
|
72
|
-
return Lorj::Data.new if networks.length == 0
|
73
|
-
networks[0]
|
74
|
-
rescue => e
|
75
|
-
PrcLib.error("%s\n%s", e.message, e.backtrace.join("\n"))
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# Identify an external network thanks to the network router.
|
81
|
-
class Lorj::BaseDefinition
|
82
|
-
define_obj(:external_network,
|
83
|
-
|
84
|
-
:create_e => :forj_get_or_create_ext_net,
|
85
|
-
:query_e => :forj_query_external_network
|
86
|
-
)
|
87
|
-
|
88
|
-
obj_needs :CloudObject, :network_connection
|
89
|
-
obj_needs :CloudObject, :router
|
90
|
-
end
|