Class: ManageIQ::ApplianceConsole::LogfileConfiguration

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/manageiq/appliance_console/logfile_configuration.rb

Constant Summary collapse

LOGFILE_DIRECTORY =
Pathname.new("/var/www/miq/vmdb/log").freeze
LOGFILE_NAME =
"miq_logs".freeze
MIQ_LOGS_CONF =
Pathname.new("/etc/logrotate.d/miq_logs.conf").freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#error_and_logging_from_command_result_error, #error_and_logging_from_standard_error, #interactive, #interactive=, interactive?, #interactive?, #log_and_feedback, #log_and_feedback_exception, #log_and_feedback_info, #log_error, #log_prefix, #logger, #logger=, #say_error, #say_info

Constructor Details

#initialize(config = {}) ⇒ LogfileConfiguration

Returns a new instance of LogfileConfiguration.



17
18
19
20
21
22
23
24
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 17

def initialize(config = {})
  self.disk                = config[:disk]
  self.new_logrotate_count = nil

  self.size = Utilities.disk_usage(LOGFILE_DIRECTORY)[0][:total_bytes]
  self.current_logrotate_count = /rotate\s+(\d+)/.match(File.read(MIQ_LOGS_CONF))[1]
  self.evm_was_running = LinuxAdmin::Service.new("evmserverd").running?
end

Instance Attribute Details

#current_logrotate_countObject

Returns the value of attribute current_logrotate_count.



13
14
15
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 13

def current_logrotate_count
  @current_logrotate_count
end

#diskObject

Returns the value of attribute disk.



13
14
15
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 13

def disk
  @disk
end

#evm_was_runningObject

Returns the value of attribute evm_was_running.



13
14
15
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 13

def evm_was_running
  @evm_was_running
end

#new_logrotate_countObject

Returns the value of attribute new_logrotate_count.



13
14
15
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 13

def new_logrotate_count
  @new_logrotate_count
end

#sizeObject

Returns the value of attribute size.



13
14
15
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 13

def size
  @size
end

Instance Method Details

#activateObject



26
27
28
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 26

def activate
  activate_new_disk && activate_new_logrotate_count
end

#ask_questionsObject



30
31
32
33
34
35
# File 'lib/manageiq/appliance_console/logfile_configuration.rb', line 30

def ask_questions
  clear_screen
  choose_disk if use_new_disk
  choose_logrotate_count if set_new_logrotate_count?
  confirm_selection
end