Allow dynamic configuration for devices and filesystems

* Edit .fixtures.yml to add ssh and rsync dependency
* Created the cloud_objectstorage_stroage_spec.rb
This commit is contained in:
Yanis Guenane 2014-05-22 17:19:09 -04:00
parent b7203bbaef
commit 315b6dcabe
3 changed files with 141 additions and 14 deletions

View File

@ -87,5 +87,11 @@ fixtures:
'kmod':
repo: 'git://github.com/enovance/puppet-kmod.git'
ref: 'accc40093e6f8ee9cc472e9eb6ba3bab4bad3a1f'
'ssh':
repo: 'git://github.com/enovance/puppet-ssh.git'
ref: '10675c0d80511a8cdd514af67b695887fa97ec40'
'rsync':
repo: 'git://github.com/enovance/puppetlabs-rsync.git'
ref: '7122983d89bf68bc4170415cc03212f6a8a4636e'
symlinks:
'cloud': '#{source_dir}'

View File

@ -16,12 +16,15 @@
# Swift Storage node
#
class cloud::object::storage (
$storage_eth = '127.0.0.1',
$swift_zone = undef,
$object_port = '6000',
$container_port = '6001',
$account_port = '6002',
$onloopdevices = false,
$storage_eth = '127.0.0.1',
$swift_zone = undef,
$object_port = '6000',
$container_port = '6001',
$account_port = '6002',
$fstype = 'xfs',
$device_config_hash = {},
$ring_container_device = 'sdb',
$ring_account_device = 'sdb',
) {
include 'cloud::object'
@ -77,21 +80,18 @@ allow_versions = on
swift::storage::filter::recon { $swift_components : }
swift::storage::filter::healthcheck { $swift_components : }
$object_nodes = flatten([ range('sdc','sdd')])
swift::storage::xfs { $object_nodes: }
swift::storage::xfs { 'sdb': }
cloud::object::set_io_scheduler {'sdb':}
cloud::object::set_io_scheduler {$object_nodes:}
create_resources("swift::storage::${fstype}", $device_config_hash)
create_resources('cloud::object::set_io_scheduler', $device_config_hash)
@@ring_container_device { "${storage_eth}:${container_port}/sdb":
@@ring_container_device { "${storage_eth}:${container_port}/${ring_container_device}":
zone => $swift_zone,
weight => '100.0',
}
@@ring_account_device { "${storage_eth}:${account_port}/sdb":
@@ring_account_device { "${storage_eth}:${account_port}/${ring_account_device}":
zone => $swift_zone,
weight => '100.0',
}
$object_urls = prefix($object_nodes, "${storage_eth}:${object_port}/")
$object_urls = prefix(keys($device_config_hash), "${storage_eth}:${object_port}/")
@@ring_object_device {$object_urls:
zone => $swift_zone,
weight => '100.0',

View File

@ -0,0 +1,121 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Unit tests for cloud::object::storage class
#
require 'spec_helper'
describe 'cloud::object::storage' do
shared_examples_for 'openstack storage configuration' do
let :params do
{ :storage_eth => '127.0.0.1',
:swift_zone => 'undef',
:object_port => '6000',
:container_port => '6001',
:account_port => '6002',
:fstype => 'xfs',
:device_config_hash => {'sdc' => {}, 'sdd' => {}},
:ring_container_device => 'sdb',
:ring_account_device => 'sdb' }
end
it 'create and configure storage server' do
should contain_class('swift::storage').with({
'storage_local_net_ip' => '127.0.0.1',
})
should contain_swift__storage__server('6000').with({
'type' => 'object',
'config_file_path' => 'object-server.conf',
'log_facility' => 'LOG_LOCAL6',
'pipeline' => ['healthcheck', 'recon', 'object-server'],
'storage_local_net_ip' => '127.0.0.1',
'replicator_concurrency' => '2',
'updater_concurrency' => '1',
'reaper_concurrency' => '1',
'mount_check' => 'true',
'require' => 'Class[Swift]',
})
should contain_swift__storage__server('6001').with({
'type' => 'container',
'config_file_path' => 'container-server.conf',
'log_facility' => 'LOG_LOCAL4',
'pipeline' => ['healthcheck', 'container-server'],
'storage_local_net_ip' => '127.0.0.1',
'replicator_concurrency' => '2',
'updater_concurrency' => '1',
'reaper_concurrency' => '1',
'mount_check' => 'true',
'require' => 'Class[Swift]',
})
should contain_swift__storage__server('6002').with({
'type' => 'account',
'config_file_path' => 'account-server.conf',
'log_facility' => 'LOG_LOCAL2',
'pipeline' => ['healthcheck', 'account-server'],
'storage_local_net_ip' => '127.0.0.1',
'replicator_concurrency' => '2',
'updater_concurrency' => '1',
'reaper_concurrency' => '1',
'mount_check' => 'true',
'require' => 'Class[Swift]',
})
end
it 'create and configure the hard drive' do
should contain_swift__storage__xfs('sdc')
should contain_swift__storage__xfs('sdd')
should contain_cloud__object__set_io_scheduler('sdc')
should contain_cloud__object__set_io_scheduler('sdd')
end
['account', 'container', 'object'].each do |swift_component|
it "configures #{swift_component} filter" do
should contain_swift__storage__filter__recon(swift_component)
should contain_swift__storage__filter__healthcheck(swift_component)
end
end
end
context 'on Debian platforms' do
let :facts do
{
:concat_basedir => '/tmp/',
:concat_basedir => '/tmp/foo',
:osfamily => 'Debian' ,
}
end
it_configures 'openstack storage configuration'
end
context 'on RedHat platforms' do
let :facts do
{
:concat_basedir => '/tmp/',
:concat_basedir => '/tmp/foo',
:osfamily => 'RedHat'
}
end
it_configures 'openstack storage configuration'
end
end