Sha256: 7de201b9c4016be5f43bbafa8e8e0ea0b214ba7661e10c5f5735e85d14b56a99

Contents?: true

Size: 1.57 KB

Versions: 18

Compression:

Stored size: 1.57 KB

Contents

module Katello
  module Concerns
    module Api::V2::RegistrationControllerExtensions
      extend ActiveSupport::Concern

      def prepare_host
        if params['uuid']
          @host = Katello::Host::SubscriptionFacet.find_by(uuid: params['uuid'])&.host
          if @host.nil?
            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
          super
        end
      end

      def host_setup_extension
        if params['host']['lifecycle_environment_id']
          @host.content_facet.assign_single_environment(content_view_id: @host&.content_views&.first&.id, lifecycle_environment_id: params['host']['lifecycle_environment_id'])
          @host.update_candlepin_associations
        end

        super
      end

      def context_urls
        super.merge(rhsm_url: smart_proxy.rhsm_url, pulp_content_url: smart_proxy.pulp_content_url)
      end

      private

      def smart_proxy
        @smart_proxy ||= begin
          proxy = params[:url] ? find_smart_proxy : 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 find_smart_proxy
        auth_smart_proxy
        @detected_proxy
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
katello-4.11.0 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.11.0.rc2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.11.0.rc1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.10.0 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.9.2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.10.0.rc2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.10.0.rc1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.4 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.9.1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.3 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.9.0 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.9.0.rc2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.9.0.rc1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.0 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.0.rc2 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb
katello-4.8.0.rc1 app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb