Module: ForemanResourceQuota::HostManagedExtensions
- Extended by:
- ActiveSupport::Concern
- Includes:
- Exceptions, ResourceQuotaHelper
- Defined in:
- app/models/concerns/foreman_resource_quota/host_managed_extensions.rb
Constant Summary
ResourceQuotaHelper::FACTOR_B_TO_GB, ResourceQuotaHelper::FACTOR_B_TO_KB, ResourceQuotaHelper::FACTOR_B_TO_MB
Instance Method Summary
collapse
#find_largest_unit, #natural_resource_name_by_type, #resource_value_to_string, #units_by_type, #utilization_from_resource_origins
Instance Method Details
#resource_quota_id ⇒ Object
42
43
44
|
# File 'app/models/concerns/foreman_resource_quota/host_managed_extensions.rb', line 42
def resource_quota_id
resource_quota&.id
end
|
#resource_quota_id=(val) ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'app/models/concerns/foreman_resource_quota/host_managed_extensions.rb', line 46
def resource_quota_id=(val)
if val.blank?
resource_quota_host&.destroy
else
quota = ForemanResourceQuota::ResourceQuota.find_by(id: val)
raise ActiveRecord::RecordNotFound, "ResourceQuota with ID \"#{val}\" not found" unless quota
self.resource_quota = quota
end
end
|
#verify_resource_quota ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/models/concerns/foreman_resource_quota/host_managed_extensions.rb', line 25
def verify_resource_quota
handle_quota_check(resource_quota)
true
rescue ResourceQuotaException => e
handle_error('resource_quota_id',
e.bare_message,
format('An error occured while checking the resource quota capacity: %s', e))
rescue Foreman::Exception => e
handle_error(:base,
e.bare_message,
format('An unexpected Foreman error occured while checking the resource quota capacity: %s', e))
rescue StandardError => e
handle_error(:base,
e.message,
format('An unknown error occured while checking the resource quota capacity: %s', e))
end
|