@@ -90,9 +90,10 @@ def self.concrete_subclasses
9090 leaf_subclasses | descendants . select { |d | d . try ( :acts_as_sti_leaf_class? ) }
9191 end
9292
93- class_attribute :default_queue_name , :required_roles , :maximum_workers_count , :include_stopping_workers_on_synchronize
93+ class_attribute :default_queue_name , :required_roles , :maximum_workers_count , :include_stopping_workers_on_synchronize , :worker_settings_paths
9494 self . include_stopping_workers_on_synchronize = false
9595 self . required_roles = [ ]
96+ self . worker_settings_paths = [ ]
9697
9798 def self . server_scope
9899 return current_scope if current_scope && current_scope . where_values_hash . include? ( 'miq_server_id' )
@@ -205,31 +206,38 @@ def self.fetch_worker_settings_from_options_hash(options_hash, raw = false)
205206 classes . each do |c |
206207 section = section [ c ]
207208 raise _ ( "Missing config section %{section_name}" ) % { :section_name => c } if section . nil?
209+
208210 defaults = section [ :defaults ]
209211 unless defaults . nil?
210- defaults . delete_if { | k , v | v == Vmdb ::Settings ::RESET_VALUE }
212+ defaults . delete_if { | _k , v | v == Vmdb ::Settings ::RESET_VALUE }
211213 settings . merge! ( defaults )
212214 end
213215 end
214216
215- section . delete_if { | k , v | v == Vmdb ::Settings ::RESET_VALUE }
217+ section . delete_if { | _k , v | v == Vmdb ::Settings ::RESET_VALUE }
216218 settings . merge! ( section )
219+ normalize_settings! ( settings ) unless raw == true
220+ end
217221
218- # If not specified, provide the worker_settings cleaned up in fixnums, etc. instead of 1.seconds, 10.megabytes
219- # Clean up the configuration values in a format like "30.seconds"
220- unless raw == true
221- settings . keys . each do |k |
222- if settings [ k ] . kind_of? ( String )
223- if settings [ k ] . number_with_method?
224- settings [ k ] = settings [ k ] . to_i_with_method
225- elsif settings [ k ] =~ /\A \d +(.\d +)?\z / # case where int/float saved as string
226- settings [ k ] = settings [ k ] . to_i
227- end
228- end
222+ settings
223+ end
224+
225+ # If not specified, provide the worker_settings cleaned up in fixnums, etc. instead of 1.seconds, 10.megabytes
226+ # and decrypt any values which are encrypted with ManageIQ::Password.
227+ def self . normalize_settings! ( settings , recurse : false )
228+ settings . each_key do |k |
229+ if settings [ k ] . kind_of? ( Hash ) && recurse
230+ normalize_settings! ( settings [ k ] )
231+ elsif settings [ k ] . kind_of? ( String )
232+ if settings [ k ] . number_with_method?
233+ settings [ k ] = settings [ k ] . to_i_with_method
234+ elsif settings [ k ] . match? ( /\A \d +(.\d +)?\z / ) # case where int/float saved as string
235+ settings [ k ] = settings [ k ] . to_i
236+ elsif ManageIQ ::Password . encrypted? ( settings [ k ] )
237+ settings [ k ] = ManageIQ ::Password . decrypt ( settings [ k ] )
229238 end
230239 end
231240 end
232- settings
233241 end
234242
235243 def worker_settings ( options = { } )
0 commit comments