module ForemanRhCloud
Constants
- VERSION
Public Class Methods
base_url()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 15 def self.base_url # for testing set ENV to 'https://ci.cloud.redhat.com' env_or_on_premise_url('SATELLITE_RH_CLOUD_URL') || 'https://cloud.redhat.com' end
ca_cert()
click to toggle source
# File lib/foreman_rh_cloud/engine.rb, line 132 def self.ca_cert # The reference to candlepin ca_cert_file can be removed # once the setting is dropped. Foreman 3.15 introduces # a single CA file that bundles all CAs. if ::SETTINGS.dig(:katello, :candlepin, :ca_cert_file) ::SETTINGS[:katello][:candlepin][:ca_cert_file] else ::SETTINGS[:ssl_ca_file] end end
cert_base_url()
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
For testing purposes we can override the default hostname with an environment variable SATELLITE_RH_CLOUD_FOREMAN_HOST
# 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 # fullname didn't work. Let's try shortname shortname = /(?<shortname>[^\.]*)\.?.*/.match(fullname)[:shortname] ::Host.unscoped.friendly.find(shortname) end end
foreman_host_name()
click to toggle source
# 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()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 65 def self.global_foreman_proxy Setting[:http_proxy] end
http_proxy_string()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 36 def self.http_proxy_string ForemanRhCloud.proxy_setting end
iop_smart_proxy()
click to toggle source
# File lib/foreman_rh_cloud/engine.rb, line 128 def self.iop_smart_proxy SmartProxy.unscoped.with_features('iop').first end
legacy_insights_ca()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 107 def self.legacy_insights_ca "#{ForemanRhCloud::Engine.root}/config/rh_cert-api_chain.pem" unless ForemanRhCloud.with_iop_smart_proxy? end
legacy_insights_url()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/foreman_rh_cloud/engine.rb, line 143 def self.on_prem_smart_proxy_features ['iop'] end
on_premise_url()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 6 def self.on_premise_url return unless ForemanRhCloud.with_iop_smart_proxy? ForemanRhCloud.iop_smart_proxy&.url end
proxy_setting()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 44 def self.proxy_setting fix_port(proxy_string) end
proxy_string()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 48 def self.proxy_string return '' if ForemanRhCloud.with_iop_smart_proxy? HttpProxy.default_global_content_proxy&.full_url || ForemanRhCloud.global_foreman_proxy || '' end
query_limit()
click to toggle source
# 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()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 115 def self.requests_delay @requests_delay ||= ENV['SATELLITE_RH_CLOUD_REQUESTS_DELAY'] end
transform_scheme(uri_string)
click to toggle source
This method assumes uri_string contains uri-encoded username and p@$$word: user:p%40%24%24word@localhost:8888
# 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
transformed_http_proxy_string()
click to toggle source
# File lib/foreman_rh_cloud.rb, line 40 def self.transformed_http_proxy_string ForemanRhCloud.transform_scheme(ForemanRhCloud.proxy_setting) end
verify_ssl_method()
click to toggle source
# 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?()
click to toggle source
# File lib/foreman_rh_cloud/engine.rb, line 124 def self.with_iop_smart_proxy? SmartProxy.unscoped.with_features('iop').exists? end