diff --git a/lib/foreman_rh_cloud.rb b/lib/foreman_rh_cloud.rb index f9e64309..406703fc 100644 --- a/lib/foreman_rh_cloud.rb +++ b/lib/foreman_rh_cloud.rb @@ -3,17 +3,23 @@ require 'uri' module ForemanRhCloud + def self.on_premise_url + return unless ForemanRhCloud.with_insights_on_premise? + port = ENV['INSIGHTS_ADVISOR_PORT'] || "8000" + "http://#{ForemanRhCloud.foreman_host.fqdn || 'localhost'}:#{port}" + end + def self.base_url # for testing set ENV to 'https://ci.cloud.redhat.com' - @base_url ||= ENV['SATELLITE_RH_CLOUD_URL'] || 'https://cloud.redhat.com' + @base_url ||= on_premise_url || ENV['SATELLITE_RH_CLOUD_URL'] || 'https://cloud.redhat.com' end def self.cert_base_url - @cert_base_url ||= ENV['SATELLITE_CERT_RH_CLOUD_URL'] || 'https://cert.cloud.redhat.com' + @cert_base_url ||= on_premise_url || ENV['SATELLITE_CERT_RH_CLOUD_URL'] || 'https://cert.cloud.redhat.com' end def self.legacy_insights_url - @legacy_insights_url ||= ENV['SATELLITE_LEGACY_INSIGHTS_URL'] || 'https://cert-api.access.redhat.com' + @legacy_insights_url ||= on_premise_url || ENV['SATELLITE_LEGACY_INSIGHTS_URL'] || 'https://cert-api.access.redhat.com' end def self.verify_ssl_method