Sha256: c90d29710a0a605822a9fbdf26919c2b4a3bc47c05fab3f50e2f5f556b076b4a

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

kind = TemplateKind.unscoped.where(:name => 'Bootdisk').first_or_create

organizations = Organization.all
locations = Location.all
created = []

ProvisioningTemplate.without_auditing do
  content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'host.erb'))
  created << 'Boot disk iPXE - host' unless ProvisioningTemplate.find_by_name('Boot disk iPXE - host')
  tmpl = ProvisioningTemplate.unscoped.where(:name => 'Boot disk iPXE - host').first_or_create do |template|
    template.attributes = {
      :template_kind_id => kind.id,
      :snippet => false,
      :template => content
    }
  end
  tmpl.attributes = {
    :template => content,
    :default  => true,
    :vendor   => "Foreman boot disk",
  }
  tmpl.locked = true
  tmpl.save!(:validate => false) if tmpl.changes.present?

  content = File.read(File.join(ForemanBootdisk::Engine.root, 'app', 'views', 'foreman_bootdisk', 'generic_host.erb'))
  created << 'Boot disk iPXE - generic host' unless ProvisioningTemplate.find_by_name('Boot disk iPXE - generic host')
  tmpl = ProvisioningTemplate.unscoped.where(:name => 'Boot disk iPXE - generic host').first_or_create do |template|
    template.attributes = {
      :template_kind_id => kind.id,
      :snippet => false,
      :template => content
    }
  end
  tmpl.attributes = {
    :template => content,
    :default  => true,
    :vendor   => "Foreman boot disk",
  }
  tmpl.locked = true
  tmpl.save!(:validate => false) if tmpl.changes.present?

  ProvisioningTemplate.unscoped.where(:name => created, :default => true).each do |tmpl|
    tmpl.organizations = organizations if SETTINGS[:organizations_enabled]
    tmpl.locations = locations if SETTINGS[:locations_enabled]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
foreman_bootdisk-12.0.1 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-13.0.0 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-12.0.0 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-11.0.0 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-10.0.2 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-10.0.1 db/seeds.d/50-bootdisk_templates.rb
foreman_bootdisk-10.0.0 db/seeds.d/50-bootdisk_templates.rb