Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename kernel_arguments to kdump_kernel_arguments * Add crashkernel fact * Checks for crashkernel being set are done using crashkernel fact
- Loading branch information
Showing
9 changed files
with
56 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Fact: crashkernel | ||
# | ||
# Purpose: | ||
# This fact checks for current crashkernel in kernel boot | ||
# | ||
# Resolution: | ||
# Checks `proc/cmdline` | ||
# | ||
# Caveats: | ||
# Only supports Linux. | ||
# | ||
|
||
Facter.add(:crashkernel) do | ||
confine kernel: :linux | ||
setcode do | ||
crashkernel = false | ||
kernel_arguments = Facter.value(:kdump_kernel_arguments) | ||
if kernel_arguments | ||
if kernel_arguments =~ %r{crashkernel=(\S+)} | ||
crashkernel = Regexp.last_match(1) | ||
end | ||
end | ||
crashkernel | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 1 addition & 0 deletions
1
spec/fixtures/unit/facter/crashkernel/kernelargs-without-crash.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ro root=/dev/mapper/vg_sys-lv_root rd_LVM_LV=vg_sys/lv_swap rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD KEYTABLE=us nofb quiet splash=quiet SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_sys/lv_root rd_NO_DM rhgb quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ro root=/dev/mapper/vg_sys-lv_root rd_LVM_LV=vg_sys/lv_swap rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD KEYTABLE=us nofb quiet splash=quiet SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_sys/lv_root rd_NO_DM rhgb quiet crashkernel=131M@0M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'spec_helper' | ||
|
||
describe 'crashkernel fact' do | ||
before :each do | ||
Facter.clear | ||
end | ||
|
||
context 'kernel is linux' do | ||
it 'returns crashkernel' do | ||
allow(Facter::Core::Execution).to receive(:exec).with('uname -s').and_return('Linux') | ||
allow(Facter).to receive(:value).with(:kdump_kernel_arguments).and_return(my_fixture_read('kernelargs-with-crash.txt')) | ||
expect(Facter.fact(:crashkernel).value).to eq('131M@0M') | ||
end | ||
it 'returns false' do | ||
allow(Facter::Core::Execution).to receive(:exec).with('uname -s').and_return('Linux') | ||
allow(Facter).to receive(:value).with(:kdump_kernel_arguments).and_return(my_fixture_read('kernelargs-without-crash.txt')) | ||
expect(Facter.fact(:crashkernel).value).to eq(false) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters