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,
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
Defined Under Namespace
Modules: Async, CertAuth, CloudRequest, IopSmartProxyAccess, Plugin, TemplateRendererHelper
Classes: BranchInfo, CloudConnector, CloudPingService, CloudPresence, CloudRequestForwarder, Engine, ForemanRhCloudController, HitRemediationsRetriever, HitsUploader, InsightsApiForwarder, InsightsStatusCleaner, Ping, RemediationsRetriever, RulesIngester, TagsAuth, URLRemediationsRetriever
Constant Summary
collapse
- VERSION =
'13.0.7'.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
@base_url ||= env_or_on_premise_url('SATELLITE_RH_CLOUD_URL') || 'https://cloud.redhat.com'
end
|
.ca_cert ⇒ Object
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/foreman_rh_cloud/engine.rb', line 129
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
@cert_base_url ||= env_or_on_premise_url('SATELLITE_CERT_RH_CLOUD_URL') || 'https://cert.cloud.redhat.com'
end
|
.cloud_url_validator ⇒ Object
111
112
113
|
# File 'lib/foreman_rh_cloud.rb', line 111
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
|
# File 'lib/foreman_rh_cloud.rb', line 86
def self.foreman_host
@foreman_host ||= begin
fullname = foreman_host_name
::Host.unscoped.friendly.find(fullname)
rescue ActiveRecord::RecordNotFound
shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname]
::Host.unscoped.friendly.find(shortname)
end
end
|
.foreman_host_name ⇒ Object
97
98
99
|
# File 'lib/foreman_rh_cloud.rb', line 97
def self.foreman_host_name
ENV['SATELLITE_RH_CLOUD_FOREMAN_HOST'] || marked_foreman_host&.name || ::SmartProxy.default_capsule.name
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
125
126
127
|
# File 'lib/foreman_rh_cloud/engine.rb', line 125
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
@legacy_insights_url ||= env_or_on_premise_url('SATELLITE_LEGACY_INSIGHTS_URL') || 'https://cert-api.access.redhat.com'
end
|
.marked_foreman_host ⇒ Object
101
102
103
104
105
|
# File 'lib/foreman_rh_cloud.rb', line 101
def self.marked_foreman_host
::Host.unscoped.search_for('infrastructure_facet.foreman = true').first
rescue ScopedSearch::QueryNotSupported
nil
end
|
.on_prem_smart_proxy_features ⇒ Object
140
141
142
|
# File 'lib/foreman_rh_cloud/engine.rb', line 140
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
115
116
117
|
# File 'lib/foreman_rh_cloud.rb', line 115
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
121
122
123
|
# File 'lib/foreman_rh_cloud/engine.rb', line 121
def self.with_iop_smart_proxy?
SmartProxy.unscoped.with_features('iop').exists?
end
|