Merge pull request #56 from rubiojr/xfs-storage-improvements

swift::storage::xfs improvements
This commit is contained in:
Dan Bode 2012-10-28 18:18:51 -07:00
commit 58d9d17e57
2 changed files with 42 additions and 26 deletions
manifests/storage
spec/defines

@ -1,34 +1,56 @@
# follow the instructions for creating a loopback device
# for storage from: http://swift.openstack.org/development_saio.html
#
#
#
# this define needs to be sent a refresh signal to do anything
#
#
# [*title*]
# [*title*]
#
# [*byte_size*] Byte size to use for every inode in the created filesystem.
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode.
#
#
# Sample usage:
#
# swift::storage::xfs {
# ['sdb', 'sdc', 'sde', 'sdf', 'sdg', 'sdh', 'sdi', 'sdj', 'sdk']:
# mnt_base_dir => '/srv/node',
# require => Class['swift'];
# }
#
# Creates /srv/node if dir does not exist, formats sdbX with XFS unless
# it already has an XFS FS, and mounts de FS in /srv/node/sdX
#
define swift::storage::xfs(
$device,
$device = '',
$byte_size = '1024',
$mnt_base_dir = '/srv/node',
$loopback = false
) {
include swift::xfs
# does this have to be refreshonly?
# how can I know if this drive has been formatted?
if $device == '' {
$target_device = "/dev/${name}"
} else {
$target_device = $device
}
if(!defined(File[$mnt_base_dir])) {
file { $mnt_base_dir:
owner => 'swift',
group => 'swift',
ensure => directory,
}
}
# We use xfs_admin -l to print FS label
# If it's not a valid XFS FS, command will return 1
# so we format it. If device has a valid XFS FS, command returns 0
# So we do NOT touch it.
exec { "mkfs-${name}":
command => "mkfs.xfs -i size=${byte_size} ${device}",
path => ['/sbin/'],
refreshonly => true,
require => Package['xfsprogs'],
command => "mkfs.xfs -f -i size=${byte_size} ${target_device}",
path => ['/sbin/', '/usr/sbin/'],
require => Package['xfsprogs'],
unless => "xfs_admin -l ${target_device}",
}
swift::storage::mount { $name:
device => $device,
device => "/dev/${name}",
mnt_base_dir => $mnt_base_dir,
subscribe => Exec["mkfs-${name}"],
loopback => $loopback,

@ -3,11 +3,6 @@ describe 'swift::storage::xfs' do
let :title do
'foo'
end
describe 'when a device is not specified' do
it 'should raise an error' do
expect { subject }.to raise_error(Puppet::Error)
end
end
describe 'when a device is specified' do
let :default_params do
@ -38,14 +33,13 @@ describe 'swift::storage::xfs' do
end
it { should contain_exec("mkfs-foo").with(
:command => "mkfs.xfs -i size=#{param_hash[:byte_size]} #{param_hash[:device]}",
:path => '/sbin/',
:refreshonly => true,
:command => "mkfs.xfs -f -i size=#{param_hash[:byte_size]} #{param_hash[:device]}",
:path => ['/sbin/', '/usr/sbin/'],
:require => 'Package[xfsprogs]'
)}
it { should contain_swift__storage__mount('foo').with(
:device => param_hash[:device],
:device => '/dev/foo',
:mnt_base_dir => param_hash[:mnt_base_dir],
:loopback => param_hash[:loopback],
:subscribe => 'Exec[mkfs-foo]'