Module: Katello::Concerns::Api::V2::RegistrationControllerExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb

Instance Method Summary collapse

Instance Method Details

#context_urlsObject



22
23
24
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 22

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

#default_locationObject



26
27
28
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 26

def default_location
  Location.authorized(:view_locations).find_by(title: Setting[:default_location_subscribed_hosts]) || super
end

#prepare_hostObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 6

def prepare_host
  if params['uuid']
    host_id = Katello::Host::SubscriptionFacet.find_by(uuid: params['uuid'])&.host_id
    @host = ::Host::Managed.unscoped.find_by(id: host_id)
    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.owner = User.current
    @host.save!
  else
    super
  end
end