From 8edb6169d3c8a0d69c636b8582133bed1eba5f53 Mon Sep 17 00:00:00 2001 From: Rafael Gomez Date: Tue, 12 Nov 2024 11:21:06 +0000 Subject: [PATCH] Refactor harddisk_services to check active services, decrease root size and 90% of maxsize --- resources/libraries/harddisk_services.rb | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/resources/libraries/harddisk_services.rb b/resources/libraries/harddisk_services.rb index 2eb018f..7a4a387 100644 --- a/resources/libraries/harddisk_services.rb +++ b/resources/libraries/harddisk_services.rb @@ -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