Sha256: 14f8ad78a45c48800a514229c537b6d81aa9dc389e49d40afb8a059cb0fc0d86

Contents?: true

Size: 1.42 KB

Versions: 38

Compression:

Stored size: 1.42 KB

Contents

require_dependency "redhat_access/application_controller"

module RedhatAccess
  module Api
    class LogsController < RedhatAccess::Api::ApiController
      # 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']
      @@log_files = REDHAT_ACCESS_CONFIG[:diagnostic_logs]

      def logs
        #
        # This REST hack of using index for both list and specific resource get
        # is being forced by the current UI design
        #
        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

      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

      def is_valid_file?  file
        @@log_files.include?(file) && File.exist?(file) && File.readable?(file) && File.size(file) > 0
      end


      def permission_denied
        render status: 403 , json: {:message => 'Permission denied.'}
      end

      def api_version
        'v1'
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
redhat_access-2.9.1 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.8.1 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.20 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.19 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.18 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.17 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.16 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.15 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.14 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.13 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.12 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.11 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.10 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.9 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.8 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.2.7 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.1.10 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.17 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.16 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.1.9 app/controllers/redhat_access/api/logs_controller.rb