Module: ForemanRhCloud
- Defined in:
- lib/foreman_rh_cloud.rb,
lib/foreman_rh_cloud/engine.rb,
lib/foreman_rh_cloud/plugin.rb,
lib/foreman_rh_cloud/version.rb,
app/models/foreman_rh_cloud/ping.rb,
app/services/foreman_rh_cloud/cert_auth.rb,
app/services/foreman_rh_cloud/tags_auth.rb,
app/services/foreman_rh_cloud/branch_info.rb,
app/services/foreman_rh_cloud/cloud_request.rb,
app/services/foreman_rh_cloud/hits_uploader.rb,
app/services/foreman_rh_cloud/cloud_presence.rb,
app/services/foreman_rh_cloud/rules_ingester.rb,
app/services/foreman_rh_cloud/cloud_connector.rb,
lib/foreman_rh_cloud/async/exponential_backoff.rb,
app/services/foreman_rh_cloud/cloud_ping_service.rb,
app/services/foreman_rh_cloud/insights_api_forwarder.rb,
app/services/foreman_rh_cloud/remediations_retriever.rb,
lib/foreman_rh_cloud/organization_destroy_extensions.rb,
app/services/foreman_rh_cloud/cloud_request_forwarder.rb,
app/services/foreman_rh_cloud/insights_status_cleaner.rb,
app/services/foreman_rh_cloud/template_renderer_helper.rb,
app/services/foreman_rh_cloud/hit_remediations_retriever.rb,
app/services/foreman_rh_cloud/url_remediations_retriever.rb,
app/controllers/foreman_rh_cloud/foreman_rh_cloud_controller.rb,
app/controllers/concerns/foreman_rh_cloud/iop_smart_proxy_access.rb,
app/controllers/concerns/foreman_rh_cloud/registration_manager_extensions.rb
Defined Under Namespace
Modules: Async, CertAuth, CloudRequest, IopSmartProxyAccess, OrganizationDestroyExtensions, Plugin, RegistrationManagerExtensions, TemplateRendererHelper
Classes: BranchInfo, CloudConnector, CloudPingService, CloudPresence, CloudRequestForwarder, Engine, ForemanRhCloudController, HitRemediationsRetriever, HitsUploader, InsightsApiForwarder, InsightsStatusCleaner, Ping, RemediationsRetriever, RulesIngester, TagsAuth, URLRemediationsRetriever
Constant Summary
collapse
- VERSION =
'14.1.3'.freeze
Class Method Summary
collapse
Class Method Details
.base_url ⇒ Object
15
16
17
18
|
# File 'lib/foreman_rh_cloud.rb', line 15
def self.base_url
env_or_on_premise_url('SATELLITE_RH_CLOUD_URL') || 'https://cloud.redhat.com'
end
|
.ca_cert ⇒ Object
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/foreman_rh_cloud/engine.rb', line 132
def self.ca_cert
if ::SETTINGS.dig(:katello, :candlepin, :ca_cert_file)
::SETTINGS[:katello][:candlepin][:ca_cert_file]
else
::SETTINGS[:ssl_ca_file]
end
end
|
.cert_base_url ⇒ Object
20
21
22
|
# File 'lib/foreman_rh_cloud.rb', line 20
def self.cert_base_url
env_or_on_premise_url('SATELLITE_CERT_RH_CLOUD_URL') || 'https://cert.cloud.redhat.com'
end
|
.cloud_url_validator ⇒ Object
138
139
140
|
# File 'lib/foreman_rh_cloud.rb', line 138
def self.cloud_url_validator
@cloud_url_validator ||= Regexp.new(ENV['SATELLITE_RH_CLOUD_VALIDATOR'] || 'redhat.com$')
end
|
.env_or_on_premise_url(env_var_name) ⇒ Object
11
12
13
|
# File 'lib/foreman_rh_cloud.rb', line 11
def self.env_or_on_premise_url(env_var_name)
on_premise_url || ENV[env_var_name]
end
|
.fix_port(uri_string) ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'lib/foreman_rh_cloud.rb', line 56
def self.fix_port(uri_string)
return '' if uri_string.empty?
uri = URI(uri_string)
uri.send(:define_singleton_method, :default_port, -> { nil })
uri.to_s
end
|
.foreman_host ⇒ Object
For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/foreman_rh_cloud.rb', line 86
def self.foreman_host
return @foreman_host if defined?(@foreman_host)
fullname = foreman_host_name
return @foreman_host = nil unless fullname
host = ::Host.unscoped.friendly.where(name: fullname).first
if host.nil?
shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
host = ::Host.unscoped.friendly.where(name: shortname).first
end
@foreman_host = host
end
|
.foreman_host_name ⇒ Object
104
105
106
|
# File 'lib/foreman_rh_cloud.rb', line 104
def self.foreman_host_name
ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || marked_foreman_host&.name || foreman_url_hostname
end
|
.foreman_url_hostname ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/foreman_rh_cloud.rb', line 108
def self.foreman_url_hostname
return nil unless Setting[:foreman_url]
begin
url = Setting[:foreman_url].to_s
URI.parse(url).host
rescue URI::InvalidURIError, ArgumentError, TypeError => e
Rails.logger.warn("Invalid foreman_url setting: #{e.message}")
nil
end
end
|
.global_foreman_proxy ⇒ Object
65
66
67
|
# File 'lib/foreman_rh_cloud.rb', line 65
def self.global_foreman_proxy
Setting[:http_proxy]
end
|
.http_proxy_string ⇒ Object
.iop_smart_proxy ⇒ Object
128
129
130
|
# File 'lib/foreman_rh_cloud/engine.rb', line 128
def self.iop_smart_proxy
SmartProxy.unscoped.with_features('iop').first
end
|
.legacy_insights_ca ⇒ Object
.legacy_insights_url ⇒ Object
24
25
26
|
# File 'lib/foreman_rh_cloud.rb', line 24
def self.legacy_insights_url
env_or_on_premise_url('SATELLITE_LEGACY_INSIGHTS_URL') || 'https://cert-api.access.redhat.com'
end
|
.marked_foreman_host ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/foreman_rh_cloud.rb', line 121
def self.marked_foreman_host
return nil unless defined?(HostFacets::InfrastructureFacet)
facet = HostFacets::InfrastructureFacet.find_by(foreman_instance: true)
facet&.host
rescue ActiveRecord::StatementInvalid => e
Rails.logger.debug("Could not query marked foreman host: #{e.message}")
nil
end
|
.on_prem_smart_proxy_features ⇒ Object
143
144
145
|
# File 'lib/foreman_rh_cloud/engine.rb', line 143
def self.on_prem_smart_proxy_features
['iop']
end
|
.proxy_setting ⇒ Object
44
45
46
|
# File 'lib/foreman_rh_cloud.rb', line 44
def self.proxy_setting
fix_port(proxy_string)
end
|
.query_limit ⇒ Object
32
33
34
|
# File 'lib/foreman_rh_cloud.rb', line 32
def self.query_limit
@query_limit ||= ENV['SATELLITE_RH_CLOUD_QUERY_LIMIT'] ? ENV['SATELLITE_RH_CLOUD_QUERY_LIMIT'].to_i : 100
end
|
.requests_delay ⇒ Object
142
143
144
|
# File 'lib/foreman_rh_cloud.rb', line 142
def self.requests_delay
@requests_delay ||= ENV['SATELLITE_RH_CLOUD_REQUESTS_DELAY']
end
|
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/foreman_rh_cloud.rb', line 71
def self.transform_scheme(uri_string)
return unless uri_string
transformed_uri = URI.parse(uri_string)
case transformed_uri.scheme
when "http"
transformed_uri.scheme = 'proxy'
when "https"
transformed_uri.scheme = 'proxys'
end
transformed_uri.to_s
end
|
.verify_ssl_method ⇒ Object
28
29
30
|
# File 'lib/foreman_rh_cloud.rb', line 28
def self.verify_ssl_method
@verify_ssl_method ||= ENV['SATELLITE_RH_CLOUD_URL'] ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
end
|
.with_iop_smart_proxy? ⇒ Boolean
124
125
126
|
# File 'lib/foreman_rh_cloud/engine.rb', line 124
def self.with_iop_smart_proxy?
SmartProxy.unscoped.with_features('iop').exists?
end
|