lorj 0.2.0 → 1.0.0
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/.gitignore +1 -0
- data/.rubocop.yml +46 -0
- data/Gemfile +15 -15
- data/README.md +22 -17
- data/Rakefile +12 -2
- data/bin/cloud_test.rb +13 -65
- data/example/students_1/process/students.rb +39 -0
- data/example/students_1/students.rb +22 -5
- data/example/students_2/process/students.rb +48 -0
- data/example/students_2/students.rb +39 -16
- data/example/students_3/controller/yaml_students.rb +50 -43
- data/example/students_3/controller/yaml_students_controller.rb +100 -87
- data/example/students_3/process/students.rb +161 -97
- data/example/students_3/students.rb +85 -56
- data/example/yaml_students/students.rb +40 -40
- data/example/yaml_students/yaml_students.rb +103 -90
- data/lib/core/core.rb +356 -696
- data/lib/core/core_controller.rb +227 -0
- data/lib/core/core_internal.rb +339 -0
- data/lib/core/core_model.rb +328 -0
- data/lib/core/core_object_data.rb +330 -0
- data/lib/core/core_object_params.rb +230 -0
- data/lib/core/core_process.rb +391 -0
- data/lib/core/core_process_setup.rb +353 -0
- data/lib/core/core_setup_ask.rb +241 -0
- data/lib/core/core_setup_encrypt.rb +146 -0
- data/lib/core/core_setup_init.rb +229 -0
- data/lib/core/core_setup_list.rb +160 -0
- data/lib/core/definition.rb +647 -469
- data/lib/core/definition_internal.rb +264 -308
- data/lib/core/lorj_basecontroller.rb +95 -0
- data/lib/core/lorj_basedefinition.rb +307 -0
- data/lib/core/lorj_baseprocess.rb +265 -0
- data/lib/core/lorj_data.rb +583 -0
- data/lib/core/lorj_keypath.rb +119 -0
- data/lib/core_process/cloud/process/common.rb +63 -0
- data/lib/core_process/cloud/process/connection.rb +93 -0
- data/lib/core_process/cloud/process/external_network.rb +94 -0
- data/lib/core_process/cloud/process/flavor.rb +99 -0
- data/lib/core_process/cloud/process/images.rb +87 -0
- data/lib/core_process/cloud/process/internet_network.rb +34 -0
- data/lib/core_process/cloud/process/internet_server.rb +30 -0
- data/lib/core_process/cloud/process/keypairs.rb +276 -0
- data/lib/core_process/cloud/process/network.rb +108 -0
- data/lib/core_process/cloud/process/public_ip.rb +100 -0
- data/lib/core_process/cloud/process/router.rb +260 -0
- data/lib/core_process/cloud/process/rules.rb +120 -0
- data/lib/core_process/cloud/process/security_groups.rb +121 -0
- data/lib/core_process/cloud/process/server.rb +127 -0
- data/lib/core_process/cloud/process/server_log.rb +35 -0
- data/lib/core_process/cloud/process/subnetwork.rb +108 -0
- data/lib/core_process/cloud_process.rb +30 -0
- data/lib/logging.rb +298 -0
- data/lib/lorj/version.rb +18 -1
- data/lib/lorj.rb +58 -18
- data/lib/lorj_account.rb +556 -0
- data/lib/lorj_config.rb +468 -0
- data/lib/lorj_defaults.rb +278 -0
- data/lib/prc.rb +136 -104
- data/lib/prc_base_config.rb +285 -0
- data/lib/prc_core_config.rb +878 -0
- data/lib/prc_section_config.rb +57 -0
- data/lib/providers/hpcloud/compute.rb +81 -93
- data/lib/providers/hpcloud/hpcloud.rb +462 -0
- data/lib/providers/hpcloud/network.rb +96 -98
- data/lib/providers/hpcloud/security_groups.rb +41 -40
- data/lib/providers/mock/mock.rb +144 -0
- data/lib/providers/openstack/openstack.rb +45 -0
- data/lib/providers/templates/compute.rb +21 -23
- data/lib/providers/templates/mycloud.rb +72 -0
- data/lib/providers/templates/network.rb +11 -12
- data/lib/rh.rb +339 -0
- data/lorj-spec/defaults.yaml +4 -0
- data/lorj.gemspec +6 -0
- data/spec/00_lorj_log_spec.rb +53 -0
- data/spec/01_hash_rh_spec.rb +243 -0
- data/spec/02_prc_base_config_spec.rb +216 -0
- data/spec/04_prc_core_config_spec.rb +83 -0
- data/spec/11_lorj_config_spec.rb +263 -0
- data/spec/12_lorj_account_spec.rb +181 -0
- metadata +76 -28
- data/Gemfile.lock +0 -37
- data/example/students_1/process/Students.rb +0 -20
- data/example/students_2/process/Students.rb +0 -27
- data/example/students_4/controller/yaml_students.rb +0 -82
- data/example/students_4/controller/yaml_students_controller.rb +0 -141
- data/example/students_4/process/students.rb +0 -112
- data/example/students_4/students.rb +0 -103
- data/lib/core/lorj-basecontroller.rb +0 -90
- data/lib/core/lorj-basedefinition.rb +0 -1139
- data/lib/core/lorj-baseprocess.rb +0 -236
- data/lib/core/lorj-data.rb +0 -567
- data/lib/core/lorj-keypath.rb +0 -115
- data/lib/core_process/CloudProcess.rb +0 -337
- data/lib/core_process/global_process.rb +0 -502
- data/lib/core_process/network_process.rb +0 -605
- data/lib/prc-account.rb +0 -339
- data/lib/prc-config.rb +0 -1030
- data/lib/prc-logging.rb +0 -261
- data/lib/providers/hpcloud/Hpcloud.rb +0 -426
- data/lib/providers/mock/Mock.rb +0 -141
- data/lib/providers/openstack/Openstack.rb +0 -47
- data/lib/providers/templates/core.rb +0 -61
- data/spec/forj-account_spec.rb +0 -75
- data/spec/forj-config_spec.rb +0 -196
|
@@ -16,323 +16,279 @@
|
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
18
|
module Lorj
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
value_free = ask("Enter %s: [%s]" % [sDesc, value_hidden]) do |q|
|
|
72
|
-
q.echo = '*'
|
|
73
|
-
end
|
|
74
|
-
if value_free == "" and enc_value
|
|
75
|
-
value_free = Encryptor.decrypt(
|
|
76
|
-
:value => Base64::strict_decode64(enc_value),
|
|
77
|
-
:key => entr[:key],
|
|
78
|
-
:iv => Base64::strict_decode64(entr[:iv]),
|
|
79
|
-
:salt => entr[:salt]
|
|
80
|
-
)
|
|
81
|
-
else
|
|
82
|
-
PrcLib.message("%s cannot be empty." % sDesc) if value_free == ""
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
enc_value = Base64::strict_encode64(
|
|
86
|
-
Encryptor.encrypt(
|
|
87
|
-
:value => value_free,
|
|
88
|
-
:key => entr[:key],
|
|
89
|
-
:iv => Base64::strict_decode64(entr[:iv]),
|
|
90
|
-
:salt => entr[:salt]
|
|
91
|
-
)
|
|
92
|
-
)
|
|
19
|
+
# Class Definition internal function.
|
|
20
|
+
class BaseDefinition
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
# return Object data meta data.
|
|
24
|
+
def _get_meta_data(key)
|
|
25
|
+
meta_default = Lorj.defaults.get_meta(key)
|
|
26
|
+
return nil if meta_default.nil?
|
|
27
|
+
meta_default = meta_default.clone
|
|
28
|
+
|
|
29
|
+
section = Lorj.defaults.get_meta_section(key)
|
|
30
|
+
return meta_default if section.nil?
|
|
31
|
+
meta = PrcLib.model.meta_data.rh_get(section, key)
|
|
32
|
+
return meta_default if meta.nil?
|
|
33
|
+
|
|
34
|
+
meta_default.merge!(meta)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# internal runtime function for process call
|
|
38
|
+
# Get the controller result and map controller object data to
|
|
39
|
+
# lorj object attributes, using controller mapping function.
|
|
40
|
+
#
|
|
41
|
+
# *parameters*:
|
|
42
|
+
# - +object_type+ : object_type to map
|
|
43
|
+
# - +oControlerObject+ : Controller object
|
|
44
|
+
#
|
|
45
|
+
# *return*:
|
|
46
|
+
# - value : Hash. return the parameter value.
|
|
47
|
+
#
|
|
48
|
+
# *raise*:
|
|
49
|
+
#
|
|
50
|
+
def _return_map(object_type, oControlerObject)
|
|
51
|
+
return nil if oControlerObject.nil?
|
|
52
|
+
|
|
53
|
+
attr_value = {}
|
|
54
|
+
|
|
55
|
+
map_handler = _map_identify_mapping_handler(object_type)
|
|
56
|
+
return nil if map_handler.nil?
|
|
57
|
+
|
|
58
|
+
object_opts = PrcLib.model.meta_obj.rh_get(object_type)
|
|
59
|
+
|
|
60
|
+
maps = object_opts[:returns]
|
|
61
|
+
maps.each do |key, map|
|
|
62
|
+
next unless map
|
|
63
|
+
|
|
64
|
+
key_obj = KeyPath.new(key)
|
|
65
|
+
map_obj = KeyPath.new(map)
|
|
66
|
+
|
|
67
|
+
value = _call_controller_map(map_handler, oControlerObject,
|
|
68
|
+
map_obj.tree)
|
|
69
|
+
value = _mapping_data(object_type, key_obj, object_opts, value)
|
|
70
|
+
attr_value.rh_set(value, key_path.tree)
|
|
93
71
|
end
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
sSection = Lorj::Default.get_meta_section(sKey)
|
|
130
|
-
return hMetaDefault if sSection.nil?
|
|
131
|
-
hMeta = Lorj::rhGet(@@meta_data, sSection, sKey)
|
|
132
|
-
return hMetaDefault if hMeta.nil?
|
|
133
|
-
|
|
134
|
-
hMetaDefault.merge!(hMeta)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def _return_map(sCloudObj, oControlerObject)
|
|
138
|
-
return nil if oControlerObject.nil?
|
|
139
|
-
|
|
140
|
-
attr_value = {}
|
|
141
|
-
|
|
142
|
-
pProc = Lorj::rhGet(@@meta_obj, sCloudObj, :lambdas, :get_attr_e)
|
|
143
|
-
bController = Lorj::rhGet(@@meta_obj, sCloudObj, :options, :controller)
|
|
144
|
-
return nil if not pProc and not bController
|
|
145
|
-
|
|
146
|
-
hMap = Lorj::rhGet(@@meta_obj, sCloudObj, :returns)
|
|
147
|
-
hMap.each { |key, map|
|
|
148
|
-
oKeyPath = KeyPath.new(key)
|
|
149
|
-
oMapPath = KeyPath.new(map)
|
|
150
|
-
next if not map
|
|
151
|
-
if pProc
|
|
152
|
-
Lorj::debug(4, "Calling process function '%s' to retrieve/map Controller object '%s' data " % [pProc, sCloudObj])
|
|
153
|
-
controller_attr_value = @oForjProcess.method(pProc).call(sCloudObj, oControlerObject)
|
|
154
|
-
else
|
|
155
|
-
Lorj::debug(4, "Calling controller function 'get_attr' to retrieve/map Controller object '%s' data " % [sCloudObj])
|
|
156
|
-
controller_attr_value = @oProvider.get_attr(oControlerObject, oMapPath.aTree) if bController
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
hValueMapping = Lorj::rhGet(@@meta_obj, sCloudObj, :value_mapping, oKeyPath.sFullPath)
|
|
160
|
-
if hValueMapping and not controller_attr_value.nil?
|
|
161
|
-
hValueMapping.each { | map_key, map_value |
|
|
162
|
-
if controller_attr_value == map_value
|
|
163
|
-
Lorj::rhSet(attr_value, map_key ,oKeyPath.aTree)
|
|
164
|
-
Lorj::debug(5, "Object '%s' value mapped '%s': '%s' => '%s'" % [sCloudObj, oKeyPath.aTree, controller_attr_value, map_value])
|
|
165
|
-
break
|
|
166
|
-
end
|
|
167
|
-
}
|
|
168
|
-
raise Lorj::PrcError.new(), "'%s.%s': No controller value mapping for '%s'." % [sCloudObj, oKeyPath.sKey, controller_attr_value] if attr_value.nil?
|
|
169
|
-
else
|
|
170
|
-
Lorj::debug(5, "Object '%s' value '%s' extracted: '%s'" % [sCloudObj, oKeyPath.aTree, controller_attr_value])
|
|
171
|
-
Lorj::rhSet(attr_value, controller_attr_value ,oKeyPath.aTree)
|
|
172
|
-
end
|
|
173
|
-
}
|
|
174
|
-
attr_value
|
|
72
|
+
attr_value
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# internal runtime function for process call
|
|
76
|
+
# Get the object controller mapping method and method origin.
|
|
77
|
+
#
|
|
78
|
+
# If the object is fully managed by the process, ie no controller
|
|
79
|
+
# object is attached to it, the process will own the mapping method.
|
|
80
|
+
#
|
|
81
|
+
# *parameters*:
|
|
82
|
+
# - +object_type+ : object_type to map
|
|
83
|
+
#
|
|
84
|
+
# *return*:
|
|
85
|
+
# - map_method : return the parameter value.
|
|
86
|
+
# - method_name : Name of the map method.
|
|
87
|
+
# - is_controller : true if the map method is owned by the controller
|
|
88
|
+
# false if the map method is owned by the process.
|
|
89
|
+
# - class owner : Class owner of the map method.
|
|
90
|
+
#
|
|
91
|
+
# *raise*:
|
|
92
|
+
#
|
|
93
|
+
def _map_identify_mapping_handler(object_type)
|
|
94
|
+
proc_name = PrcLib.model.meta_obj.rh_get(object_type,
|
|
95
|
+
:lambdas, :get_attr_e)
|
|
96
|
+
|
|
97
|
+
is_controller = PrcLib.model.meta_obj.rh_get(object_type,
|
|
98
|
+
:options, :controller)
|
|
99
|
+
|
|
100
|
+
return nil if !proc_name && !is_controller
|
|
101
|
+
|
|
102
|
+
if proc_name
|
|
103
|
+
map_handler = [@process.method(proc_name), proc_name, false]
|
|
104
|
+
map_handler << @process.class
|
|
105
|
+
return map_handler
|
|
175
106
|
end
|
|
176
107
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
#~ if hValueMapping
|
|
200
|
-
#~ raise PrcError.new(), "'%s.%s': No Config value mapping for '%s'" % [section, sKey, value] if Lorj::rhExist?(hValueMapping, value) != 1
|
|
201
|
-
#~ value = hValueMapping[value]
|
|
202
|
-
#~ end
|
|
203
|
-
end
|
|
204
|
-
if Lorj::rhExist?(hParams, :mapping) == 1
|
|
205
|
-
# NOTE: if mapping is set, the definition subtree
|
|
206
|
-
# is ignored.
|
|
207
|
-
# if key map to mykey
|
|
208
|
-
# [:section1][subsect][key] = value
|
|
209
|
-
# oParam => [:hdata][mykey] = value
|
|
210
|
-
# not oParam => [:hdata][:section1][subsect][mykey] = value
|
|
211
|
-
Lorj::rhSet(oParam[:hdata], value, Lorj::rhGet(hParams, :mapping))
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
oParam[oKeyPath.aTree] = value
|
|
108
|
+
[@controller.method(:get_attr), :get_attr, true, @controller.class]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# internal runtime function for process call
|
|
112
|
+
# Call the mapping method to get the controller attribute data.
|
|
113
|
+
#
|
|
114
|
+
#
|
|
115
|
+
# *parameters*:
|
|
116
|
+
# - +map_handler+ : map array returned by _map_identify_mapping_handler
|
|
117
|
+
# - +controller_obj+ : Controller object
|
|
118
|
+
# - +attr_tree+ : Array of attribute tree to get the controller data.
|
|
119
|
+
#
|
|
120
|
+
# *return*:
|
|
121
|
+
# - controller data.
|
|
122
|
+
#
|
|
123
|
+
# *raise*:
|
|
124
|
+
#
|
|
125
|
+
def _call_controller_map(map_handler, oControlerObject, attr_tree)
|
|
126
|
+
if map_handler[2]
|
|
127
|
+
type = 'controller'
|
|
128
|
+
else
|
|
129
|
+
type = 'process'
|
|
215
130
|
end
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
raise Lorj::PrcError.new(), "Undefined ObjectData '%s'." % [ hParams[:type]]
|
|
250
|
-
end
|
|
251
|
-
}
|
|
252
|
-
oParams
|
|
131
|
+
Lorj.debug(4, "Calling '%s.%s' to retrieve/map %s object '%s' data ",
|
|
132
|
+
map_handler[3], map_handler[1], type, attr_tree)
|
|
133
|
+
|
|
134
|
+
map_handler[0].call(oControlerObject, attr_tree)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# internal runtime function for process call
|
|
138
|
+
# Do the mapping of the value as defined by obj_needs options:
|
|
139
|
+
# :value_mapping => (Array of attribute tree)
|
|
140
|
+
#
|
|
141
|
+
# *parameters*:
|
|
142
|
+
# - +object_type+ : Object type to get data mapped.
|
|
143
|
+
# - +key_obj+ : Attribute to map
|
|
144
|
+
# - +object_opts+ : Attribute options.
|
|
145
|
+
# - +value+ : Controller value to map.
|
|
146
|
+
#
|
|
147
|
+
# *return*:
|
|
148
|
+
# - controller data.
|
|
149
|
+
#
|
|
150
|
+
# *raise*:
|
|
151
|
+
#
|
|
152
|
+
def _mapping_data(object_type, key_obj, object_opts, value)
|
|
153
|
+
value_mapping = object_opts.rh_get(:value_mapping, key_obj.fpath)
|
|
154
|
+
if value_mapping && !value.nil?
|
|
155
|
+
value_mapping.each do | map_key, map_value |
|
|
156
|
+
next unless value == map_value
|
|
157
|
+
Lorj.debug(5, "Object '%s' value mapped '%s': '%s' => '%s'",
|
|
158
|
+
object_type, key_obj.tree,
|
|
159
|
+
value, map_value)
|
|
160
|
+
return map_key
|
|
161
|
+
end
|
|
162
|
+
runtime_fail("'%s.%s': No controller value mapping for '%s'.",
|
|
163
|
+
object_type, key_obj.tree, value)
|
|
253
164
|
end
|
|
254
165
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
166
|
+
Lorj.debug(5, "Object '%s' value '%s' extracted: '%s'",
|
|
167
|
+
object_type, key_obj.tree, value)
|
|
168
|
+
value
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# internal runtime function for process call
|
|
172
|
+
# Check object needs list, to report missing required data.
|
|
173
|
+
# raise a runtime error if at least, one data is not set.
|
|
174
|
+
# It returns a list "missing objects".
|
|
175
|
+
#
|
|
176
|
+
# *parameters*:
|
|
177
|
+
# - +object_missing+ : Array of missing object for process caller.
|
|
178
|
+
# - +attr_name+ : attribute/data name
|
|
179
|
+
# - +attr_options+ : attribute options
|
|
180
|
+
# - +fname+ : caller function
|
|
181
|
+
#
|
|
182
|
+
# *return*:
|
|
183
|
+
# - Array : missing objects.
|
|
184
|
+
#
|
|
185
|
+
# *raise*:
|
|
186
|
+
# - runtime error if required data is not set. (empty or nil)
|
|
187
|
+
#
|
|
188
|
+
def _check_required(object_type, sEventType, fname)
|
|
189
|
+
object_missing = []
|
|
190
|
+
|
|
191
|
+
attr_paths = PrcLib.model.meta_obj.rh_get(object_type,
|
|
192
|
+
:params, :keys)
|
|
193
|
+
PrcLib.runtime_fail("'%s' Object data needs not set. Forgot "\
|
|
194
|
+
'obj_needs?', object_type) if attr_paths.nil?
|
|
195
|
+
|
|
196
|
+
if sEventType == :delete_e &&
|
|
197
|
+
@object_data.type?(object_type) != :DataObject
|
|
198
|
+
object_missing << object_type
|
|
262
199
|
end
|
|
263
200
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
oKeypath = KeyPath.new(keypath)
|
|
268
|
-
sKeyPath = oKeypath.sKeyPath
|
|
269
|
-
return nil if Lorj::rhExist?(@@meta_data, section, sKeyPath, :process, sControllerValue) != 4
|
|
270
|
-
Lorj::rhGet(@@meta_data, section, sKeyPath, :process, sControllerValue)
|
|
201
|
+
attr_paths.each do | _attr_path, attr_options|
|
|
202
|
+
next if attr_options[:for] && !attr_options[:for].include?(sEventType)
|
|
203
|
+
_check_required_attr(object_missing, attr_name, attr_options, fname)
|
|
271
204
|
end
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
sSection = Lorj::Default.get_meta_section(sKey)
|
|
304
|
-
sSection = 'runtime' if not sSection
|
|
305
|
-
raise Lorj::PrcError.new(), "key '%s/%s' is not set. '%s' requirement failed." % [ sSection, sKey, fname], aCaller
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
when :CloudObject
|
|
309
|
-
#~ if hParams[:required] and Lorj::rhExist?(@CloudData, sKey, :object) != 2
|
|
310
|
-
if hParams[:required] and @ObjectData.type?(sKey) != :DataObject
|
|
311
|
-
oObjMissing << sKey
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
|
-
}
|
|
315
|
-
return oObjMissing
|
|
205
|
+
object_missing
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# internal runtime function
|
|
209
|
+
# Check while the attribute data or object is required, if it is set.
|
|
210
|
+
# raise a runtime error if data is not set.
|
|
211
|
+
# add object in the missing object Array if object is not set.
|
|
212
|
+
#
|
|
213
|
+
# *parameters*:
|
|
214
|
+
# - +object_missing+ : Array of missing object for process caller.
|
|
215
|
+
# - +attr_name+ : attribute/data name
|
|
216
|
+
# - +attr_options+ : attribute options
|
|
217
|
+
# - +fname+ : caller function
|
|
218
|
+
#
|
|
219
|
+
# *return*:
|
|
220
|
+
#
|
|
221
|
+
# *raise*:
|
|
222
|
+
# - runtime error if required data is not set. (empty or nil)
|
|
223
|
+
#
|
|
224
|
+
def _check_required_attr(object_missing, attr_name, attr_options, fname)
|
|
225
|
+
attr_obj = KeyPath.new(attr_path)
|
|
226
|
+
|
|
227
|
+
attr_name = attr_obj.key
|
|
228
|
+
case attr_options[:type]
|
|
229
|
+
when :data
|
|
230
|
+
_check_required_attr_data(attr_name, attr_options, fname)
|
|
231
|
+
when :CloudObject
|
|
232
|
+
if attr_options[:required] &&
|
|
233
|
+
@object_data.type?(attr_name) != :DataObject
|
|
234
|
+
object_missing << attr_name
|
|
235
|
+
end
|
|
316
236
|
end
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# internal runtime function
|
|
240
|
+
# Check while the attribute data is required, if data is not set
|
|
241
|
+
# raise a runtime error if not.
|
|
242
|
+
#
|
|
243
|
+
# *parameters*:
|
|
244
|
+
# - +attr_name+ : attribute/data name
|
|
245
|
+
# - +attr_options+ : attribute options
|
|
246
|
+
# - +fname+ : caller function
|
|
247
|
+
#
|
|
248
|
+
# *return*:
|
|
249
|
+
#
|
|
250
|
+
# *raise*:
|
|
251
|
+
# - runtime error if required data is not set. (empty or nil)
|
|
252
|
+
#
|
|
253
|
+
def _check_required_attr_data(attr_name, attr_options, fname)
|
|
254
|
+
default = attr_options.rh_get(:default_value)
|
|
255
|
+
|
|
256
|
+
return unless attr_options[:required]
|
|
257
|
+
|
|
258
|
+
if attr_options.key?(:extract_from)
|
|
259
|
+
unless @object_data.exist?(attr_options[:extract_from])
|
|
260
|
+
PrcLib.runtime_fail("key '%s' was not extracted from '%s'"\
|
|
261
|
+
". '%s' requirement failed.",
|
|
262
|
+
attr_name, attr_options[:extract_from], fname)
|
|
263
|
+
end
|
|
264
|
+
elsif @config.get(attr_name, default).nil?
|
|
265
|
+
section = Lorj.defaults.get_meta_section(attr_name)
|
|
266
|
+
section = 'runtime' unless section
|
|
267
|
+
PrcLib.runtime_fail("key '%s/%s' is not set. '%s' requirement"\
|
|
268
|
+
' failed.', section, attr_name, fname)
|
|
335
269
|
end
|
|
336
|
-
|
|
337
|
-
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# Obsolete function
|
|
273
|
+
#
|
|
274
|
+
# *parameters*:
|
|
275
|
+
# -
|
|
276
|
+
|
|
277
|
+
# def _identify_data(object_type, sEventType, data_type = :data)
|
|
278
|
+
# data_array = []
|
|
279
|
+
#
|
|
280
|
+
# key_paths = PrcLib.model.meta_obj.rh_get(object_type,
|
|
281
|
+
# :params, :keys)
|
|
282
|
+
# runtime_fail("'%s' Object data needs not set. Forgot obj_needs?",
|
|
283
|
+
# object_type) if key_paths.nil?
|
|
284
|
+
#
|
|
285
|
+
# key_paths.each do | sKeypath, hParams|
|
|
286
|
+
# next if hParams[:for] && !hParams[:for].include?(sEventType)
|
|
287
|
+
# key_path = KeyPath.new(sKeypath)
|
|
288
|
+
#
|
|
289
|
+
# data_array << key_path.tree if hParams[:type] == data_type
|
|
290
|
+
# end
|
|
291
|
+
# data_array
|
|
292
|
+
# end
|
|
293
|
+
end
|
|
338
294
|
end
|