@@ -77,54 +77,6 @@ def file_exists?
7777 klass . new ( legacy_depot_hash ) . exist? ( log_uri )
7878 end
7979
80- # main UI method to call to request logs from a server
81- def self . logs_from_server ( *args )
82- options = args . extract_options!
83- userid = args [ 0 ] || "system"
84-
85- # If no server provided, use the MiqServer receiving this request
86- server = args [ 1 ] || MiqServer . my_server
87-
88- # All server types who provide logs must implement the following instance methods:
89- # - my_zone: which returns the zone in which they reside
90- # - who_am_i: which returns a log friendly string of the server's class and id
91- [ :my_zone , :who_am_i ] . each { |meth | raise "#{ meth } not implemented for #{ server . class . name } " unless server . respond_to? ( meth ) }
92- zone = server . my_zone
93- resource = server . who_am_i
94-
95- _log . info ( "Queueing the request by userid: [#{ userid } ] for logs from server: [#{ resource } ]" )
96-
97- begin
98- # Create the task for the UI to check
99- task = MiqTask . create ( :name => "Zipped log retrieval for [#{ resource } ]" , :userid => userid , :miq_server_id => server . id )
100-
101- # callback only on exceptions.. ie, on errors... second level callback will set status to finished
102- cb = { :class_name => task . class . name , :instance_id => task . id , :method_name => :queue_callback_on_exceptions , :args => [ 'Finished' ] }
103-
104- # Queue the async fetch of the logs from the server - specifying a timeout, the zone to process this request, and a callback
105- options = options . merge ( :taskid => task . id , :klass => server . class . name , :id => server . id )
106-
107- MiqQueue . put (
108- :class_name => name ,
109- :method_name => "_request_logs" ,
110- :args => [ options ] ,
111- :zone => zone ,
112- :miq_callback => cb ,
113- :msg_timeout => LOG_REQUEST_TIMEOUT ,
114- :priority => MiqQueue ::HIGH_PRIORITY
115- )
116- rescue => err
117- task . queue_callback_on_exceptions ( 'Finished' , 'error' , err . to_s , nil ) if task
118- raise
119- else
120- # return task id to the UI
121- msg = "Queued the request for logs from server: [#{ resource } ]"
122- task . update_status ( "Queued" , "Ok" , msg )
123- _log . info ( "Task: [#{ task . id } ] #{ msg } " )
124- task . id
125- end
126- end
127-
12880 def self . historical_logfile
12981 empty_logfile ( true )
13082 end
@@ -139,14 +91,6 @@ def self.empty_logfile(historical)
13991 :description => "Default logfile" )
14092 end
14193
142- def self . ping_timeout
143- ::Settings . log . collection . ping_depot_timeout
144- end
145-
146- def self . do_ping?
147- ::Settings . log . collection . ping_depot == true
148- end
149-
15094 def upload_log_file_ftp
15195 file_depot . upload_file ( self )
15296 end
@@ -222,51 +166,4 @@ def legacy_depot_hash
222166 :password => file_depot . authentication_password ,
223167 }
224168 end
225-
226- def self . _request_logs ( options )
227- taskid = options [ :taskid ]
228- klass = options . delete ( :klass ) . to_s
229- id = options . delete ( :id )
230-
231- log_header = "Task: [#{ taskid } ]"
232-
233- server = Object . const_get ( klass ) . find ( id )
234- resource = server . who_am_i
235-
236- # server must implement an instance method: started_on? which returns whether the server is started
237- unless server . respond_to? ( :started? )
238- raise MiqException ::Error , _ ( "started? not implemented for %{server_name}" ) % { :server_name => server . class . name }
239- end
240-
241- unless server . started?
242- if server . respond_to? ( :name )
243- raise MiqException ::Error ,
244- _ ( "Log request failed since [%{resource} %{server_name}] is not started" ) % { :resource => resource ,
245- :server_name => server . name }
246- else
247- raise MiqException ::Error ,
248- _ ( "Log request failed since [%{resource}] is not started" ) % { :resource => resource }
249- end
250- end
251-
252- task = MiqTask . find ( taskid )
253-
254- msg = "Requesting logs from server: [#{ resource } ]"
255- _log . info ( "#{ log_header } #{ msg } " )
256- task . update_status ( "Active" , "Ok" , msg )
257-
258- cb = { :class_name => task . class . name , :instance_id => task . id , :method_name => :queue_callback_on_exceptions , :args => [ 'Finished' ] }
259- unless server . respond_to? ( :_post_my_logs )
260- raise MiqException ::Error ,
261- _ ( "_post_my_logs not implemented for %{server_name}" ) % { :server_name => server . class . name }
262- end
263- options = options . merge ( :callback => cb , :timeout => LOG_REQUEST_TIMEOUT )
264- server . _post_my_logs ( options )
265-
266- msg = "Requested logs from: [#{ resource } ]"
267- _log . info ( "#{ log_header } #{ msg } " )
268- task . update_status ( "Queued" , "Ok" , msg )
269- end
270-
271- private_class_method :_request_logs
272169end
0 commit comments