Revision 0fa5d146
Added by Dominic Cleal over 10 years ago
db/migrate/20110420150600_add_solaris_templates.rb | ||
---|---|---|
class AddSolarisTemplates < ActiveRecord::Migration
|
||
class ConfigTemplate < ActiveRecord::Base
|
||
has_and_belongs_to_many :operatingsystems
|
||
end
|
||
def self.up
|
||
TemplateKind.create :name =>"PXEGrub"
|
||
TemplateKind.all.each do |kind|
|
||
case kind.name
|
||
when /provision/
|
||
ConfigTemplate.create(
|
||
:name => "Jumpstart Default",
|
||
:template_kind_id => kind.id,
|
||
:operatingsystem_ids => Solaris.all.map(&:id),
|
||
:template => File.read("#{Rails.root}/app/views/unattended/jumpstart.erb"))
|
||
when /finish/
|
||
ConfigTemplate.create(
|
||
:name => "Jumstart Default Finish",
|
||
:template_kind_id => kind.id,
|
||
:operatingsystem_ids => Solaris.all.map(&:id),
|
||
:template => File.read("#{Rails.root}/app/views/unattended/jumpstart_finish.erb"))
|
||
when /pxegrub/i
|
||
ConfigTemplate.create(
|
||
:name => "Jumpstart default PXEGrub",
|
||
:template_kind_id => kind.id,
|
||
:operatingsystem_ids => Solaris.all.map(&:id),
|
||
:template => File.read("#{Rails.root}/app/views/unattended/pxe_jumpstart_config.erb"))
|
||
end
|
||
snippet = "#{Rails.root}/app/views/unattended/snippets/_http_proxy.erb"
|
||
ConfigTemplate.find_or_create_by_name(
|
||
:name => "http_proxy",
|
||
:template => File.read(snippet),
|
||
:snippet => true)
|
||
end
|
||
rescue Exception => e
|
||
# something bad happened, but we don't want to break the migration process
|
||
Rails.logger.warn "Failed to migrate #{e}"
|
||
return true
|
||
end
|
||
|
||
def self.down
|
Also available in: Unified diff
fixes #3752 - move data population from migrations into seed script