Class: RedhatAccess::Api::LogsController
Constant Summary
collapse
- @@log_files =
Use temporary implementation to show proof of ooncept in beta release In GA a more robust implementation will be used @@log_files = [‘/var/log/foreman/production.log’,‘/var/log/foreman/delayed_job.log’,‘/var/log/foreman/jobs-startup.log’]
REDHAT_ACCESS_CONFIG[:diagnostic_logs]
Instance Method Summary
collapse
#api_request?, #http_error_response
Instance Method Details
#api_version ⇒ Object
44
45
46
|
# File 'app/controllers/redhat_access/api/logs_controller.rb', line 44
def api_version
'v1'
end
|
#get_available_logs ⇒ Object
28
29
30
31
32
33
|
# File 'app/controllers/redhat_access/api/logs_controller.rb', line 28
def get_available_logs
files = @@log_files.select do |file|
File.exist?(file) && File.readable?(file) && File.size(file) > 0
end
files.join("\n")
end
|
#is_valid_file?(file) ⇒ Boolean
35
36
37
|
# File 'app/controllers/redhat_access/api/logs_controller.rb', line 35
def is_valid_file? file
@@log_files.include?(file) && File.exist?(file) && File.readable?(file) && File.size(file) > 0
end
|
#logs ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/redhat_access/api/logs_controller.rb', line 11
def logs
path = params[:path]
if path.nil?
render :plain => get_available_logs, :layout => false
else
if is_valid_file? path
render :file => path, :layout => false
else
render :text => ''
end
end
end
|
#permission_denied ⇒ Object
40
41
42
|
# File 'app/controllers/redhat_access/api/logs_controller.rb', line 40
def permission_denied
render status: 403 , json: {:message => 'Permission denied.'}
end
|