Skip to content

Commit

Permalink
Support UdevNameAttr attribute on disk plugin (fixes #300)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnangle committed Jul 27, 2015
1 parent 975e1d5 commit ed2cdf5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions manifests/plugin/disk.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$disks = [],
$ignoreselected = false,
$interval = undef,
$udevnameattr = undef,
) {

validate_array($disks)
Expand Down
36 changes: 35 additions & 1 deletion spec/classes/collectd_plugin_disk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,39 @@
should compile.and_raise_error(/String/)
end
end
end

context ':udevnameattr on collectd < 5.5' do
let :params do
{:udevnameattr => 'DM_NAME'}
end
let :facts do
{ :osfamily => 'RedHat',
:collectd_version => '5.4',
}
end
it 'Will not include the setting' do
should contain_file('disk.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-disk.conf',
}).without_content(/UdevNameAttr DM_NAME/)
end
end

context ':udevnameattr on collectd >= 5.5' do
let :params do
{:udevnameattr => 'DM_NAME'}
end
let :facts do
{ :osfamily => 'RedHat',
:collectd_version => '5.5',
}
end
it 'Will include the setting' do
should contain_file('disk.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-disk.conf',
:content => /UdevNameAttr DM_NAME/,
})
end
end
end
3 changes: 3 additions & 0 deletions templates/plugin/disk.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
Disk "<%=disk %>"
<% end -%>
IgnoreSelected <%= @ignoreselected %>
<% if @udevnameattr and @collectd_version and (scope.function_versioncmp([@collectd_version, '5.5']) >= 0) -%>
UdevNameAttr <%= @udevnameattr %>
<% end -%>
</Plugin>

0 comments on commit ed2cdf5

Please sign in to comment.