diff --git a/app/helpers/katello/katello_urls_helper.rb b/app/helpers/katello/katello_urls_helper.rb index 484437cf7ce..f064f309a70 100644 --- a/app/helpers/katello/katello_urls_helper.rb +++ b/app/helpers/katello/katello_urls_helper.rb @@ -45,18 +45,16 @@ def subscription_manager_configuration_url(host = nil, rpm = true, hostname: nil end def repository_url(content_path, _content_type = nil, schema = 'http') return content_path if content_path =~ %r|^([\w\-\+]+)://| - url = if @host.content_source - "#{schema}://#{@host.content_source.hostname}" - else - foreman_settings_url(schema) - end + + url = @host.content_source.pulp_content_url + url.schema = schema content_path = content_path.sub(%r|^/|, '') if @host.content_view && !@host.content_view.default? content_path = [@host.content_view.label, content_path].join('/') end path = ::Katello::Glue::Pulp::Repos.repo_path_from_content_path( @host.lifecycle_environment, content_path) - "#{url}/pulp/content/#{path}" + "#{url}/#{path}" end end end diff --git a/app/lib/katello/resources/registry.rb b/app/lib/katello/resources/registry.rb index 5f8779a641b..86a99504c13 100644 --- a/app/lib/katello/resources/registry.rb +++ b/app/lib/katello/resources/registry.rb @@ -28,7 +28,7 @@ def load_class # Pulp 3 has its own registry if pulp_primary&.pulp3_repository_type_support?(::Katello::Repository::DOCKER_TYPE) - uri = URI(pulp_primary.setting(SmartProxy::PULP3_FEATURE, 'content_app_url')) + uri = URI(pulp_primary.pulp_content_url) uri.path = "/pulpcore_registry/" registry_url = uri.to_s diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index cd8b8d122ba..b60b35800f1 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -118,11 +118,25 @@ def container_gateway_users ::User.where(login: usernames['users']) end + def rhsm_url + # TODO: We shouldn't relate this to the Pulp feature and also expose it + # as a setting + if pulp_mirror? + "https://#{URI.parse(url).host}:8443/rhsm" + elsif pulp_primary? + "https://#{URI.parse(url).host}/rhsm" + end + end + def pulp_url uri = URI.parse(url) "#{uri.scheme}://#{uri.host}/pulp/api/v2/" end + def pulp_content_url + setting(SmartProxy::PULP3_FEATURE, 'content_app_url') + end + def pulp_api @pulp_api ||= Katello::Pulp::Server.config(pulp_url, User.remote_user) end diff --git a/app/models/katello/host/info_provider.rb b/app/models/katello/host/info_provider.rb index e698fedfd76..c786e8f2d49 100644 --- a/app/models/katello/host/info_provider.rb +++ b/app/models/katello/host/info_provider.rb @@ -16,6 +16,15 @@ def host_info if host.content_facet.present? info['parameters']['kickstart_repository'] = host.content_facet.kickstart_repository.try(:label) end + + if (rhsm_url = host.content_source&.rhsm_url) + host['rhsm_url'] = rhsm_url + end + + if (content_url = host.content_source&.pulp_content_url) + host['content_url'] = content_url + end + info end diff --git a/app/models/katello/repository.rb b/app/models/katello/repository.rb index 756cf34cf64..f3878bf6a19 100644 --- a/app/models/katello/repository.rb +++ b/app/models/katello/repository.rb @@ -400,17 +400,21 @@ def group end def full_path(smart_proxy = nil, force_http = false) - pulp_uri = URI.parse(smart_proxy ? smart_proxy.url : ::SmartProxy.pulp_primary.url) - scheme = force_http ? 'http' : 'https' + smart_proxy ||= ::SmartProxy.pulp_primary + pulp_uri = URI.parse(smart_proxy.pulp_content_url) + pulp_uri.scheme = force_http ? 'http' : 'https' + # TODO: this should be normalized in smart_proxy_pulp's setting + pulp_uri.host = pulp_uri.host.downcase if docker? - "#{pulp_uri.host.downcase}/#{container_repository_name}" + "#{pulp_uri.host}/#{container_repository_name}" elsif ostree? - "#{scheme}://#{pulp_uri.host.downcase}/pulp/content/web/#{relative_path}" + pulp_uri.path += "/web/#{relative_path}" elsif ansible_collection? - "#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api" + pulp_uri.path = "/pulp_ansible/galaxy/#{relative_path}/api" else - "#{scheme}://#{pulp_uri.host.downcase}/pulp/content/#{relative_path}/" + pulp_uri.path += "/#{relative_path}" end + pulp_uri.to_s end def to_hash(content_source = nil, force_http = false) diff --git a/app/services/katello/pulp/repository/yum.rb b/app/services/katello/pulp/repository/yum.rb index 0acaa9c6813..0976fb97dc9 100644 --- a/app/services/katello/pulp/repository/yum.rb +++ b/app/services/katello/pulp/repository/yum.rb @@ -24,6 +24,7 @@ def generate_mirror_importer end def partial_repo_path + # TODO: get /pulp/content from pulp_content_url "/pulp/content/#{repo.relative_path}/".sub('//', '/') end diff --git a/app/services/katello/pulp3/repository/yum.rb b/app/services/katello/pulp3/repository/yum.rb index c0472566d42..f4f5b089fbe 100644 --- a/app/services/katello/pulp3/repository/yum.rb +++ b/app/services/katello/pulp3/repository/yum.rb @@ -82,6 +82,7 @@ def self.distribution_bootable?(distribution) end def partial_repo_path + # TODO: get /pulp/content from pulp_content_url "/pulp/content/#{repo.relative_path}/".sub('//', '/') end