Format IPv6 address for ring device
The IPv6 addresses in ring_*_device resource names should be surrounded by []. This ensures the address is properly formatted when the resource is define in swift::storage::node. Closes-Bug: #1997295 Change-Id: I390f3c7bbfbbbc7217f81e8a0312e5db201ef409
This commit is contained in:
parent
0dcd3afa09
commit
a8ef5f6906
@ -72,10 +72,12 @@ define swift::storage::node(
|
||||
config_file_path => 'object-server.conf',
|
||||
}
|
||||
|
||||
$ring_host = normalize_ip_for_uri($storage_local_net_ip)
|
||||
|
||||
if !$policy_index {
|
||||
$ring_device = "${storage_local_net_ip}:60${name}0/${name}"
|
||||
$ring_device = "${ring_host}:60${name}0/${name}"
|
||||
} else {
|
||||
$ring_device = "${policy_index}:${storage_local_net_ip}:60${name}0/${name}"
|
||||
$ring_device = "${policy_index}:${ring_host}:60${name}0/${name}"
|
||||
}
|
||||
|
||||
ring_object_device { $ring_device:
|
||||
@ -87,7 +89,7 @@ define swift::storage::node(
|
||||
type => 'container',
|
||||
config_file_path => 'container-server.conf',
|
||||
}
|
||||
ring_container_device { "${storage_local_net_ip}:60${name}1/${name}":
|
||||
ring_container_device { "${ring_host}:60${name}1/${name}":
|
||||
zone => $zone,
|
||||
weight => $weight,
|
||||
}
|
||||
@ -96,7 +98,7 @@ define swift::storage::node(
|
||||
type => 'account',
|
||||
config_file_path => 'account-server.conf',
|
||||
}
|
||||
ring_account_device { "${storage_local_net_ip}:60${name}2/${name}":
|
||||
ring_account_device { "${ring_host}:60${name}2/${name}":
|
||||
zone => $zone,
|
||||
weight => $weight,
|
||||
}
|
||||
|
@ -2,60 +2,81 @@ require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::node' do
|
||||
shared_examples 'swift::storage::node' do
|
||||
describe 'with valid preconditons should contain ring devices' do
|
||||
let :title do
|
||||
"1"
|
||||
end
|
||||
|
||||
context 'with valid preconditons and IPv4 address' do
|
||||
let :params do
|
||||
{
|
||||
:zone => "1",
|
||||
:zone => "1",
|
||||
:mnt_base_dir => '/srv/node'
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
"1"
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '127.0.0.1' }"
|
||||
end
|
||||
|
||||
it { is_expected.to contain_ring_object_device("127.0.0.1:6010/1") }
|
||||
it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") }
|
||||
it { is_expected.to contain_ring_account_device("127.0.0.1:6012/1") }
|
||||
it 'should contain ring devices' do
|
||||
is_expected.to contain_ring_object_device("127.0.0.1:6010/1")
|
||||
is_expected.to contain_ring_container_device("127.0.0.1:6011/1")
|
||||
is_expected.to contain_ring_account_device("127.0.0.1:6012/1")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when zone is not a number' do
|
||||
let(:title) { '1' }
|
||||
|
||||
let :params do
|
||||
{ :zone => 'invalid',
|
||||
:mnt_base_dir => '/srv/node' }
|
||||
end
|
||||
let :params do
|
||||
{
|
||||
:zone => 'invalid',
|
||||
:mnt_base_dir => '/srv/node'
|
||||
}
|
||||
end
|
||||
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
describe 'with valid preconditons and policy_index=1 should contain ring devices' do
|
||||
context 'with valid preconditions and IPv6 address' do
|
||||
let :params do
|
||||
{
|
||||
:zone => "1",
|
||||
:zone => "1",
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:storage_local_net_ip => '::1',
|
||||
}
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '::1' }"
|
||||
end
|
||||
|
||||
it 'should contain ring devices with IPv6 address' do
|
||||
is_expected.to contain_ring_object_device("[::1]:6010/1")
|
||||
is_expected.to contain_ring_container_device("[::1]:6011/1")
|
||||
is_expected.to contain_ring_account_device("[::1]:6012/1")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid preconditons and policy_index=1' do
|
||||
let :params do
|
||||
{
|
||||
:zone => "1",
|
||||
:mnt_base_dir => '/srv/node',
|
||||
:policy_index => '1',
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
"1"
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '127.0.0.1' }"
|
||||
end
|
||||
|
||||
it { is_expected.to contain_ring_object_device("1:127.0.0.1:6010/1") }
|
||||
it { is_expected.to contain_ring_container_device("127.0.0.1:6011/1") }
|
||||
it { is_expected.to contain_ring_account_device("127.0.0.1:6012/1") }
|
||||
it 'should contain ring devices' do
|
||||
is_expected.to contain_ring_object_device("1:127.0.0.1:6010/1")
|
||||
is_expected.to contain_ring_container_device("127.0.0.1:6011/1")
|
||||
is_expected.to contain_ring_account_device("127.0.0.1:6012/1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user