Skip to content

Commit

Permalink
Refactor harddisk_services to check active services, decrease root si…
Browse files Browse the repository at this point in the history
…ze and 90% of maxsize
  • Loading branch information
rgomezborder committed Nov 12, 2024
1 parent eab6d1a commit 8edb616
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions resources/libraries/harddisk_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ module RbManager
module Helpers
def harddisk_services
hd_services = {}
root_dev_bytes = node['filesystem']['by_mountpoint']['/']['kb_size'].to_i * 1024
node['redborder']['manager']['hd_services'].each do |service|
service_name = service['name']
service_count = service['count']
allocated_bytes = root_dev_bytes * (service_count.to_f / 100)
hd_services[service_name] = allocated_bytes.to_i
root_dev_kb = node['filesystem']['by_mountpoint']['/']['kb_size']
size_bytes = root_dev_kb.to_i * 1024
size_bytes -= 7 * 1024 * 1024 * 1024
maxsize = size_bytes

hd_services_dev = node['redborder']['manager']['hd_services'].map do |service|
{
name: service[:name],
count: node['redborder']['services'][service[:name]] ? service[:count] + 1 : service[:count]
}
end

hd_services_dev.each do |service|
service_count = service[:count].to_f / 100
hd_services[service[:name]] = service_count * maxsize * 0.90
end

hd_services # hard disk services sizes are pased in bytes
end
end
Expand Down

0 comments on commit 8edb616

Please sign in to comment.