Module: Katello::Concerns::SubscriptionFacetHostExtensions
- Extended by:
- ActiveSupport::Concern
- Includes:
- ScopedSearchExtensions
- Defined in:
- app/models/katello/concerns/subscription_facet_host_extensions.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#update_candlepin_associations(consumer_params = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 36 def update_candlepin_associations(consumer_params = nil) Rails.logger.debug "Updating Candlepin associations for host #{name}" content_facet.cvenvs_changed = false if content_facet content_facet&.save! if subscription_facet && !subscription_facet.destroyed? consumer_params ||= subscription_facet.consumer_attributes host_uuid = consumer_params.dig(:facts, 'dmi.system.uuid') if ::Katello::Host::SubscriptionFacet.override_dmi_uuid?(host_uuid) # if host reported a dmi uuid to treat as a duplicate, override it with the stored host param override_value = subscription_facet.dmi_uuid_override&.value override_value ||= subscription_facet.update_dmi_uuid_override&.value consumer_params[:facts]['dmi.system.uuid'] = override_value end begin ::Katello::Resources::Candlepin::Consumer.update(subscription_facet.uuid, consumer_params) rescue RestClient::Gone, RestClient::NotFound raise "Unable to update missing or deleted candlepin consumer uuid=#{subscription_facet.uuid} host_id=#{self.id}" end if consumer_params.try(:[], :facts) ::Katello::Host::SubscriptionFacet.update_facts(self, consumer_params[:facts]) end unless consumer_params.blank? subscription_facet.update_from_consumer_attributes(consumer_params) subscription_facet.save! end end end |