lorj 1.0.3 → 1.0.4

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/example/students_1/students.rb +5 -6
  3. data/example/students_2/students.rb +4 -5
  4. data/example/students_3/students.rb +4 -5
  5. data/example/students_4/students.rb +4 -5
  6. data/example/students_5/students.rb +5 -5
  7. data/lib/core/core.rb +6 -1
  8. data/lib/core/core_controller.rb +1 -9
  9. data/lib/core/core_internal.rb +2 -1
  10. data/lib/core/core_model.rb +2 -10
  11. data/lib/core/core_object_data.rb +18 -0
  12. data/lib/core/core_object_params.rb +43 -4
  13. data/lib/core/core_process.rb +1 -9
  14. data/lib/core/core_process_setup.rb +32 -6
  15. data/lib/core/core_setup_ask.rb +41 -33
  16. data/lib/core/core_setup_encrypt.rb +29 -6
  17. data/lib/core/core_setup_init.rb +2 -2
  18. data/lib/core/definition.rb +33 -10
  19. data/lib/core/definition_internal.rb +10 -14
  20. data/lib/core/lorj_basedefinition.rb +16 -24
  21. data/lib/core/lorj_baseprocess.rb +113 -44
  22. data/lib/core/lorj_data.rb +2 -9
  23. data/lib/core/lorj_keypath.rb +5 -2
  24. data/lib/core_process/cloud/process/common.rb +4 -7
  25. data/lib/core_process/cloud/process/connection.rb +44 -45
  26. data/lib/core_process/cloud/process/external_network.rb +24 -28
  27. data/lib/core_process/cloud/process/flavor.rb +31 -34
  28. data/lib/core_process/cloud/process/images.rb +12 -15
  29. data/lib/core_process/cloud/process/internet_network.rb +13 -14
  30. data/lib/core_process/cloud/process/internet_server.rb +9 -10
  31. data/lib/core_process/cloud/process/keypairs.rb +34 -27
  32. data/lib/core_process/cloud/process/network.rb +21 -23
  33. data/lib/core_process/cloud/process/public_ip.rb +17 -18
  34. data/lib/core_process/cloud/process/router.rb +86 -92
  35. data/lib/core_process/cloud/process/rules.rb +30 -31
  36. data/lib/core_process/cloud/process/security_groups.rb +21 -22
  37. data/lib/core_process/cloud/process/server.rb +30 -31
  38. data/lib/core_process/cloud/process/server_log.rb +13 -14
  39. data/lib/core_process/cloud/process/subnetwork.rb +25 -40
  40. data/lib/logging.rb +4 -17
  41. data/lib/lorj/version.rb +1 -1
  42. data/lib/lorj.rb +2 -1
  43. data/lib/lorj_account.rb +137 -90
  44. data/lib/lorj_config.rb +13 -19
  45. data/lib/lorj_defaults.rb +46 -292
  46. data/lib/lorj_meta.rb +729 -0
  47. data/lib/prc.rb +119 -30
  48. data/lib/prc_base_config.rb +53 -47
  49. data/lib/prc_core_config.rb +837 -565
  50. data/lib/prc_section_config.rb +44 -16
  51. data/lib/providers/hpcloud/hpcloud.rb +1 -1
  52. data/lib/providers/openstack/openstack.rb +278 -21
  53. data/lib/providers/openstack/openstack_create.rb +205 -0
  54. data/lib/providers/openstack/openstack_delete.rb +28 -0
  55. data/lib/providers/openstack/openstack_get.rb +39 -0
  56. data/lib/providers/openstack/openstack_process.rb +26 -0
  57. data/lib/providers/openstack/openstack_query.rb +96 -0
  58. data/lib/providers/openstack/openstack_update.rb +35 -0
  59. data/lib/rh.rb +91 -6
  60. data/lorj-spec/defaults.yaml +18 -12
  61. data/lorj.gemspec +1 -0
  62. data/spec/01_hash_rh_spec.rb +41 -2
  63. data/spec/02_prc_base_config_spec.rb +1 -1
  64. data/spec/03_prc_section_config_spec.rb +1 -1
  65. data/spec/04_prc_core_config_spec.rb +148 -4
  66. data/spec/09_prc_spec.rb +104 -0
  67. data/spec/{00_lorj_log_spec.rb → 10_lorj_log_spec.rb} +23 -2
  68. data/spec/11_lorj_config_spec.rb +9 -27
  69. data/spec/12_lorj_account_spec.rb +36 -20
  70. data/spec/20_lorj_meta_spec.rb +271 -0
  71. data/spec/21_lorj_defaults_spec.rb +85 -0
  72. metadata +31 -4
@@ -116,6 +116,17 @@ module Lorj
116
116
  # - def_attr_mapping : Define object attribute mapping.
117
117
  # - data_value_mapping: Define Data model values mapping.
118
118
  #
119
+ # * *Args*
120
+ # - type : Symbol. Object type to declare.
121
+ # - handlers : Hash. List of Process handler to call for
122
+ # create/query/get/delete/update/get_attr.
123
+ # Handlers supported:
124
+ # - :create_e : Process function to call with create
125
+ # - :delete_e : Process function to call with delete
126
+ # - :update_e : Process function to call with update
127
+ # - :get_e : Process function to call with get
128
+ # - :query_e : Process function to call with query
129
+ # - :get_attr_e : Process function to call with get_attr
119
130
  def self.define_obj(obj_type_name, handlers = nil)
120
131
  return nil unless [NilClass, String, Symbol].include?(obj_type_name.class)
121
132
  PrcLib.model.heap true
@@ -142,6 +153,16 @@ module Lorj
142
153
  end
143
154
 
144
155
  # Application process to defines query attributes.
156
+ #
157
+ # This function is depreciated.
158
+ #
159
+ # def_attribute or def_attr_mapping already set the attribute as
160
+ # queriable. If the controller needs to redefine how the attribute is
161
+ # queried, use it will needs to call query_mapping.
162
+ #
163
+ # But from process point of view, all attribute must be queriable.
164
+ #
165
+ # So, use def_attribute(process), then query_mapping(controller)
145
166
  def self.def_query_attribute(key)
146
167
  PrcLib.model.heap true
147
168
  query_mapping(key, key)
@@ -261,17 +282,16 @@ module Lorj
261
282
  return nil if options.class != Hash
262
283
  PrcLib.model.heap true
263
284
 
264
- data = data.to_sym if data.class == String
285
+ data = KeyPath.new data, 2
265
286
  PrcLib.dcl_fail("%s: Config data '%s' unknown",
266
- self.class, data) unless Lorj.defaults.meta_exist?(data)
287
+ self.class,
288
+ data) unless Lorj.data.auto_meta_exist?(data.key)
267
289
 
268
290
  PrcLib.model.data_context data
269
291
 
270
- section = _section_from(data)
292
+ section = Lorj.data.first_section(data.key)
271
293
 
272
- cur_options = PrcLib.model.meta_data.rh_get(section, data)
273
- return cur_options.merge!(options) if cur_options
274
- PrcLib.model.meta_data.rh_set(options, section, data)
294
+ Lorj.data.define_controller_data(section, data.key, options)
275
295
  end
276
296
 
277
297
  # Controller to declare a model Data value mapping
@@ -288,7 +308,7 @@ module Lorj
288
308
  section = _section_from(data)
289
309
 
290
310
  Lorj.debug(2, format("%s/%s: Define config data value mapping: '%s' => "\
291
- "'%s'", section, data, value, map))
311
+ "'%s'", section, data.fpath, value, map))
292
312
  PrcLib.model.meta_data.rh_set(map, section, data,
293
313
  :value_mapping, :controller, value)
294
314
  PrcLib.model.meta_data.rh_set(value, section, data,
@@ -333,6 +353,8 @@ module Lorj
333
353
  # Controller declaration to map an query attribute
334
354
  # By default, def_attribute configure those attributes as queriable.
335
355
  # The controller can redefine the query part.
356
+ # Use def_attribute or def_attr_mapping
357
+ # All attributes are considered as queriable.
336
358
  def self.query_mapping(key, map)
337
359
  PrcLib.model.heap true
338
360
  _query_mapping(key, map)
@@ -495,9 +517,10 @@ module Lorj
495
517
  [key_path_obj.fpath, map_path_obj.fpath]
496
518
  end
497
519
 
498
- # Internal section detection
520
+ # Internal section detection based on a keyPath Object
499
521
  def self._section_from(data)
500
- section = Lorj.defaults.get_meta_section(data)
522
+ return data.key[0] if data.length == 2
523
+ section = Lorj.defaults.get_meta_section(data.key)
501
524
  section = :runtime if section.nil?
502
525
 
503
526
  section
@@ -575,7 +598,7 @@ module Lorj
575
598
  # Internal function
576
599
  def self._obj_needs_data(object_attr, msg_action, new_params)
577
600
  attr_name = PrcLib.model.attribute_context
578
- if Lorj.defaults.meta_exist?(attr_name)
601
+ if Lorj.data.auto_meta_exist?(attr_name)
579
602
  Lorj.debug(2, "%-28s: %s predefined config '%s'.",
580
603
  _object_name(PrcLib.model.object_context),
581
604
  msg_action, attr_name)
@@ -22,26 +22,22 @@ module Lorj
22
22
 
23
23
  # return Object data meta data.
24
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
25
+ Lorj.data.auto_section_data(key)
26
+ # meta_default = Lorj.defaults.get_meta_auto(key)
27
+ # return nil if meta_default.nil?
28
+ # meta_default = meta_default.clone
28
29
 
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?
30
+ # section = Lorj.defaults.get_meta_section(key)
31
+ # return meta_default if section.nil?
32
+ # meta = PrcLib.model.meta_data.rh_get(section, key)
33
+ # return meta_default if meta.nil?
33
34
 
34
- meta_default.merge!(meta)
35
- end
36
-
37
- def _get_meta_data_auto(key)
38
- return nil if key.nil?
39
- Lorj.defaults.get_meta_auto(key)
35
+ # meta_default.merge!(meta)
40
36
  end
41
37
 
42
38
  def _get_account_section(key)
43
39
  return nil if key.nil?
44
- Lorj.defaults.get_meta_section(key)
40
+ Lorj.data.first_section(key)
45
41
  end
46
42
 
47
43
  # internal runtime function for process call
@@ -14,16 +14,9 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- # Module Lorj which contains several classes.
17
+ # Module Lorj implements ERBConfig, and initialization functions for
18
+ # Lorj::BaseDefinition
18
19
  #
19
- # Those classes describes :
20
- # - processes (BaseProcess) : How to create/delete/edit/query object.
21
- # - controler (BaseControler) : If a provider is defined, define how will do
22
- # object creation/etc...
23
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
24
- # and setup
25
- # this task to make it to work.
26
-
27
20
  module Lorj
28
21
  # This class limits ERC template to access only to config object data.
29
22
  class ERBConfig
@@ -80,21 +73,9 @@ module Lorj
80
73
  # Ex: object.set_data(...)
81
74
  # config
82
75
 
83
- # Function to manipulate the config object.
84
- # 2 kind of functions:
85
- # - set (key, value) and []=(key, value)
86
- # From processes, you can set a runtime data with:
87
- # config.set(key, value)
88
- # OR
89
- # config[key] = value
76
+ # Reference to the config object.
90
77
  #
91
- # - get (key, default) and [](key, default)
92
- # default is an optional value.
93
- # From processes, you can get a data (runtime/account/config.yaml or
94
- # defaults.yaml) with:
95
- # config.get(key)
96
- # OR
97
- # config[key]
78
+ # See Lorj::Config or Lorj::Account for details
98
79
  def config
99
80
  PrcLib.runtime_fail 'No config object loaded.' unless @config
100
81
  @config
@@ -187,7 +168,7 @@ module Lorj
187
168
  @object_data.add data_objects
188
169
  end
189
170
 
190
- # Function to get Lorj core data cache.
171
+ # Function to get attributes of objects stored in the Lorj core data cache.
191
172
  #
192
173
  # *Args*
193
174
  # - object_type : Object type to get
@@ -201,6 +182,17 @@ module Lorj
201
182
  @object_data[sObjectType, *key]
202
183
  end
203
184
 
185
+ # Function to get Lorj core data cache keys.
186
+ #
187
+ # *Args*
188
+ #
189
+ # *Return*
190
+ # - List of objects in cache.
191
+ #
192
+ def cache_objects_keys
193
+ @object_data[].keys
194
+ end
195
+
204
196
  # get an attribute/object/... from an object.
205
197
  def get_data(oObj, *key)
206
198
  if oObj.is_a?(Hash) && oObj.key?(:object_type)
@@ -15,16 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- # Module Lorj which contains several classes.
19
- #
20
- # Those classes describes :
21
- # - processes (BaseProcess) : How to create/delete/edit/query object.
22
- # - controler (BaseControler) : If a provider is defined, define how will do
23
- # object creation/etc...
24
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
25
- # and setup
26
- # this task to make it to work.
27
-
18
+ # - Lorj::BaseProcess : Process functions to call create/delete/edit/query
19
+ # processes on other objects.
28
20
  module Lorj
29
21
  # class describing generic Object Process
30
22
  # with controller calls
@@ -48,37 +40,37 @@ module Lorj
48
40
 
49
41
  attr_writer :base_object
50
42
 
51
- def controller_connect(sObjectType, params = nil)
43
+ def controller_connect(sObjectType, params = nil) #:doc:
52
44
  process_error 'No Controler object loaded.' unless @base_object
53
45
  params = nil unless params.is_a?(Hash)
54
46
  @base_object.controller_connect(sObjectType, params)
55
47
  end
56
48
 
57
- def controller_create(sObjectType, params = nil)
49
+ def controller_create(sObjectType, params = nil) #:doc:
58
50
  process_error 'No Controler object loaded.' unless @base_object
59
51
  params = nil unless params.is_a?(Hash)
60
52
  @base_object.controller_create(sObjectType, params)
61
53
  end
62
54
 
63
- def controller_query(sObjectType, sQuery, params = nil)
55
+ def controller_query(sObjectType, sQuery, params = nil) #:doc:
64
56
  process_error 'No Controler object loaded.' unless @base_object
65
57
  params = nil unless params.is_a?(Hash)
66
58
  @base_object.controller_query(sObjectType, sQuery, params)
67
59
  end
68
60
 
69
- def controller_update(sObjectType, params = nil)
61
+ def controller_update(sObjectType, params = nil) #:doc:
70
62
  process_error 'No Controler object loaded.' unless @base_object
71
63
  params = nil unless params.is_a?(Hash)
72
64
  @base_object.controller_update(sObjectType, params)
73
65
  end
74
66
 
75
- def controller_delete(sObjectType, params = nil)
67
+ def controller_delete(sObjectType, params = nil) #:doc:
76
68
  process_error 'No Controler object loaded.' unless @base_object
77
69
  params = nil unless params.is_a?(Hash)
78
70
  @base_object.controller_delete(sObjectType, params)
79
71
  end
80
72
 
81
- def controller_get(sObjectType, sId, params = nil)
73
+ def controller_get(sObjectType, sId, params = nil) #:doc:
82
74
  process_error 'No Controler object loaded.' unless @base_object
83
75
  params = nil unless params.is_a?(Hash)
84
76
  @base_object.controller_get(sObjectType, sId, params)
@@ -88,29 +80,29 @@ module Lorj
88
80
  # class describing generic Object Process
89
81
  # with process calls
90
82
  class BaseProcess
91
- def process_create(sObjectType)
83
+ def process_create(sObjectType, hConfig = nil) #:doc:
92
84
  process_error 'No Base object loaded.' unless @base_object
93
- @base_object.process_create(sObjectType)
85
+ @base_object.process_create(sObjectType, hConfig)
94
86
  end
95
87
 
96
- def process_query(sObjectType, sQuery)
88
+ def process_query(sObjectType, sQuery, hConfig = nil) #:doc:
97
89
  process_error 'No Base object loaded.' unless @base_object
98
- @base_object.process_query(sObjectType, sQuery)
90
+ @base_object.process_query(sObjectType, sQuery, hConfig)
99
91
  end
100
92
 
101
- def process_update(sObjectType)
93
+ def process_update(sObjectType, hConfig = nil) #:doc:
102
94
  process_error 'No Base object loaded.' unless @base_object
103
- @base_object.process_update(sObjectType)
95
+ @base_object.process_update(sObjectType, hConfig)
104
96
  end
105
97
 
106
- def process_get(sObjectType, sId)
98
+ def process_get(sObjectType, sId, hConfig = nil) #:doc:
107
99
  process_error 'No Base object loaded.' unless @base_object
108
- @base_object.process_get(sObjectType, sId)
100
+ @base_object.process_get(sObjectType, sId, hConfig)
109
101
  end
110
102
 
111
- def process_delete(sObjectType)
103
+ def process_delete(sObjectType, hConfig = nil) #:doc:
112
104
  process_error 'No Base object loaded.' unless @base_object
113
- @base_object.process_delete(sObjectType)
105
+ @base_object.process_delete(sObjectType, hConfig)
114
106
  end
115
107
  end
116
108
 
@@ -119,12 +111,12 @@ module Lorj
119
111
  class BaseProcess
120
112
  private
121
113
 
122
- def query_cache_cleanup(sObjectType)
114
+ def query_cache_cleanup(sObjectType) #:doc:
123
115
  fail Lorj::PrcError.new, 'No Base object loaded.' unless @base_object
124
116
  @base_object.query_cleanup(sObjectType)
125
117
  end
126
118
 
127
- def object_cache_cleanup(sObjectType)
119
+ def object_cache_cleanup(sObjectType) #:doc:
128
120
  fail Lorj::PrcError.new, 'No Base object loaded.' unless @base_object
129
121
  @base_object.object_cleanup(sObjectType)
130
122
  end
@@ -143,21 +135,45 @@ module Lorj
143
135
  @base_object
144
136
  end
145
137
 
146
- def format_object(sObjectType, oMiscObj)
138
+ def format_object(sObjectType, oMiscObj) #:doc:
147
139
  PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
148
140
  @base_object.format_object(sObjectType, oMiscObj)
149
141
  end
150
142
 
151
- def format_query(sObjectType, oMiscObj, hQuery)
143
+ def format_query(sObjectType, oMiscObj, hQuery) #:doc:
152
144
  PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
153
145
  @base_object.format_list(sObjectType, oMiscObj, hQuery)
154
146
  end
155
147
 
156
- def data_objects(sObjectType, *key)
148
+ # Function to provides Lorj Core data cache access.
149
+ #
150
+ # See BaseDefinition#data_objects for details.
151
+ #
152
+ # AVOID CALLING THIS FUNCTION, except in debug case.
153
+ # Usually, if you are using this function to access some data,
154
+ # it means you need to declare those data in your object model.
155
+ #
156
+ # As normally this data should be accessible to the function parameter
157
+ # call. Please review.
158
+ #
159
+ def data_objects(sObjectType, *key) #:doc:
160
+ PrcLib.debug('data_objects is depreciated. To access "%s", you should '\
161
+ 'declare it with obj_needs of "%s" and if needed, refresh '\
162
+ 'hParams with hParams.refresh. Please update your code'\
163
+ "\nSee %s", sObjectType, sObjectType, caller[0])
157
164
  PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
158
165
  @base_object.data_objects(sObjectType, *key)
159
166
  end
160
167
 
168
+ # Function to provides Lorj Core data cache access.
169
+ #
170
+ # See BaseDefinition#cache_objects_keys for details.
171
+ #
172
+ def cache_objects_keys #:doc:
173
+ PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
174
+ @base_object.cache_objects_keys
175
+ end
176
+
161
177
  def get_data(oObj, *key)
162
178
  PrcLib.warning('get_data call is obsolete. Please update your code. '\
163
179
  "Use [] instead.\n%s", caller)
@@ -165,17 +181,78 @@ module Lorj
165
181
  @base_object.get_data(oObj, :attrs, key)
166
182
  end
167
183
 
168
- def register(oObject, sObjectType = nil)
184
+ def register(oObject, sObjectType = nil) #:doc:
169
185
  PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
170
186
  @base_object.register(oObject, sObjectType)
171
187
  end
172
188
 
173
- def config
189
+ def config #:doc:
174
190
  PrcLib.runtime_fail 'No Base object loaded.' unless @base_object
175
191
  @base_object.config
176
192
  end
177
193
 
178
- def query_single(sCloudObj, sQuery, name, sInfoMsg = {})
194
+ # Function to execute a query and return one or no record.
195
+ #
196
+ # * *Args*
197
+ # - +type+ : Symbol. meta object type to query.
198
+ # - +sQuery+ : Hash. Represents the query to execute
199
+ # - +name+ : String. Human name of the object to search.
200
+ # - +info+ : List of message to format. This string is printed out
201
+ # thanks to #Lorj.debug or #PrcLib.info
202
+ # - :notfound : not found string formated with: type, name
203
+ # - :checkmatch : checking match string formated with: type, name
204
+ # - :nomatch : No match string formated with: type, name
205
+ # - :found : Found string formated with: type, item
206
+ # item string built from :items and :items_form
207
+ # - :more : Found several string formated with: type, name
208
+ # - :items_form : Combined with :items. Represent a valid format string
209
+ # for Ruby format function
210
+ # - :items : Symbol or Array of Symbol.
211
+ # List of elements extracted from the first element of the query
212
+ # result.
213
+ # It is used to format the `item` string with :items_form format
214
+ # string.
215
+ # by default, the element extracted is :name and :items_form is '%s'.
216
+ #
217
+ # * *returns*
218
+ # - Lorj::Data of type :list. It represents the query result.
219
+ # It contains 0 or more Lorj::Data of type :data
220
+ #
221
+ # Example: following info is the default setting. If this setting is what
222
+ # want, then info can be missed. Otherwise, set one or all of this setting
223
+ # to change the default query_single print out.
224
+ #
225
+ # info = {
226
+ # :notfound => "No %s '%s' found",
227
+ # :checkmatch => "Found 1 %s. checking exact match for '%s'.",
228
+ # :nomatch => "No %s '%s' match",
229
+ # :found => "Found %s '%s'.",
230
+ # :more => "Found several %s. Searching for '%s'.",
231
+ # :items_form => '%s',
232
+ # :items => [:name]
233
+ # }
234
+ # item_searched = 'forj'
235
+ # query = { :name => item_searched }
236
+ # query_single(:network, query, item_searched, info)
237
+ # # if no record is found
238
+ # # => Will print "No network 'forj' found"
239
+ #
240
+ # # If found one record.
241
+ # # => Will print "Found 1 network. checking exact match for 'forj'."
242
+ #
243
+ # # if found but no match the query.
244
+ # # => Will print "No network 'forj' match"
245
+ #
246
+ # # if several record is returned:
247
+ # # => Will print "Found several network. Searching for 'forj'."
248
+ #
249
+ # # Considering query should return records with at least the attribute
250
+ # # :name, if the query return the wanted record, :name should be 'forj'.
251
+ # #
252
+ # # As defined by :items and :items_form, an item string will be set
253
+ # # with format('%s', record[:name]). ie 'forj'
254
+ # # So, in this case, query_single will print "Found network 'forj'."
255
+ def query_single(sCloudObj, sQuery, name, sInfoMsg = {}) #:doc:
179
256
  list = controller_query(sCloudObj, sQuery)
180
257
 
181
258
  info = _qs_info_init(sInfoMsg)
@@ -263,9 +340,6 @@ module Lorj
263
340
  end
264
341
  end
265
342
 
266
- # qs_info_init is not omplex as well described. Disabling rubocop
267
- # rubocop: disable PerceivedComplexity, CyclomaticComplexity
268
-
269
343
  def _qs_info_init(sInfoMsg)
270
344
  info = {
271
345
  :notfound => "No %s '%s' found",
@@ -276,13 +350,8 @@ module Lorj
276
350
  :items_form => '%s',
277
351
  :items => [:name]
278
352
  }
279
- info[:notfound] = sInfoMsg[:notfound] if sInfoMsg.key?(:notfound)
280
- info[:checkmatch] = sInfoMsg[:checkmatch] if sInfoMsg.key?(:checkmatch)
281
- info[:nomatch] = sInfoMsg[:nomatch] if sInfoMsg.key?(:nomatch)
282
- info[:found] = sInfoMsg[:found] if sInfoMsg.key?(:found)
283
- info[:more] = sInfoMsg[:more] if sInfoMsg.key?(:more)
284
- info[:items] = sInfoMsg[:items] if sInfoMsg.key?(:items)
285
- info[:items_form] = sInfoMsg[:items_form] if sInfoMsg.key?(:items_form)
353
+
354
+ info.each { |key, _| info[key] = sInfoMsg[key] if sInfoMsg.key?(key) }
286
355
  info
287
356
  end
288
357
  end
@@ -12,15 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # Module Lorj which contains several classes.
16
- #
17
- # Those classes describes :
18
- # - processes (BaseProcess) : How to create/delete/edit/query object.
19
- # - controler (BaseControler) : If a provider is defined, define how will do
20
- # object creation/etc...
21
- # - definition(BaseDefinition): Functions to declare objects, query/data mapping
22
- # and setup
23
- # this task to make it to work.
15
+ # - Lorj::Data : Defines how to manage Objects data between processes,
16
+ # controllers and internally in the core of Lorj.
24
17
  module Lorj
25
18
  # This class is the Data object used by lorj object!
26
19
  # This is a key component of lorj
@@ -48,9 +48,10 @@ module Lorj
48
48
  # puts oKey.tree # => [:test,:test2,:test3]
49
49
  #
50
50
  class KeyPath
51
- def initialize(sKeyPath = nil)
51
+ def initialize(sKeyPath = nil, max_level = -1)
52
52
  @keypath = []
53
- set sKeyPath
53
+ @max_level = max_level
54
+ set sKeyPath unless sKeyPath.nil?
54
55
  end
55
56
 
56
57
  def key=(sKeyPath)
@@ -65,6 +66,8 @@ module Lorj
65
66
  elsif sKeyPath.is_a?(String)
66
67
  @keypath = string_to_sarray(sKeyPath)
67
68
  end
69
+ PrcLib.error 'key path size limit (%s) reached',
70
+ @max_level if @max_level > 0 && @keypath.length > @max_level
68
71
  end
69
72
 
70
73
  def tree # rubocop: disable TrivialAccessors
@@ -17,13 +17,10 @@
17
17
 
18
18
  # It requires Core objects to be defined + default ForjProcess functions.
19
19
 
20
- # Define framework object on BaseDefinition
21
- module Lorj
22
- # Common definition
23
- class BaseDefinition
24
- # All objects used by this process are built from a Controller
25
- process_default :use_controller => true
26
- end
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
27
24
  end
28
25
 
29
26
  # Class to manage retry on errors before failing
@@ -17,6 +17,8 @@
17
17
 
18
18
  # It requires Core objects to be defined + default ForjProcess functions.
19
19
 
20
+ # rubocop: disable Style/ClassAndModuleChildren
21
+
20
22
  # Connection process code
21
23
  class CloudProcess
22
24
  def connect(sCloudObj, hParams)
@@ -36,58 +38,55 @@ class CloudProcess
36
38
  end
37
39
  end
38
40
 
39
- # Define framework object on BaseDefinition
40
- module Lorj
41
- # Define services model
42
- class BaseDefinition
43
- # predefined list of objects.
44
- # Links between objects is not predefined. To do it, use needs declaration
45
- # in your provider class.
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
46
 
47
- # object to get list of services
48
- # Defines Process handler to call
49
- define_obj(:services,
47
+ # object to get list of services
48
+ # Defines Process handler to call
49
+ define_obj(:services,
50
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
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
57
 
58
- undefine_attribute :id # Do not return any predefined ID
59
- undefine_attribute :name # Do not return any predefined NAME
60
- end
58
+ undefine_attribute :id # Do not return any predefined ID
59
+ undefine_attribute :name # Do not return any predefined NAME
60
+ end
61
61
 
62
- # compute_connection
63
- class BaseDefinition
64
- define_obj(:compute_connection,
62
+ # compute_connection
63
+ class Lorj::BaseDefinition
64
+ define_obj(:compute_connection,
65
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
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
73
 
74
- undefine_attribute :id # Do not return any predefined ID
75
- undefine_attribute :name # Do not return any predefined NAME
76
- end
74
+ undefine_attribute :id # Do not return any predefined ID
75
+ undefine_attribute :name # Do not return any predefined NAME
76
+ end
77
77
 
78
- # network_connection
79
- class BaseDefinition
80
- define_obj(:network_connection,
78
+ # network_connection
79
+ class Lorj::BaseDefinition
80
+ define_obj(:network_connection,
81
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
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
89
 
90
- undefine_attribute :id # Do not return any predefined ID
91
- undefine_attribute :name # Do not return any predefined NAME
92
- end
90
+ undefine_attribute :id # Do not return any predefined ID
91
+ undefine_attribute :name # Do not return any predefined NAME
93
92
  end