Class: ForemanMaintain::Utils::Disk::Device

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Concerns::SystemHelpers
Defined in:
lib/foreman_maintain/utils/disk/device.rb

Constant Summary collapse

EXTERNAL_MOUNT_TYPE =
%w[fuseblk nfs].freeze

Constants included from Concerns::OsFacts

Concerns::OsFacts::FALLBACK_OS_RELEASE_FILE, Concerns::OsFacts::OS_RELEASE_FILE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::SystemHelpers

#check_max_version, #check_min_version, #command_present?, #create_lv_snapshot, #directory_empty?, #execute, #execute!, #execute?, #execute_runner, #execute_with_status, #file_exists?, #file_nonzero?, #find_dir_containing_file, #find_package, #find_symlinks, #foreman_plugin_name, #format_shell_args, #get_lv_info, #get_lv_path, #hammer_package, #hammer_plugin_name, #hostname, included, #package_manager, #package_version, #packages_action, #parse_csv, #parse_json, #proxy_plugin_name, #repository_manager, #ruby_prefix, #server?, #shellescape, #systemd_installed?, #version

Methods included from Concerns::OsFacts

#centos?, #cpu_cores, #deb_major_version, #debian?, #debian_or_ubuntu?, #el7?, #el8?, #el?, #el_major_version, #el_short_name, #facts, #memory, #os_id, #os_id_like_list, #os_name, #os_release_file, #os_version, #os_version_codename, #os_version_id, #rhel?, #ubuntu?, #ubuntu_major_version

Methods included from Concerns::Finders

#check, #detector, #feature, #find_all_scenarios, #find_checks, #find_procedures, #find_scenarios, #procedure

Methods included from Concerns::Logger

#logger

Constructor Details

#initialize(dir) ⇒ Device

Returns a new instance of Device.



17
18
19
20
21
22
# File 'lib/foreman_maintain/utils/disk/device.rb', line 17

def initialize(dir)
  @dir = dir
  @name = find_device
  logger.info "#{dir} is externally mounted" if externally_mounted?
  @io_device = IODevice.new(dir)
end

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



11
12
13
# File 'lib/foreman_maintain/utils/disk/device.rb', line 11

def dir
  @dir
end

#io_deviceObject (readonly)

Returns the value of attribute io_device.



13
14
15
# File 'lib/foreman_maintain/utils/disk/device.rb', line 13

def io_device
  @io_device
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/foreman_maintain/utils/disk/device.rb', line 11

def name
  @name
end

#read_speedObject

Returns the value of attribute read_speed.



11
12
13
# File 'lib/foreman_maintain/utils/disk/device.rb', line 11

def read_speed
  @read_speed
end

#unitObject

Returns the value of attribute unit.



11
12
13
# File 'lib/foreman_maintain/utils/disk/device.rb', line 11

def unit
  @unit
end

Instance Method Details

#performanceObject



30
31
32
# File 'lib/foreman_maintain/utils/disk/device.rb', line 30

def performance
  "#{read_speed} #{unit}"
end

#slow_disk_error_msgObject



24
25
26
27
28
# File 'lib/foreman_maintain/utils/disk/device.rb', line 24

def slow_disk_error_msg
  "Slow disk detected #{dir} mounted on #{name}.
     Actual disk speed: #{read_speed} #{default_unit}
     Expected disk speed: #{expected_io} #{default_unit}."
end