forked from jhoblitt/puppet-smartd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Hoblitt
committed
Apr 12, 2014
1 parent
57af86d
commit 60a2988
Showing
4 changed files
with
80 additions
and
0 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,12 @@ | ||
Facter.add(:smartmontools_version) do | ||
smartd = Facter.value(:smartd) | ||
setcode do | ||
unless smartd.nil? | ||
output = Facter::Util::Resolution.exec("#{smartd} --version") | ||
next if output.nil? | ||
m = output.match(/smartmontools release ([\d\.]+)/) | ||
next unless m.size == 2 | ||
m[1] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
smartd 5.42 2011-10-20 r3458 [x86_64-linux-2.6.18-348.6.1.el5] (local build) | ||
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net | ||
|
||
smartd comes with ABSOLUTELY NO WARRANTY. This is free | ||
software, and you are welcome to redistribute it under | ||
the terms of the GNU General Public License Version 2. | ||
See http://www.gnu.org for further details. | ||
|
||
smartmontools release 5.42 dated 2011-10-20 at 19:19:34 UTC | ||
smartmontools SVN rev 3458 dated 2011-10-20 at 19:20:23 | ||
smartmontools build host: x86_64-redhat-linux-gnu | ||
smartmontools build configured: 2013-01-09 08:24:57 UTC | ||
smartd compile dated Jan 9 2013 at 03:25:25 | ||
smartmontools configure arguments: '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-selinux' '--without-systemdsystemunitdir' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' |
15 changes: 15 additions & 0 deletions
15
spec/fixtures/smartd/version-smartmontools-5.43-1.el6.x86_64
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,15 @@ | ||
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-2.6.32-431.5.1.el6.x86_64] (local build) | ||
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net | ||
|
||
smartctl comes with ABSOLUTELY NO WARRANTY. This is free | ||
software, and you are welcome to redistribute it under | ||
the terms of the GNU General Public License; either | ||
version 2, or (at your option) any later version. | ||
See http://www.gnu.org for further details. | ||
|
||
smartmontools release 5.43 dated 2012-06-30 at 14:03:01 UTC | ||
smartmontools SVN rev 3573 dated 2012-06-30 at 14:03:55 | ||
smartmontools build host: x86_64-redhat-linux-gnu | ||
smartmontools build configured: 2012-09-25 16:04:33 UTC | ||
smartctl compile dated Sep 25 2012 at 12:04:43 | ||
smartmontools configure arguments: '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-selinux' '--with-libcap-ng=yes' '-with-systemdsystemunitdir=no' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-redhat-linux-gnu' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/share/pkgconfig' |
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,39 @@ | ||
require 'spec_helper' | ||
|
||
describe 'smartmontools_version', :type => :fact do | ||
before(:each) { Facter.clear } | ||
|
||
context 'smartd fact not set' do | ||
it 'should return nil' do | ||
Facter.fact(:smartd).stubs(:value).returns(nil) | ||
Facter.fact(:smartmontools_version).value.should be_nil | ||
end | ||
end | ||
|
||
context 'smartd fact is broken' do | ||
it 'should return nil' do | ||
Facter.fact(:smartd).stubs(:value).returns('foobar') | ||
Facter.fact(:smartmontools_version).value.should be_nil | ||
end | ||
end | ||
|
||
context 'smartd fact is working' do | ||
it 'should get the version string' do | ||
Facter.fact(:smartd).stubs(:value).returns('/usr/sbin/smartd') | ||
Facter::Util::Resolution.stubs(:exec). | ||
with('/usr/sbin/smartd --version'). | ||
returns(File.read(fixtures('smartd', 'version-smartmontools-5.42-2.el5'))) | ||
Facter.fact(:smartmontools_version).value.should == '5.42' | ||
end | ||
|
||
it 'should get the version string' do | ||
Facter.fact(:smartd).stubs(:value).returns('/usr/sbin/smartd') | ||
Facter::Util::Resolution.stubs(:exec). | ||
with('/usr/sbin/smartd --version'). | ||
returns(File.read(fixtures('smartd', 'version-smartmontools-5.43-1.el6.x86_64'))) | ||
Facter.fact(:smartmontools_version).value.should == '5.43' | ||
end | ||
end | ||
|
||
end | ||
|