Module: Katello::Concerns::HostManagedExtensions::Overrides
- Defined in:
- app/models/katello/concerns/host_managed_extensions.rb
Instance Method Summary collapse
- #attributes=(attrs) ⇒ Object
- #check_cve_attributes(attrs) ⇒ Object
- #inherited_attributes ⇒ Object
- #remote_execution_proxies(provider, *_rest) ⇒ Object
- #smart_proxy_ids ⇒ Object
- #update(attrs) ⇒ Object
- #update_os_from_facts ⇒ Object
- #validate_media? ⇒ Boolean
Instance Method Details
#attributes=(attrs) ⇒ Object
31 32 33 34 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 31 def attributes=(attrs) check_cve_attributes(attrs) unless self.content_facet.blank? super end |
#check_cve_attributes(attrs) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 10 def check_cve_attributes(attrs) if attrs[:content_facet_attributes] cv_id = attrs[:content_facet_attributes].delete(:content_view_id) lce_id = attrs[:content_facet_attributes].delete(:lifecycle_environment_id) # Running validations on a host will clear out any existing errors, and then # validate all attributes. As we know, running update or save will run validations. # Since we've just removed two attributes that may # have caused an error, we need to save those so we can explicitly validate # them below in add_back_cve_errors. @pending_cve_attrs = { content_view_id: cv_id, lifecycle_environment_id: lce_id } if cv_id && lce_id cve = content_facet&.assign_single_environment(content_view_id: cv_id, lifecycle_environment_id: lce_id) Rails.logger.warn "Couldn't assign content view environment; host has no content facet" if cve.blank? @pending_cve_attrs = {} end if (cv_id.present? && lce_id.blank?) || (cv_id.blank? && lce_id.present?) errors.add(:base, _("Content view and lifecycle environment must be provided together")) end end end |
#inherited_attributes ⇒ Object
45 46 47 48 49 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 45 def inherited_attributes inherited_attrs = super inherited_attrs.delete('medium_id') if content_facet && !content_facet.kickstart_repository.blank? inherited_attrs end |
#remote_execution_proxies(provider, *_rest) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 70 def remote_execution_proxies(provider, *_rest) proxies = super name = subscription_facet&.registered_through result = [] if name.present? result = SmartProxy.with_features(provider) . .where(name: name) if result.blank? result = SmartProxy..behind_load_balancer(name) end end proxies[:registered_through] = result proxies end |
#smart_proxy_ids ⇒ Object
51 52 53 54 55 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 51 def smart_proxy_ids ids = super ids << content_source_id ids.uniq.compact end |
#update(attrs) ⇒ Object
36 37 38 39 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 36 def update(attrs) check_cve_attributes(attrs) unless self.content_facet.blank? super end |
#update_os_from_facts ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 57 def update_os_from_facts super # If facts causes the OS to change, our kickstart repo might not be # valid anymore. Let's reset it, either to nil or a valid one ks_repo = content_facet&.kickstart_repository valid_repos = .respond_to?(:kickstart_repos) ? (.kickstart_repos(self)&.pluck(:id) || []) : [] if ks_repo && valid_repos.exclude?(ks_repo.id) content_facet.kickstart_repository_id = valid_repos.first end end |
#validate_media? ⇒ Boolean
41 42 43 |
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 41 def validate_media? (content_source_id.blank? || (content_facet && content_facet.kickstart_repository.blank?)) && super end |