Merge pull request #26 from fcharlier/replicator_services

Replicator services
This commit is contained in:
Dan Bode 2012-06-05 09:29:54 -07:00
commit b428438460
4 changed files with 88 additions and 20 deletions

View File

@ -183,6 +183,7 @@ class role_swift_storage inherits role_swift {
}
# sync ring databases if they have been exported
Swift::Ringsync<<||>>
# do this before checking the status of the storage services
Swift::Ringsync<<||>> -> Class['swift::storage::all']
}

View File

@ -1,15 +1,18 @@
class swift::params {
case $osfamily {
'Debian': {
$package_name = 'swift'
$proxy_package_name = 'swift-proxy'
$proxy_service_name = 'swift-proxy'
$object_package_name = 'swift-object'
$object_service_name = 'swift-object'
$container_package_name = 'swift-container'
$container_service_name = 'swift-container'
$account_package_name = 'swift-account'
$account_service_name = 'swift-account'
$package_name = 'swift'
$proxy_package_name = 'swift-proxy'
$proxy_service_name = 'swift-proxy'
$object_package_name = 'swift-object'
$object_service_name = 'swift-object'
$object_replicator_service_name = 'swift-object-replicator'
$container_package_name = 'swift-container'
$container_service_name = 'swift-container'
$container_replicator_service_name = 'swift-container-replicator'
$account_package_name = 'swift-account'
$account_service_name = 'swift-account'
$account_replicator_service_name = 'swift-account-replicator'
if $::operatingsystem == 'Debian' {
$service_proivider = 'debian'
} else {
@ -17,16 +20,19 @@ class swift::params {
}
}
'RedHat': {
$package_name = 'openstack-swift'
$proxy_package_name = 'openstack-swift-proxy'
$proxy_service_name = 'openstack-swift-proxy'
$object_package_name = 'openstack-swift-object'
$object_service_name = 'openstack-swift-object'
$container_package_name = 'openstack-swift-container'
$container_service_name = 'openstack-swift-container'
$account_package_name = 'openstack-swift-account'
$account_service_name = 'openstack-swift-account'
$service_provider = undef
$package_name = 'openstack-swift'
$proxy_package_name = 'openstack-swift-proxy'
$proxy_service_name = 'openstack-swift-proxy'
$object_package_name = 'openstack-swift-object'
$object_service_name = 'openstack-swift-object'
$object_replicator_service_name = undef
$container_package_name = 'openstack-swift-container'
$container_service_name = 'openstack-swift-container'
$container_replicator_service_name = undef
$account_package_name = 'openstack-swift-account'
$account_service_name = 'openstack-swift-account'
$account_replicator_service_name = undef
$service_provider = undef
}
default: {
fail("Unsupported osfamily: ${osfamily} for os ${operatingsystem}")

View File

@ -51,4 +51,13 @@ define swift::storage::generic(
subscribe => Package["swift-${name}"],
}
service { "swift-${name}-replicator":
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_replicator_service_name') %>"),
ensure => running,
enable => true,
hasstatus => true,
provider => $service_provider,
subscribe => Package["swift-${name}"],
}
}

View File

@ -64,6 +64,13 @@ describe 'swift::storage::all' do
:enable => true,
:hasstatus => true
})}
it { should contain_service("swift-#{type}-replicator").with(
{:provider => 'upstart',
:ensure => 'running',
:enable => true,
:hasstatus => true
}
)}
it { should contain_file("/etc/swift/#{type}-server/").with(
{:ensure => 'directory',
:owner => 'swift',
@ -101,4 +108,49 @@ describe 'swift::storage::all' do
end
end
describe "when installed on Debian" do
let :facts do
{
:operatingsystem => 'Debian',
:osfamily => 'Debian'
}
end
[{ :storage_local_net_ip => '127.0.0.1' },
{
:devices => '/tmp/node',
:storage_local_net_ip => '10.0.0.1',
:object_port => '7000',
:container_port => '7001',
:account_port => '7002'
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
let :param_hash do
default_params.merge(param_set)
end
let :params do
param_set
end
['object', 'container', 'account'].each do |type|
it { should contain_package("swift-#{type}").with_ensure('present') }
it { should contain_service("swift-#{type}").with(
{:provider => nil,
:ensure => 'running',
:enable => true,
:hasstatus => true
})}
it { should contain_service("swift-#{type}-replicator").with(
{:provider => nil,
:ensure => 'running',
:enable => true,
:hasstatus => true
}
)}
end
end
end
end
end