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



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 65

def update_candlepin_associations(consumer_params = nil)
  content_facet.cves_changed = false if content_facet
  content_facet&.save!

  auto_attach_enabled_via_checkin = consumer_params.try(:[], 'autoheal')

  if subscription_facet
    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
    ::Katello::Resources::Candlepin::Consumer.update(subscription_facet.uuid, consumer_params)

    if auto_attach_enabled_via_checkin
      ::Katello::Resources::Candlepin::Consumer.refresh_entitlements(subscription_facet.uuid)
    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