Sha256: 38b63b7a9da267b2c52349f5d79a4bbd4fd9e492e6ed2147dbb1ca2d16aba722

Contents?: true

Size: 1.4 KB

Versions: 13

Compression:

Stored size: 1.4 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 index
        #
        # 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 :template => "katello/common/403"
      end

      def api_version
        'v1'
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
redhat_access-2.0.12 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.11 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.10 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.9 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.8 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.7 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.6 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.5 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.4 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.3 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.2 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.1 app/controllers/redhat_access/api/logs_controller.rb
redhat_access-2.0.0 app/controllers/redhat_access/api/logs_controller.rb