class Object

Public Instance Methods

find_katello_assets(args = {}) click to toggle source
# File lib/katello/plugin.rb, line 763
def find_katello_assets(args = {})
  type = args.fetch(:type, nil)
  vendor = args.fetch(:vendor, false)

  if vendor
    asset_dir = "#{Katello::Engine.root}/vendor/assets/#{type}/"
  else
    asset_dir = "#{Katello::Engine.root}/app/assets/#{type}/"
  end

  asset_paths = Dir[File.join(asset_dir, '**', '*')].reject { |file| File.directory?(file) }
  asset_paths.each { |file| file.slice!(asset_dir) }

  asset_paths
end
hashify_parameters(parameters) click to toggle source
# File lib/katello/plugin.rb, line 354
def hashify_parameters(parameters)
  Hash[parameters.map { |p| [p, p] }]
end
katello_template_setting_values(name) click to toggle source
# File lib/katello/plugin.rb, line 358
def katello_template_setting_values(name)
  templates = ProvisioningTemplate.where(:template_kind => TemplateKind.where(:name => name))
  templates.each_with_object({}) { |tmpl, hash| hash[tmpl.name] = tmpl.name }
end
remove_orphan_facets() click to toggle source
# File lib/katello/tasks/clean_orphaned_facets.rb, line 8
def remove_orphan_facets
  ::Katello::Host::ContentFacet.select { |c| c.host.nil? }&.each do |content_facet|
    Rails.logger.info "Deleting content facet with id: #{content_facet.id}\n"
    content_facet.destroy
  end
  Katello::Host::SubscriptionFacet.select { |s| s.host.nil? }&.each do |subscription_facet|
    Rails.logger.info "Deleting subscription facet with id: #{subscription_facet.id}\n"
    subscription_facet.destroy
  end
rescue RuntimeError => e
  Rails.logger.error "Task failed: #{e}"
end