Sha256: 307902bd715568fcba12fa4a4c217a1f050cb4b9d2377f3f54c46ce87b60eccf

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

organizations = Organization.unscoped.all
locations = Location.unscoped.all

kind = TemplateKind.unscoped.find_or_create_by(name: 'kexec')
kind.description = N_("Command line options for kexec during PXE-less provisioning.")
kind.save!

ProvisioningTemplate.without_auditing do
  [['redhat_kexec.erb', 'Red Hat'], ['debian_kexec.erb', 'Debian']].each do |tmpl_names|
    content = File.read(File.join(ForemanDiscovery::Engine.root, 'app', 'views', 'foreman_discovery', tmpl_names[0]))
    tmpl = ProvisioningTemplate.unscoped.where(:name => "Discovery #{tmpl_names[1]} kexec").first_or_create(
      :template_kind_id => kind.id,
      :snippet => false,
      :template => content
    )
    tmpl.attributes = {
      :template => content,
      :default  => true,
      :vendor   => "Foreman Discovery",
      :locked   => true
    }
    tmpl.template = content
    tmpl.organizations = organizations
    tmpl.locations = locations

    metadata = Template.parse_metadata(content)
    tmpl.description = metadata['description']

    tmpl.save!(:validate => false) if tmpl.changes.present?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_discovery-21.0.5 db/seeds.d/50_discovery_templates.rb
foreman_discovery-21.0.4 db/seeds.d/50_discovery_templates.rb
foreman_discovery-21.0.3 db/seeds.d/50_discovery_templates.rb
foreman_discovery-21.0.2 db/seeds.d/50_discovery_templates.rb