Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions definitions/checks/disk/available_space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ module Disk
class AvailableSpace < ForemanMaintain::Check
metadata do
label :available_space
description 'Check to make sure root(/) partition has enough space'
# /var/cache usually contains the cache for the most used package-managers (rpm, apt...)
description 'Check if /var/cache partition has enough space for transaction:'
tags :pre_upgrade
end

MIN_SPACE_IN_MB = 4096

def run
assert(enough_space?, "System has less than #{MIN_SPACE_IN_MB / 1024}GB space available"\
' on root(/) partition')
' on /var/cache partition')
end

def enough_space?
io_obj = ForemanMaintain::Utils::Disk::IODevice.new('/')
device = ForemanMaintain::Utils::Disk::Device.new('/var/cache').name
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(device)
io_obj.available_space > MIN_SPACE_IN_MB
end
end
Expand Down