Add seed parameter to ringbuilder::rebalance.
This patch adds an optional seed parameter to the swift::ringbuilder::rebalance definition. The seed parameter can be useful if you want to (manually) generate rings on independant servers and ensure that the partition assignments are the same. Change-Id: I840b8fe0125ed25e84f7681fada1b1102e48f32b
This commit is contained in:
parent
f9724a5050
commit
b8b443416d
@ -6,12 +6,19 @@
|
||||
#
|
||||
# [*name*] Type of ring to rebalance. The ring file is assumed to be at the path
|
||||
# /etc/swift/${name}.builder
|
||||
define swift::ringbuilder::rebalance() {
|
||||
#
|
||||
# [*seed*] Optional. Seed value used to seed pythons pseudo-random for ringbuilding.
|
||||
define swift::ringbuilder::rebalance(
|
||||
$seed = undef
|
||||
) {
|
||||
|
||||
validate_re($name, '^object|container|account$')
|
||||
if $seed {
|
||||
validate_re($seed, '^\d+$')
|
||||
}
|
||||
|
||||
exec { "rebalance_${name}":
|
||||
command => "swift-ring-builder /etc/swift/${name}.builder rebalance",
|
||||
command => strip("swift-ring-builder /etc/swift/${name}.builder rebalance ${seed}"),
|
||||
path => ['/usr/bin'],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
@ -14,6 +14,30 @@ describe 'swift::ringbuilder::rebalance' do
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'with valid seed' do
|
||||
let :params do
|
||||
{ :seed => '999' }
|
||||
end
|
||||
let :title do
|
||||
'object'
|
||||
end
|
||||
it { should contain_exec("rebalance_object").with(
|
||||
{:command => "swift-ring-builder /etc/swift/object.builder rebalance 999",
|
||||
:path => '/usr/bin',
|
||||
:refreshonly => true}
|
||||
)}
|
||||
end
|
||||
describe 'with an invalid seed' do
|
||||
let :title do
|
||||
'object'
|
||||
end
|
||||
let :params do
|
||||
{ :seed => 'invalid' }
|
||||
end
|
||||
it 'should raise an error' do
|
||||
expect { subject }.to raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
describe 'with an invalid title' do
|
||||
let :title do
|
||||
'invalid'
|
||||
|
Loading…
x
Reference in New Issue
Block a user