Add swift::storage::disk to support disk device.
It aim to support to use the disk device as the swift storage backend, this pathch contains: * a new define with three params * annotations and examples for this define * a new spec test Change-Id: I92f13992a02b9cff0f29bde3266a92f37bf63d13
This commit is contained in:
parent
b0f4834165
commit
d339eb4937
63
manifests/storage/disk.pp
Normal file
63
manifests/storage/disk.pp
Normal file
@ -0,0 +1,63 @@
|
||||
# This Puppet resource is based on the following
|
||||
# instructions for creating a disk device:
|
||||
# http://swift.openstack.org/development_saio.html
|
||||
#
|
||||
# ==Add a raw disk to a swift storage node==
|
||||
#
|
||||
# It will do two steps to create a disk device:
|
||||
# - creates a disk table, use the whole disk instead
|
||||
# to make the partition (e.g. use sdb as a whole)
|
||||
# - formats the partition to an xfs device and
|
||||
# mounts it as a block device at /srv/node/$name
|
||||
#
|
||||
# ATTENTION: You should not use the disk that your Operating System
|
||||
# is installed on (typically /dev/sda/).
|
||||
#
|
||||
# =Parameters=
|
||||
# $base_dir = '/dev', assumes local disk devices
|
||||
# $mnt_base_dir = '/srv/node', base directory where disks are mounted to
|
||||
# $byte_size = '1024', block size for the disk. For very large partitions, this should be larger
|
||||
#
|
||||
# =Example=
|
||||
#
|
||||
# Simply add one disk sdb:
|
||||
#
|
||||
# swift::storage:disk { "sdb":}
|
||||
#
|
||||
# Add more than one disks and overwrite byte_size:
|
||||
#
|
||||
# swift::storage::disk {['sdb','sdc','sdd']:
|
||||
# byte_size => '2048',
|
||||
# }
|
||||
#
|
||||
# TODO(yuxcer): maybe we can remove param $base_dir
|
||||
|
||||
define swift::storage::disk(
|
||||
$base_dir = '/dev',
|
||||
$mnt_base_dir = '/srv/node',
|
||||
$byte_size = '1024',
|
||||
) {
|
||||
|
||||
if(!defined(File[$mnt_base_dir])) {
|
||||
file { $mnt_base_dir:
|
||||
owner => 'swift',
|
||||
group => 'swift',
|
||||
ensure => directory,
|
||||
}
|
||||
}
|
||||
|
||||
exec { "create_partition_label-${name}":
|
||||
command => "parted -s ${base_dir}/${name} mklabel gpt",
|
||||
path => ['/usr/bin/', '/sbin','/bin'],
|
||||
onlyif => ["test -b ${base_dir}/${name}","parted ${base_dir}/${name} print|tail -1|grep 'Error'"],
|
||||
}
|
||||
|
||||
swift::storage::xfs { $name:
|
||||
device => "${base_dir}/${name}",
|
||||
mnt_base_dir => $mnt_base_dir,
|
||||
byte_size => $byte_size,
|
||||
loopback => false,
|
||||
subscribe => Exec["create_partition_label-${name}"],
|
||||
}
|
||||
|
||||
}
|
26
spec/defines/swift_storage_disk_spec.rb
Normal file
26
spec/defines/swift_storage_disk_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::disk' do
|
||||
# TODO add more unit tests
|
||||
|
||||
let :title do
|
||||
'sdb'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{
|
||||
:base_dir => '/dev',
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:byte_size => '1024',
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_swift__storage__xfs('sdb').with(
|
||||
:device => '/dev/sdb',
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:byte_size => '1024',
|
||||
:subscribe => 'Exec[create_partition_label-sdb]',
|
||||
:loopback => false
|
||||
) }
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user