Project

General

Profile

« Previous | Next » 

Revision 0fecb533

Added by Thomas McKay over 10 years ago

fixes #3673 - auditing added to ptable w/ test

View differences:

app/models/ptable.rb
class Ptable < ActiveRecord::Base
include Authorization
include ValidateOsFamily
audited :allow_mass_assignment => true
before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)
has_many_hosts
db/migrate/20100523114430_add_ubuntu_custom_lvm_ptable.rb
class AddUbuntuCustomLvmPtable < ActiveRecord::Migration
def self.up
Ptable.create :name => "Ubuntu custom LVM", :layout => <<EOF
Ptable.without_auditing {
Ptable.new :name => "Ubuntu custom LVM", :layout => <<EOF
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string lvm
......
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
EOF
}
end
def self.down
Ptable.first(:conditions => "name = 'Ubuntu custom LVM'").delete
Ptable.without_auditing {
Ptable.first(:conditions => "name = 'Ubuntu custom LVM'").delete
}
end
end
db/migrate/20110613141800_add_solaris_disks.rb
class AddSolarisDisks < ActiveRecord::Migration
def self.up
disk = Ptable.create :name => "Solaris small disk c1t0", :layout =>"filesys c1t0d0s0 7000 /\nfilesys c1t0d0s1 1000 swap\nfilesys c1t0d0s3 15 unnamed\nfilesys c1t0d0s7 free /tmp2\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
disk = Ptable.create :name => "Solaris small disk c0t0", :layout =>"filesys c0t0d0s0 7000 /\nfilesys c0t0d0s1 1000 swap\nfilesys c0t0d0s3 15 unnamed\nfilesys c0t0d0s7 free /tmp2\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
disk = Ptable.create :name => "Solaris medium disk mirrored", :layout => "filesys mirror:d10 c1t0d0s0 c1t1d0s0 16000 /\nfilesys mirror:d20 c1t0d0s1 c1t1d0s1 8000 swap\nfilesys mirror:d40 c1t0d0s4 c1t1d0s4 free /var/tmp\nmetadb c1t0d0s7 size 8192 count 3\nmetadb c1t1d0s7 size 8192 count 3\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
Ptable.without_auditing {
disk = Ptable.create :name => "Solaris small disk c1t0", :layout =>"filesys c1t0d0s0 7000 /\nfilesys c1t0d0s1 1000 swap\nfilesys c1t0d0s3 15 unnamed\nfilesys c1t0d0s7 free /tmp2\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
disk = Ptable.create :name => "Solaris small disk c0t0", :layout =>"filesys c0t0d0s0 7000 /\nfilesys c0t0d0s1 1000 swap\nfilesys c0t0d0s3 15 unnamed\nfilesys c0t0d0s7 free /tmp2\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
disk = Ptable.create :name => "Solaris medium disk mirrored", :layout => "filesys mirror:d10 c1t0d0s0 c1t1d0s0 16000 /\nfilesys mirror:d20 c1t0d0s1 c1t1d0s1 8000 swap\nfilesys mirror:d40 c1t0d0s4 c1t1d0s4 free /var/tmp\nmetadb c1t0d0s7 size 8192 count 3\nmetadb c1t1d0s7 size 8192 count 3\n"
disk.operatingsystems = Operatingsystem.find_all_by_type "Solaris"
}
end
def self.down
Ptable.find_by_name("Solaris medium disk mirrored").destroy
Ptable.find_by_name("Solaris small disk c0t0").destroy
Ptable.find_by_name("Solaris small disk c1t0").destroy
Ptable.without_auditing {
Ptable.find_by_name("Solaris medium disk mirrored").destroy
Ptable.find_by_name("Solaris small disk c0t0").destroy
Ptable.find_by_name("Solaris small disk c1t0").destroy
}
end
end
test/unit/ptable_test.rb
assert record.valid?
end
test 'when creating a new ptable class object, an audit entry needs to be added' do
as_admin do
assert_difference('Audit.count') do
Ptable.create! :name => "dummy", :layout => "layout"
end
end
end
end

Also available in: Unified diff