Class: Katello::Provider
- Inherits:
-
Model
- Object
- ApplicationRecord
- Model
- Katello::Provider
show all
- Includes:
- ForemanTasks::Concerns::ActionSubject, Glue, Glue::Provider
- Defined in:
- app/models/katello/provider.rb
Constant Summary
collapse
- REDHAT =
'Red Hat'.encode('utf-8')
- CUSTOM =
'Custom'.encode('utf-8')
- ANONYMOUS =
'Anonymous'.encode('utf-8')
- TYPES =
[REDHAT, CUSTOM, ANONYMOUS].freeze
Glue::Provider::DISTRIBUTOR_VERSION
Instance Method Summary
collapse
Methods included from Glue
logger
included, orphaned_custom_product?, orphaned_product?, provider_for_cp_id
Methods inherited from Model
#destroy!
Instance Method Details
#anonymous_provider? ⇒ Boolean
78
79
80
|
# File 'app/models/katello/provider.rb', line 78
def anonymous_provider?
provider_type == ANONYMOUS
end
|
#as_json(*args) ⇒ Object
96
97
98
|
# File 'app/models/katello/provider.rb', line 96
def as_json(*args)
super.merge('organization_label' => self.organization.label)
end
|
#constraint_redhat_update ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/models/katello/provider.rb', line 48
def constraint_redhat_update
if !new_record? && redhat_provider?
allowed_changes = %w(task_status_id)
not_allowed_changes = changes.keys - allowed_changes
unless not_allowed_changes.empty?
errors.add(:base, _("the following attributes can not be updated for the Red Hat provider: [ %s ]") % not_allowed_changes.join(", "))
end
end
end
|
#count_providers(type) ⇒ Object
58
59
60
|
# File 'app/models/katello/provider.rb', line 58
def count_providers(type)
Provider.where(:organization_id => self.organization_id, :provider_type => type).count(:id)
end
|
#custom_provider? ⇒ Boolean
74
75
76
|
# File 'app/models/katello/provider.rb', line 74
def custom_provider?
provider_type == CUSTOM
end
|
#manifest_task ⇒ Object
92
93
94
|
# File 'app/models/katello/provider.rb', line 92
def manifest_task
return task_status
end
|
#only_one_rhn_provider ⇒ Object
31
32
33
34
35
36
|
# File 'app/models/katello/provider.rb', line 31
def only_one_rhn_provider
if new_record? && provider_type == REDHAT && count_providers(REDHAT) != 0
errors.add(:base, _("Only one Red Hat provider permitted for an Organization"))
end
end
|
#prevent_redhat_deletion ⇒ Object
38
39
40
41
42
43
44
45
46
|
# File 'app/models/katello/provider.rb', line 38
def prevent_redhat_deletion
if !being_deleted? && redhat_provider?
Rails.logger.error _("Red Hat provider can not be deleted")
throw :abort
else
true
end
end
|
#redhat_provider=(is_rh) ⇒ Object
66
67
68
|
# File 'app/models/katello/provider.rb', line 66
def redhat_provider=(is_rh)
is_rh ? REDHAT : ANONYMOUS
end
|
#redhat_provider? ⇒ Boolean
70
71
72
|
# File 'app/models/katello/provider.rb', line 70
def redhat_provider?
provider_type == REDHAT
end
|
108
109
110
|
# File 'app/models/katello/provider.rb', line 108
def related_resources
self.organization
end
|
#serializable_hash(options = {}) ⇒ Object
84
85
86
87
88
89
90
|
# File 'app/models/katello/provider.rb', line 84
def serializable_hash(options = {})
options = {} if options.nil?
hash = super(options)
hash = hash.merge(:sync_state => self.sync_state,
:last_sync => self.last_sync)
hash
end
|
#total_products ⇒ Object
100
101
102
|
# File 'app/models/katello/provider.rb', line 100
def total_products
products.length
end
|
#total_repositories ⇒ Object
104
105
106
|
# File 'app/models/katello/provider.rb', line 104
def total_repositories
repositories.length
end
|
#yum_repo? ⇒ Boolean
62
63
64
|
# File 'app/models/katello/provider.rb', line 62
def yum_repo?
provider_type == CUSTOM || provider_type == ANONYMOUS
end
|