Merge pull request #46 from bodepd/add_loopback_mnt_param
Add loopback mnt param
This commit is contained in:
@@ -7,10 +7,10 @@
|
|||||||
# - formats the file to be an xfs device and mounts it as a loopback device at /srv/node/$name
|
# - formats the file to be an xfs device and mounts it as a loopback device at /srv/node/$name
|
||||||
# - sets up each mount point as a swift endpoint
|
# - sets up each mount point as a swift endpoint
|
||||||
define swift::storage::loopback(
|
define swift::storage::loopback(
|
||||||
$base_dir = '/srv/loopback-device',
|
$base_dir = '/srv/loopback-device',
|
||||||
$mnt_base_dir = '/srv/node',
|
$mnt_base_dir = '/srv/node',
|
||||||
$byte_size = '1024',
|
$byte_size = '1024',
|
||||||
$seek = '25000'
|
$seek = '25000'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if(!defined(File[$base_dir])) {
|
if(!defined(File[$base_dir])) {
|
||||||
@@ -39,6 +39,7 @@ define swift::storage::loopback(
|
|||||||
mnt_base_dir => $mnt_base_dir,
|
mnt_base_dir => $mnt_base_dir,
|
||||||
byte_size => $byte_size,
|
byte_size => $byte_size,
|
||||||
subscribe => Exec["create_partition-${name}"],
|
subscribe => Exec["create_partition-${name}"],
|
||||||
|
loopback => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -5,9 +5,14 @@
|
|||||||
#
|
#
|
||||||
define swift::storage::mount(
|
define swift::storage::mount(
|
||||||
$device,
|
$device,
|
||||||
$mnt_base_dir = '/srv/node'
|
$mnt_base_dir = '/srv/node',
|
||||||
|
$loopback = false
|
||||||
) {
|
) {
|
||||||
|
if($loopback){
|
||||||
|
$options = 'noatime,nodiratime,nobarrier,logbufs=8,loop'
|
||||||
|
} else {
|
||||||
|
$options = 'noatime,nodiratime,nobarrier,logbufs=8'
|
||||||
|
}
|
||||||
# the directory that represents the mount point
|
# the directory that represents the mount point
|
||||||
# needs to exist
|
# needs to exist
|
||||||
file { "${mnt_base_dir}/${name}":
|
file { "${mnt_base_dir}/${name}":
|
||||||
@@ -20,7 +25,7 @@ define swift::storage::mount(
|
|||||||
ensure => present,
|
ensure => present,
|
||||||
device => $device,
|
device => $device,
|
||||||
fstype => 'xfs',
|
fstype => 'xfs',
|
||||||
options => 'loop,noatime,nodiratime,nobarrier,logbufs=8',
|
options => $options,
|
||||||
require => File["${mnt_base_dir}/${name}"]
|
require => File["${mnt_base_dir}/${name}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,8 +12,9 @@
|
|||||||
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode.
|
# It is recommened to use 1024 to ensure that the metadata can fit in a single inode.
|
||||||
define swift::storage::xfs(
|
define swift::storage::xfs(
|
||||||
$device,
|
$device,
|
||||||
$byte_size = '1024',
|
$byte_size = '1024',
|
||||||
$mnt_base_dir = '/srv/node'
|
$mnt_base_dir = '/srv/node',
|
||||||
|
$loopback = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include swift::xfs
|
include swift::xfs
|
||||||
@@ -29,7 +30,8 @@ define swift::storage::xfs(
|
|||||||
swift::storage::mount { $name:
|
swift::storage::mount { $name:
|
||||||
device => $device,
|
device => $device,
|
||||||
mnt_base_dir => $mnt_base_dir,
|
mnt_base_dir => $mnt_base_dir,
|
||||||
subscribe => Exec["mkfs-${name}"]
|
subscribe => Exec["mkfs-${name}"],
|
||||||
|
loopback => $loopback,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,18 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'swift::storage::loopback' do
|
describe 'swift::storage::loopback' do
|
||||||
# TODO add unit tests
|
# TODO add more unit tests
|
||||||
# this is not the highest priority b/c it is really for testing
|
|
||||||
|
let :title do
|
||||||
|
'dans_disk'
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_swift__storage__xfs('dans_disk').with(
|
||||||
|
:device => '/srv/loopback-device/dans_disk',
|
||||||
|
:mnt_base_dir => '/srv/node',
|
||||||
|
:byte_size => '1024',
|
||||||
|
:subscribe => 'Exec[create_partition-dans_disk]',
|
||||||
|
:loopback => true
|
||||||
|
) }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@@ -1,4 +1,42 @@
|
|||||||
|
require 'spec_helper'
|
||||||
describe 'swift::storage::mount' do
|
describe 'swift::storage::mount' do
|
||||||
# TODO add unit tests
|
# TODO add unit tests
|
||||||
# not a super high priority b/c this is just for testing
|
|
||||||
|
let :title do
|
||||||
|
'dans_mount_point'
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'with defaults params' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:device => '/dev/sda'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_mount('/srv/node/dans_mount_point').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:device => '/dev/sda',
|
||||||
|
:fstype => 'xfs',
|
||||||
|
:options => 'noatime,nodiratime,nobarrier,logbufs=8',
|
||||||
|
:require => 'File[/srv/node/dans_mount_point]'
|
||||||
|
)}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when mounting a loopback device' do
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:device => '/dev/sda',
|
||||||
|
:loopback => true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_mount('/srv/node/dans_mount_point').with(
|
||||||
|
:device => '/dev/sda',
|
||||||
|
:options => 'noatime,nodiratime,nobarrier,logbufs=8,loop'
|
||||||
|
)}
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@@ -11,15 +11,21 @@ describe 'swift::storage::xfs' do
|
|||||||
|
|
||||||
describe 'when a device is specified' do
|
describe 'when a device is specified' do
|
||||||
let :default_params do
|
let :default_params do
|
||||||
{:device => 'some_device',
|
{
|
||||||
|
:device => 'some_device',
|
||||||
:byte_size => '1024',
|
:byte_size => '1024',
|
||||||
:mnt_base_dir => '/srv/node'}
|
:mnt_base_dir => '/srv/node',
|
||||||
|
:loopback => false
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
[{:device => 'some_device'},
|
[{:device => 'some_device'},
|
||||||
{:device => 'some_device',
|
{
|
||||||
:byte_size => 1,
|
:device => 'some_device',
|
||||||
:mnt_base_dir => '/mnt/foo'}
|
:byte_size => 1,
|
||||||
|
:mnt_base_dir => '/mnt/foo',
|
||||||
|
:loopback => true
|
||||||
|
}
|
||||||
].each do |param_set|
|
].each do |param_set|
|
||||||
|
|
||||||
describe "#{param_set == {} ? "using default" : "specifying"} class parameters" do
|
describe "#{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||||
@@ -39,9 +45,10 @@ describe 'swift::storage::xfs' do
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
it { should contain_swift__storage__mount('foo').with(
|
it { should contain_swift__storage__mount('foo').with(
|
||||||
{:device => param_hash[:device],
|
:device => param_hash[:device],
|
||||||
:mnt_base_dir => param_hash[:mnt_base_dir],
|
:mnt_base_dir => param_hash[:mnt_base_dir],
|
||||||
:subscribe => 'Exec[mkfs-foo]'}
|
:loopback => param_hash[:loopback],
|
||||||
|
:subscribe => 'Exec[mkfs-foo]'
|
||||||
)}
|
)}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
1
spec/fixtures/modules/swift
vendored
1
spec/fixtures/modules/swift
vendored
@@ -1 +0,0 @@
|
|||||||
../../../
|
|
Reference in New Issue
Block a user