diff --git a/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb b/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb index 989a555..3d9793f 100644 --- a/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb +++ b/app/models/concerns/foreman_resource_quota/host_managed_extensions.rb @@ -19,6 +19,7 @@ module HostManagedExtensions # A host shall always have a .host_resources attribute before_validation :build_host_resources, unless: -> { host_resources.present? } + after_save :save_host_resources, if: -> { host_resources.changed? } end def verify_resource_quota @@ -141,6 +142,10 @@ def quota_assigment_optional? owner.resource_quota_is_optional || Setting[:resource_quota_optional_assignment] end + def save_host_resources + host_resources.save + end + # Wrap into a function for easier testing def call_utilization_helper(resources, hosts) all_host_resources, missing_hosts = utilization_from_resource_origins(resources, hosts)