app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb in katello-4.1.4 vs app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb in katello-4.2.0.rc1
- old
+ new
@@ -5,11 +5,11 @@
def prepare_host
if params['uuid']
@host = Katello::Host::SubscriptionFacet.find_by(uuid: params['uuid'])&.host
if @host.nil?
- msg = N_("Host was not found by the subscription UUID: '%s', this can happen if the host is registered already, but not to this Foreman") % params['uuid']
+ msg = _("Host was not found by the subscription UUID: '%s', this can happen if the host is registered already, but not to this instance") % params['uuid']
fail ActiveRecord::RecordNotFound, msg
end
@host.assign_attributes(host_params('host'))
@host.save!
else
@@ -23,9 +23,34 @@
@host.content_facet.lifecycle_environment = new_lce
@host.update_candlepin_associations
end
super
+ end
+
+ def context_urls
+ super.merge(rhsm_url: rhsm_url, pulp_content_url: pulp_content_url)
+ end
+
+ private
+
+ def smart_proxy
+ @smart_proxy ||= begin
+ proxy = params[:url] ? SmartProxy.find_by(url: params[:url]) : SmartProxy.pulp_primary
+
+ fail Foreman::Exception, _('Smart proxy content source not found!') unless proxy
+ fail Foreman::Exception, _('Pulp 3 is not enabled on Smart proxy!') unless proxy.pulp3_enabled?
+
+ proxy
+ end
+ end
+
+ def rhsm_url
+ URI(smart_proxy.rhsm_url)
+ end
+
+ def pulp_content_url
+ smart_proxy.setting(SmartProxy::PULP3_FEATURE, 'content_app_url')
end
end
end
end