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



31
32
33
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 31

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

#default_locationObject



35
36
37
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 35

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

#host_setup_extensionObject



22
23
24
25
26
27
28
29
# File 'app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb', line 22

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

#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