diff --git a/app/controllers/katello/concerns/hosts_controller_extensions.rb b/app/controllers/katello/concerns/hosts_controller_extensions.rb index f19c3742103..dbe4177f380 100644 --- a/app/controllers/katello/concerns/hosts_controller_extensions.rb +++ b/app/controllers/katello/concerns/hosts_controller_extensions.rb @@ -63,11 +63,11 @@ def content_hosts .preload(:subscription_facet, :host_statuses, :operatingsystem, :applicable_rpms, :content_view_environments) csv_response(@hosts, - [:name, :subscription_status_label, 'content_facet.installable_security_errata_count', + [:name, 'content_facet.installable_security_errata_count', 'content_facet.installable_bugfix_errata_count', 'content_facet.installable_enhancement_errata_count', 'content_facet.upgradable_rpm_count', :operatingsystem, :content_view_environment_names, 'subscription_facet.registered_at', 'subscription_facet.last_checkin'], - ['Name', 'Subscription Status', 'Installable Updates - Security', + ['Name', 'Installable Updates - Security', 'Installable Updates - Bug Fixes', 'Installable Updates - Enhancements', 'Installable Updates - Package Count', 'OS', 'Content View Environments', 'Registered', 'Last Checkin']) diff --git a/app/helpers/katello/concerns/dashboard_helper_extensions.rb b/app/helpers/katello/concerns/dashboard_helper_extensions.rb index 4bbbb8acb7e..3e5a71bb5a8 100644 --- a/app/helpers/katello/concerns/dashboard_helper_extensions.rb +++ b/app/helpers/katello/concerns/dashboard_helper_extensions.rb @@ -9,26 +9,6 @@ def total_host_count host_query.size end - def partial_consumer_count - host_query.search_for("subscription_status = partial").size - end - - def valid_consumer_count - host_query.search_for("subscription_status = valid").size - end - - def invalid_consumer_count - host_query.search_for("subscription_status = invalid").size - end - - def unknown_consumer_count - host_query.search_for("subscription_status = unknown or (null? subscription_uuid)").size - end - - def unsubscribed_hypervisor_count - host_query.search_for("subscription_status = unsubscribed_hypervisor").size - end - def removed_widgets widgets = super diff --git a/app/lib/actions/katello/host/hypervisors_update.rb b/app/lib/actions/katello/host/hypervisors_update.rb index efbb9a2210d..70815bffad7 100644 --- a/app/lib/actions/katello/host/hypervisors_update.rb +++ b/app/lib/actions/katello/host/hypervisors_update.rb @@ -170,7 +170,6 @@ def update_subscription_facet(uuid, host) host.subscription_facet.candlepin_consumer.consumer_attributes = @candlepin_attributes[uuid] host.subscription_facet.import_database_attributes host.subscription_facet.save! - host.subscription_facet.update_subscription_status(@candlepin_attributes[uuid].try(:[], :entitlementStatus)) end end diff --git a/app/models/katello/concerns/host_managed_extensions.rb b/app/models/katello/concerns/host_managed_extensions.rb index 18a917977d5..c483fa6b772 100644 --- a/app/models/katello/concerns/host_managed_extensions.rb +++ b/app/models/katello/concerns/host_managed_extensions.rb @@ -410,18 +410,6 @@ def import_tracer_profile(tracer_profile) update_trace_status end - def subscription_status - @subscription_status ||= get_status(::Katello::SubscriptionStatus).status - end - - def subscription_status_label(options = {}) - @subscription_status_label ||= get_status(::Katello::SubscriptionStatus).to_label(options) - end - - def subscription_global_status - @subscription_global_status ||= get_status(::Katello::SubscriptionStatus).to_global - end - def errata_status @errata_status ||= get_status(::Katello::ErrataStatus).status end @@ -430,46 +418,6 @@ def errata_status_label(options = {}) @errata_status_label ||= get_status(::Katello::ErrataStatus).to_label(options) end - def purpose_status - @purpose_status ||= get_status(::Katello::PurposeStatus).status - end - - def purpose_status_label(options = {}) - @purpose_status_label ||= get_status(::Katello::PurposeStatus).to_label(options) - end - - def purpose_sla_status - @purpose_sla_status ||= get_status(::Katello::PurposeSlaStatus).status - end - - def purpose_sla_status_label(options = {}) - @purpose_sla_status_label ||= get_status(::Katello::PurposeSlaStatus).to_label(options) - end - - def purpose_role_status - @purpose_role_status ||= get_status(::Katello::PurposeRoleStatus).status - end - - def purpose_role_status_label(options = {}) - @purpose_role_status_label ||= get_status(::Katello::PurposeRoleStatus).to_label(options) - end - - def purpose_usage_status - @purpose_usage_status ||= get_status(::Katello::PurposeUsageStatus).status - end - - def purpose_usage_status_label(options = {}) - @purpose_usage_status_label ||= get_status(::Katello::PurposeUsageStatus).to_label(options) - end - - def purpose_addons_status - @purpose_addons_status ||= get_status(::Katello::PurposeAddonsStatus).status - end - - def purpose_addons_status_label(options = {}) - @purpose_addons_status_label ||= get_status(::Katello::PurposeAddonsStatus).to_label(options) - end - def rhel_lifecycle_global_status @rhel_lifecycle_global_status ||= get_status(::Katello::RhelLifecycleStatus).to_global end @@ -602,8 +550,7 @@ class ::Host::Managed::Jail < Safemode::Jail :host_collections, :pools, :hypervisor_host, :installed_debs, :installed_packages, :traces_helpers, :advisory_ids, :package_names_for_job_template, :filtered_entitlement_quantity_consumed, :bound_repositories, - :single_content_view, :single_lifecycle_environment, :purpose_role, :purpose_usage, :release_version, - :purpose_role_status_label, :purpose_usage_status_label + :single_content_view, :single_lifecycle_environment, :release_version end class ActiveRecord::Associations::CollectionProxy::Jail < Safemode::Jail diff --git a/app/models/katello/concerns/subscription_facet_host_extensions.rb b/app/models/katello/concerns/subscription_facet_host_extensions.rb index 84169844279..50087fce980 100644 --- a/app/models/katello/concerns/subscription_facet_host_extensions.rb +++ b/app/models/katello/concerns/subscription_facet_host_extensions.rb @@ -10,38 +10,15 @@ module SubscriptionFacetHostExtensions included do audited :associations => [:pools] - SUBSCRIPTION_STATUS_MAP = { - :valid => Katello::SubscriptionStatus::VALID, - :partial => Katello::SubscriptionStatus::PARTIAL, - :invalid => Katello::SubscriptionStatus::INVALID, - :unknown => Katello::SubscriptionStatus::UNKNOWN, - :disabled => Katello::SubscriptionStatus::DISABLED, - :unsubscribed_hypervisor => Katello::SubscriptionStatus::UNSUBSCRIBED_HYPERVISOR - }.freeze - accepts_nested_attributes_for :subscription_facet, :update_only => true, :reject_if => lambda { |attrs| attrs.values.compact.empty? } has_many :activation_keys, :through => :subscription_facet has_many :pools, :through => :subscription_facet has_many :purpose_addons, :through => :subscription_facet has_many :subscriptions, :through => :pools - has_one :subscription_status_object, :class_name => 'Katello::SubscriptionStatus', :foreign_key => 'host_id', :dependent => :destroy - has_one :purpose_sla_status_object, :class_name => 'Katello::PurposeSlaStatus', :foreign_key => 'host_id', :dependent => :destroy - has_one :purpose_role_status_object, :class_name => 'Katello::PurposeRoleStatus', :foreign_key => 'host_id', :dependent => :destroy - has_one :purpose_usage_status_object, :class_name => 'Katello::PurposeUsageStatus', :foreign_key => 'host_id', :dependent => :destroy - has_one :purpose_addons_status_object, :class_name => 'Katello::PurposeAddonsStatus', :foreign_key => 'host_id', :dependent => :destroy - has_one :purpose_status_object, :class_name => 'Katello::PurposeStatus', :foreign_key => 'host_id', :dependent => :destroy has_one :rhel_lifecycle_status_object, :class_name => 'Katello::RhelLifecycleStatus', :foreign_key => 'host_id', :dependent => :destroy has_one :hypervisor_host, :through => :subscription_facet - scoped_search :on => :status, :relation => :subscription_status_object, :rename => :subscription_status, - :complete_value => SUBSCRIPTION_STATUS_MAP - - scoped_search on: :status, relation: :purpose_sla_status_object, rename: :sla_status, complete_value: purpose_status_map - scoped_search on: :status, relation: :purpose_role_status_object, rename: :role_status, complete_value: purpose_status_map - scoped_search on: :status, relation: :purpose_usage_status_object, rename: :usage_status, complete_value: purpose_status_map - scoped_search on: :status, relation: :purpose_addons_status_object, rename: :addons_status, complete_value: purpose_status_map - scoped_search on: :status, relation: :purpose_status_object, rename: :purpose_status, complete_value: purpose_status_map scoped_search on: :status, relation: :rhel_lifecycle_status_object, rename: :rhel_lifecycle_status, complete_value: rhel_lifecycle_status_map scoped_search :on => :release_version, :relation => :subscription_facet, :complete_value => true, :only_explicit => true @@ -98,10 +75,6 @@ def update_candlepin_associations(consumer_params = nil) end module ClassMethods - def purpose_status_map - ::Katello::PurposeStatus.status_map - end - def rhel_lifecycle_status_map ::Katello::RhelLifecycleStatus.status_map end diff --git a/app/models/katello/concerns/widget_extensions.rb b/app/models/katello/concerns/widget_extensions.rb deleted file mode 100644 index 0168351c6b3..00000000000 --- a/app/models/katello/concerns/widget_extensions.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Katello - module Concerns - module WidgetExtensions - extend ActiveSupport::Concern - - module ClassMethods - SUBSCRIPTION_TEMPLATES = %w[subscription_status_widget subscription_widget].freeze - - def without_subscription_widgets - where.not(template: ::Widget.singleton_class::SUBSCRIPTION_TEMPLATES) - end - - def available - if Organization.current&.simple_content_access? - super.without_subscription_widgets - else - super - end - end - end - end - end -end diff --git a/app/models/katello/host/subscription_facet.rb b/app/models/katello/host/subscription_facet.rb index 9c4aa68d8e6..eafccd10113 100644 --- a/app/models/katello/host/subscription_facet.rb +++ b/app/models/katello/host/subscription_facet.rb @@ -49,7 +49,6 @@ def update_from_consumer_attributes(consumer_params) end def import_database_attributes(consumer_params = candlepin_consumer.consumer_attributes) - update_subscription_status(consumer_params[:entitlementStatus]) unless consumer_params[:entitlementStatus].blank? update_hypervisor(consumer_params) update_guests(consumer_params) @@ -182,24 +181,6 @@ def update_dmi_uuid_override(host_uuid = nil) param end - def update_subscription_status(status_override = nil) - update_status(::Katello::SubscriptionStatus, status_override: status_override) - - host.refresh_global_status! - end - - def update_purpose_status(sla_status: nil, role_status: nil, usage_status: nil, addons_status: nil, purpose_status: nil) - # if this method is ever called such that we aren't sending the status params, we should pass along the candlepin_consumer - # in order to reduce HTTP requests into candlepin for each Status - update_status(::Katello::PurposeSlaStatus, status_override: sla_status) - update_status(::Katello::PurposeRoleStatus, status_override: role_status) - update_status(::Katello::PurposeUsageStatus, status_override: usage_status) - update_status(::Katello::PurposeAddonsStatus, status_override: addons_status) - update_status(::Katello::PurposeStatus, status_override: purpose_status) - - host.refresh_global_status! - end - def self.override_dmi_uuid?(host_uuid) Setting[:host_dmi_uuid_duplicates].include?(host_uuid) end diff --git a/app/models/katello/purpose_addons_status.rb b/app/models/katello/purpose_addons_status.rb deleted file mode 100644 index 75893e570c3..00000000000 --- a/app/models/katello/purpose_addons_status.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Katello - class PurposeAddonsStatus < HostStatus::Status - UNKNOWN = Katello::PurposeStatus::UNKNOWN - def self.status_name - N_('Addons') - end - - def self.humanized_name - 'purpose_addons' - end - - def to_label(_options = {}) - Katello::PurposeStatus.to_label(status) - end - - def to_status(options = {}) - Katello::PurposeStatus.to_status(self, :addons_status, options) - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - - def substatus?(_options = {}) - true - end - end -end diff --git a/app/models/katello/purpose_role_status.rb b/app/models/katello/purpose_role_status.rb deleted file mode 100644 index 3a5aee9ef20..00000000000 --- a/app/models/katello/purpose_role_status.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Katello - class PurposeRoleStatus < HostStatus::Status - UNKNOWN = Katello::PurposeStatus::UNKNOWN - def self.status_name - N_('Role') - end - - def self.humanized_name - 'purpose_role' - end - - def to_label(_options = {}) - Katello::PurposeStatus.to_label(status) - end - - def to_status(options = {}) - Katello::PurposeStatus.to_status(self, :role_status, options) - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - - def substatus?(_options = {}) - true - end - end -end diff --git a/app/models/katello/purpose_sla_status.rb b/app/models/katello/purpose_sla_status.rb deleted file mode 100644 index 0d85f17294e..00000000000 --- a/app/models/katello/purpose_sla_status.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Katello - class PurposeSlaStatus < HostStatus::Status - UNKNOWN = Katello::PurposeStatus::UNKNOWN - def self.status_name - N_('Service level') - end - - def self.humanized_name - 'purpose_sla' - end - - def to_label(_options = {}) - Katello::PurposeStatus.to_label(status) - end - - def to_status(options = {}) - Katello::PurposeStatus.to_status(self, :sla_status, options) - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - - def substatus?(_options = {}) - true - end - end -end diff --git a/app/models/katello/purpose_status.rb b/app/models/katello/purpose_status.rb deleted file mode 100644 index b83cda2b4d1..00000000000 --- a/app/models/katello/purpose_status.rb +++ /dev/null @@ -1,71 +0,0 @@ -module Katello - class PurposeStatus < HostStatus::Status - UNKNOWN = 0 - MISMATCHED = 1 - MATCHED = 2 - NOT_SPECIFIED = 3 - - def self.status_map - map = { - mismatched: MISMATCHED, - matched: MATCHED, - not_specified: NOT_SPECIFIED - } - - map.default = UNKNOWN - map - end - - def self.status_name - N_('System purpose') - end - - def self.humanized_name - 'purpose' - end - - def self.to_label(status) - case status - when MATCHED - N_('Matched') - when MISMATCHED - N_('Mismatched') - when NOT_SPECIFIED - N_('Not specified') - else - N_('Unknown') - end - end - - def self.to_status(status, purpose_method, options) - return UNKNOWN unless status.relevant? - - if options.key?(:status_override) - return self.status_map[options[:status_override]] - end - - consumer = status.host.subscription_facet.candlepin_consumer - self.status_map[consumer.system_purpose.send(purpose_method)] - end - - def to_label(_options = {}) - self.class.to_label(status) - end - - def to_global(_options = {}) - if [MATCHED, UNKNOWN, NOT_SPECIFIED].include?(status) - ::HostStatus::Global::OK - else - ::HostStatus::Global::WARN - end - end - - def to_status(options = {}) - self.class.to_status(self, :overall_status, options) - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - end -end diff --git a/app/models/katello/purpose_usage_status.rb b/app/models/katello/purpose_usage_status.rb deleted file mode 100644 index 6c14fb78c7d..00000000000 --- a/app/models/katello/purpose_usage_status.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Katello - class PurposeUsageStatus < HostStatus::Status - UNKNOWN = Katello::PurposeStatus::UNKNOWN - def self.status_name - N_('Usage') - end - - def self.humanized_name - 'purpose_usage' - end - - def to_label(_options = {}) - Katello::PurposeStatus.to_label(status) - end - - def to_status(options = {}) - Katello::PurposeStatus.to_status(self, :usage_status, options) - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - - def substatus?(_options = {}) - true - end - end -end diff --git a/app/models/katello/subscription_status.rb b/app/models/katello/subscription_status.rb deleted file mode 100644 index c33b0cde635..00000000000 --- a/app/models/katello/subscription_status.rb +++ /dev/null @@ -1,71 +0,0 @@ -module Katello - class SubscriptionStatus < HostStatus::Status - DISABLED = 5 - UNSUBSCRIBED_HYPERVISOR = 4 - UNKNOWN = 3 - INVALID = 2 - PARTIAL = 1 - VALID = 0 - - def self.status_name - N_("Subscription") - end - - def to_label(_options = {}) - case status - when VALID - N_("Fully entitled") - when PARTIAL - N_("Partially entitled") - when INVALID - N_("Unentitled") - when UNSUBSCRIBED_HYPERVISOR - N_("Unsubscribed hypervisor") - when DISABLED - N_("Simple Content Access") - else - N_("Unknown subscription status") - end - end - - def to_global(_options = {}) - case status - when INVALID - ::HostStatus::Global::ERROR - when DISABLED - ::HostStatus::Global::OK - when VALID - ::HostStatus::Global::OK - else - ::HostStatus::Global::WARN - end - end - - def to_status(options = {}) - return UNKNOWN unless host.subscription_facet.try(:uuid) - return DISABLED if host.organization.simple_content_access? - status_override = 'unsubscribed_hypervisor' if host.subscription_facet.unsubscribed_hypervisor? - status_override ||= options.fetch(:status_override, nil) - status = status_override || host.subscription_facet.candlepin_consumer.entitlement_status - - case status - when Katello::Candlepin::Consumer::ENTITLEMENTS_DISABLED - DISABLED - when Katello::Candlepin::Consumer::ENTITLEMENTS_VALID - VALID - when Katello::Candlepin::Consumer::ENTITLEMENTS_PARTIAL - PARTIAL - when Katello::Candlepin::Consumer::ENTITLEMENTS_INVALID - INVALID - when 'unsubscribed_hypervisor' - UNSUBSCRIBED_HYPERVISOR - else - UNKNOWN - end - end - - def relevant?(_options = {}) - host.subscription_facet.try(:uuid) - end - end -end diff --git a/app/services/katello/candlepin/consumer.rb b/app/services/katello/candlepin/consumer.rb index 4dd7ca5c6d7..3d8f0328f40 100644 --- a/app/services/katello/candlepin/consumer.rb +++ b/app/services/katello/candlepin/consumer.rb @@ -118,10 +118,6 @@ def compliance_reasons self.class.friendly_compliance_reasons(Resources::Candlepin::Consumer.compliance(uuid)['reasons']) end - def system_purpose - @system_purpose ||= Katello::Candlepin::SystemPurpose.new(purpose_compliance) - end - def entitlements? # use cahced consumer_attributes if possible count = @consumer_attributes.try(:[], 'entitlementCount') diff --git a/app/services/katello/candlepin/event_handler.rb b/app/services/katello/candlepin/event_handler.rb index fa4d073c7f5..a9df69163c4 100644 --- a/app/services/katello/candlepin/event_handler.rb +++ b/app/services/katello/candlepin/event_handler.rb @@ -26,9 +26,9 @@ def handle(message) when /pool\.deleted/ message_handler.delete_pool when /^compliance\.created/ - reindex_subscription_status + event_no_longer_handled when /system_purpose_compliance\.created/ - reindex_purpose_status + event_no_longer_handled when /owner_content_access_mode\.modified/ message_handler.handle_content_access_mode_modified end @@ -37,31 +37,12 @@ def handle(message) private - def subscription_facet - message_handler.subscription_facet + def event_no_longer_handled + @logger.error "Received #{message_handler.subject} event from Candlepin. Handling of this event is no longer supported." end - def reindex_subscription_status - if message_handler.status.nil? - @logger.debug "skip re-indexing of empty #{message_handler.subject} status #{message_handler.consumer_uuid}" - return - end - - reindex_consumer do - subscription_facet.update_subscription_status(message_handler.status) - subscription_facet.update_compliance_reasons(message_handler.reasons) - end - end - - def reindex_purpose_status - reindex_consumer do - return if subscription_facet.host.organization.simple_content_access? - subscription_facet.update_purpose_status(role_status: message_handler.system_purpose.role_status, - usage_status: message_handler.system_purpose.usage_status, - addons_status: message_handler.system_purpose.addons_status, - sla_status: message_handler.system_purpose.sla_status, - purpose_status: message_handler.system_purpose.overall_status) - end + def subscription_facet + message_handler.subscription_facet end def reindex_consumer diff --git a/app/services/katello/candlepin/message_handler.rb b/app/services/katello/candlepin/message_handler.rb index d7a072dd247..1fbeb4e042e 100644 --- a/app/services/katello/candlepin/message_handler.rb +++ b/app/services/katello/candlepin/message_handler.rb @@ -42,13 +42,6 @@ def consumer_uuid content['consumerUuid'] end - def system_purpose - if subject == 'system_purpose_compliance.created' && @system_purpose.nil? - @system_purpose = Katello::Candlepin::SystemPurpose.new(event_data) - end - @system_purpose - end - def pool_id if subject == 'pool.created' || subject == 'pool.deleted' content['entityId'] @@ -105,21 +98,8 @@ def handle_content_access_mode_modified end org = ::Organization.find_by!(label: owner['key']) - hosts = org.hosts - - if event_data['contentAccessMode'] == 'org_environment' - Katello::HostStatusManager.clear_syspurpose_status(hosts) - Katello::HostStatusManager.update_subscription_status_to_sca(hosts) - elsif event_data['contentAccessMode'] == 'entitlement' - cp_consumer_uuids = hosts.joins(:subscription_facet).pluck("#{Katello::Host::SubscriptionFacet.table_name}.uuid") - cp_consumer_uuids.each do |uuid| - Katello::Resources::Candlepin::Consumer.compliance(uuid) - Katello::Resources::Candlepin::Consumer.purpose_compliance(uuid) - rescue => e - Rails.logger.error("Error encountered while fetching compliance for consumer #{uuid}: #{e.message}") - end - end + Rails.logger.error "Received content_access_mode_modified event for org #{org.label}. This event is no longer supported." org.simple_content_access?(cached: false) end diff --git a/app/services/katello/candlepin/system_purpose.rb b/app/services/katello/candlepin/system_purpose.rb deleted file mode 100644 index 62eb8087711..00000000000 --- a/app/services/katello/candlepin/system_purpose.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Katello - module Candlepin - class SystemPurpose - attr_reader :compliance - - # the purpose compliance of a consumer and via event queue - # are in the same format so we can parse them identically - def initialize(purpose_compliance) - @compliance = purpose_compliance - end - - def overall_status - if compliance['status'] == 'not specified' - :not_specified - elsif compliance['status'] == 'matched' - :matched - elsif compliance['status'] == 'mismatched' - :mismatched - end - end - - def sla_status - purpose_status(compliance['compliantSLA'], compliance['nonCompliantSLA']) - end - - def role_status - purpose_status(compliance['compliantRole'], compliance['nonCompliantRole']) - end - - def usage_status - purpose_status(compliance['compliantUsage'], compliance['nonCompliantUsage']) - end - - def addons_status - purpose_status(compliance['compliantAddons'], compliance['nonCompliantAddons']) - end - - def purpose_status(compliant, noncompliant) - if (noncompliant.nil? || noncompliant.try(:empty?)) && compliant.empty? - :not_specified - elsif noncompliant.nil? || noncompliant.try(:empty?) - :matched - elsif noncompliant.present? - :mismatched - end - end - end - end -end diff --git a/app/services/katello/host_status_manager.rb b/app/services/katello/host_status_manager.rb index 343ee458cbf..d64667e51a7 100644 --- a/app/services/katello/host_status_manager.rb +++ b/app/services/katello/host_status_manager.rb @@ -2,29 +2,7 @@ module Katello class HostStatusManager STATUSES = [ Katello::ErrataStatus, - Katello::SubscriptionStatus, - Katello::PurposeSlaStatus, - Katello::PurposeRoleStatus, - Katello::PurposeUsageStatus, - Katello::PurposeAddonsStatus, - Katello::PurposeStatus, Katello::RhelLifecycleStatus, Katello::TraceStatus].freeze - - PURPOSE_STATUS = [ - Katello::PurposeStatus, - Katello::PurposeAddonsStatus, - Katello::PurposeRoleStatus, - Katello::PurposeSlaStatus, - Katello::PurposeUsageStatus].freeze - - def self.update_subscription_status_to_sca(hosts) - HostStatus::Status.where(host: hosts, type: Katello::SubscriptionStatus.to_s).update(status: Katello::SubscriptionStatus::DISABLED) - end - - def self.clear_syspurpose_status(hosts) - host_purpose = HostStatus::Status.where(type: ::Katello::HostStatusManager::PURPOSE_STATUS.map(&:to_s)).where('host_id in (?)', hosts.pluck(:id)) - host_purpose.destroy_all - end end end diff --git a/app/services/katello/registration_manager.rb b/app/services/katello/registration_manager.rb index 29ce57a6865..815dcc92f7d 100644 --- a/app/services/katello/registration_manager.rb +++ b/app/services/katello/registration_manager.rb @@ -148,7 +148,7 @@ def unregister_host(host, options = {}) end end - def register_host(host, consumer_params, content_view_environments, activation_keys = []) # rubocop:disable Metrics/MethodLength + def register_host(host, consumer_params, content_view_environments, activation_keys = []) new_host = host.new_record? unless new_host host.save! @@ -172,7 +172,6 @@ def register_host(host, consumer_params, content_view_environments, activation_k host.content_facet.cves_changed = false # prevent backend_update_needed from triggering an update on a nonexistent consumer host.subscription_facet = populate_subscription_facet(host, activation_keys, consumer_params, host_uuid) host.save! # the host has content and subscription facets at this point - create_initial_subscription_status(host) User.as_anonymous_admin do begin @@ -219,10 +218,6 @@ def remove_partially_registered_new_host(host) destroy_host_record(host.id) end - def create_initial_subscription_status(host) - host.subscription_facet.update_subscription_status(::Katello::SubscriptionStatus::UNKNOWN) - end - def create_in_candlepin(host, content_view_environments, consumer_params, activation_keys) # if CP fails, nothing to clean up yet w.r.t. backend services cp_create = ::Katello::Resources::Candlepin::Consumer.create(content_view_environments.map(&:cp_id), consumer_params, activation_keys.map(&:cp_name), host.organization) @@ -243,7 +238,6 @@ def finalize_registration(host) host.subscription_facet.save! host.refresh_statuses([ ::Katello::ErrataStatus, - ::Katello::SubscriptionStatus, ::Katello::RhelLifecycleStatus ]) end @@ -314,12 +308,6 @@ def remove_host_artifacts(host, clear_content_facet: true) end host.get_status(::Katello::ErrataStatus).destroy - host.get_status(::Katello::PurposeSlaStatus).destroy - host.get_status(::Katello::PurposeRoleStatus).destroy - host.get_status(::Katello::PurposeUsageStatus).destroy - host.get_status(::Katello::PurposeAddonsStatus).destroy - host.get_status(::Katello::PurposeStatus).destroy - host.get_status(::Katello::SubscriptionStatus).destroy host.get_status(::Katello::TraceStatus).destroy host.installed_packages.delete_all diff --git a/app/views/dashboard/_subscription_status_widget.html.erb b/app/views/dashboard/_subscription_status_widget.html.erb deleted file mode 100644 index d137b33e4b0..00000000000 --- a/app/views/dashboard/_subscription_status_widget.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -

- <%= _("Subscription Status") %> -

- -<% unless Organization.current.present? %> -

<%= _("Please select an organization to view subscription totals.") %>

-<% else %> - <% subscriptions = Katello::Subscription.in_organization([Organization.current]).includes(:pools) %> - <% total_active_subscriptions = Organization.current.active_pools_count %> - <% total_expiring_subscriptions = subscriptions.select(&:expiring_soon?).count %> - <% total_recently_expired_subscriptions = subscriptions.select(&:recently_expired?).count %> - - - - - - - - - - - - - - - - - - - - - - -
<%= _("Subscription Status") %><%= _("Count") %>
<%= _("Active Subscriptions") %><%= total_active_subscriptions %>
<%= _("Subscriptions Expiring in 120 Days") %><%= total_expiring_subscriptions %>
<%= _("Recently Expired Subscriptions") %><%= total_recently_expired_subscriptions %>
-<% end %> - - diff --git a/app/views/dashboard/_subscription_widget.html.erb b/app/views/dashboard/_subscription_widget.html.erb deleted file mode 100644 index 5ae7fc2d232..00000000000 --- a/app/views/dashboard/_subscription_widget.html.erb +++ /dev/null @@ -1,85 +0,0 @@ -

- <%= _("Host Subscription Status") %> -

- -<% if Organization.current.blank? %> -

<%= _("Please select an organization to view subscription status.") %>

-<% else %> - <% total_count = total_host_count() %> - <% partial_consumer_count = partial_consumer_count() %> - <% valid_consumer_count = valid_consumer_count()%> - <% invalid_consumer_count = invalid_consumer_count()%> - <% unknown_consumer_count = unknown_consumer_count() %> - <% subscription_status_url = '/content_hosts?search='%> - <% registered_subscription_url = subscription_status_url + ERB::Util.url_encode('subscription_status = ') %> - <% unknown_search_url = registered_subscription_url + 'unknown or (null? subscription_uuid)' %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<%= _("Count") %>
- <%= link_to("#{registered_subscription_url}" + 'invalid') do %> -  <%= _("Invalid") %> - <% end %> - - <%= link_to( "#{invalid_consumer_count}", "#{registered_subscription_url}" + 'invalid')%> -
- <%= link_to("#{registered_subscription_url}" + 'partial') do %> -  <%= _("Partial") %> - <% end %> - - <%= link_to( "#{partial_consumer_count}", "#{registered_subscription_url}" + 'partial')%> -
- <%= link_to("#{registered_subscription_url}" + 'valid') do %> -  <%= _("Valid") %> - <% end %> - - <%= link_to( "#{valid_consumer_count}", "#{registered_subscription_url}" + 'valid')%> -
- <%= link_to("#{registered_subscription_url}" + 'unsubscribed_hypervisor') do %> -  <%= _("Unsubscribed Hypervisor") %> - <% end %> - - <%= link_to( "#{unsubscribed_hypervisor_count}", "#{registered_subscription_url}" + 'unsubscribed_hypervisor')%> -
- <%= link_to(unknown_search_url) do %> -  <%= _("Unknown or Unregistered") %> - <% end %> - - <%= link_to("#{unknown_consumer_count}", unknown_search_url)%> -

- <%= link_to("Total Content Hosts", '/content_hosts')%> -

- <%= link_to( "#{total_count}", '/content_hosts')%> -
-<% end %> diff --git a/app/views/katello/api/v2/subscription_facet/base_with_root.json.rabl b/app/views/katello/api/v2/subscription_facet/base_with_root.json.rabl index 6aade153fd0..ecf9976b418 100644 --- a/app/views/katello/api/v2/subscription_facet/base_with_root.json.rabl +++ b/app/views/katello/api/v2/subscription_facet/base_with_root.json.rabl @@ -1,6 +1,3 @@ child :subscription_facet => :subscription_facet_attributes do extends 'katello/api/v2/subscription_facet/base' end - -attributes :subscription_status, :subscription_status_label, :subscription_global_status, - :if => @object.get_status(Katello::SubscriptionStatus).relevant? diff --git a/db/migrate/20200818192230_update_system_purpose_status.rb b/db/migrate/20200818192230_update_system_purpose_status.rb index 76cc7a050c6..54871b3565b 100644 --- a/db/migrate/20200818192230_update_system_purpose_status.rb +++ b/db/migrate/20200818192230_update_system_purpose_status.rb @@ -1,12 +1,18 @@ class UpdateSystemPurposeStatus < ActiveRecord::Migration[6.0] def change - purpose_types = Katello::HostStatusManager::PURPOSE_STATUS.map(&:to_s) + purpose_types = [ + "Katello::PurposeStatus", + "Katello::PurposeAddonsStatus", + "Katello::PurposeRoleStatus", + "Katello::PurposeSlaStatus", + "Katello::PurposeUsageStatus" + ] # load both sets of host statuses and *then* update them to make sure we update the correct statuses unknown_statuses = ::HostStatus::Status.where(type: purpose_types, status: 2).pluck(:id) matched_statuses = ::HostStatus::Status.where(type: purpose_types, status: 0).pluck(:id) - ::HostStatus::Status.where(id: unknown_statuses).update_all(status: Katello::PurposeStatus::UNKNOWN) # 2 => 0 - ::HostStatus::Status.where(id: matched_statuses).update_all(status: Katello::PurposeStatus::MATCHED) # 0 => 2 + ::HostStatus::Status.where(id: unknown_statuses).update_all(status: 0) # 2 => 0 + ::HostStatus::Status.where(id: matched_statuses).update_all(status: 2) # 0 => 2 end end diff --git a/db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb b/db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb new file mode 100644 index 00000000000..016dd7fdfd8 --- /dev/null +++ b/db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb @@ -0,0 +1,30 @@ +class RemoveEntitlementModeHostStatuses < ActiveRecord::Migration[6.1] + class FakeTablePreference < ApplicationRecord + self.table_name = 'table_preferences' + serialize :columns + end + + def up + obsolete_statuses = [ + "Katello::SubscriptionStatus", + "Katello::PurposeStatus", + "Katello::PurposeAddonsStatus", + "Katello::PurposeRoleStatus", + "Katello::PurposeSlaStatus", + "Katello::PurposeUsageStatus" + ] + + ::HostStatus::Status.where(type: obsolete_statuses).delete_all + + FakeTablePreference.where(name: "hosts").each do |table_preference| + next unless table_preference.columns.include?("subscription_status") + new_columns = table_preference.columns - ["subscription_status"] + if new_columns.present? + table_preference.columns = new_columns + table_preference.save(validate: false) + else + table_preference.destroy + end + end + end +end diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-associations-content-hosts.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-associations-content-hosts.html index 58b3ba722da..9263308c39e 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-associations-content-hosts.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-associations-content-hosts.html @@ -33,10 +33,6 @@ {{ host.name }} - - - - {{ host.content_facet_attributes.lifecycle_environment.name }} {{ host.content_facet_attributes.content_view.name || "" }} {{ host.subscription_facet_attributes.service_level }} diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js index a681bec5f68..4a2ddcb0754 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js @@ -38,16 +38,6 @@ angular.module('Bastion.content-hosts').service('ContentHostsHelper', return icons[globalStatus]; }; - this.getHostPurposeStatusIcon = function (statusCode) { - var code = parseInt(statusCode); - - if (code === 2) { // matched - return 'pficon pficon-ok'; - } else if (code === 1) { // mismatched - return 'pficon pficon-warning-triangle-o'; - } - }; - this.rebootRequired = function(traces) { return traces.some(function(trace) { return trace.reboot_required; diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js index 6c70ce38155..8c25a20c836 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js @@ -24,7 +24,6 @@ angular.module('Bastion.content-hosts').controller('ContentHostDetailsController $scope.menuExpander = MenuExpander; $scope.getHostStatusIcon = ContentHostsHelper.getHostStatusIcon; - $scope.getHostPurposeStatusIcon = ContentHostsHelper.getHostPurposeStatusIcon; $scope.organization = Organization.get({id: CurrentOrganization}, function(org) { $scope.purposeAddonsCount += org.system_purposes.addons.length; diff --git a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html index dc7b69a2103..d9d432fade3 100644 --- a/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +++ b/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html @@ -74,12 +74,6 @@

Basic Information

Subscriptions

-
Subscription Status
-
- - {{ host.subscription_status_label }} -
-
Details