Add cephfs resource type and profile

This resource type can be used for setting up cephfs, it
expects FS name, data and metadata pool names as input
parameters. Data and metadata pools should already exist.

Change-Id: I18436a64fc991b9e697a1d79e369ac110cf8fe20
Partial-Bug: #1644784
This commit is contained in:
Jan Provaznik 2016-12-01 20:27:51 +01:00
parent fd5cf462c6
commit 28e8f4525f
7 changed files with 195 additions and 0 deletions

View File

@ -20,6 +20,9 @@ ceph::profile::params::osd_recovery_op_priority: '1'
ceph::profile::params::osd_recovery_max_single_start: '1'
ceph::profile::params::osd_max_scrubs: '1'
ceph::profile::params::osd_op_threads: '2'
ceph::profile::params::fs_name: 'fs_name'
ceph::profile::params::fs_metadata_pool: 'metadata_pool'
ceph::profile::params::fs_data_pool: 'data_pool'
######## Keys
ceph::profile::params::mon_key: 'AQATGHJTUCBqIBAA7M2yafV1xctn1pgr3GcKPg=='

56
manifests/fs.pp Normal file
View File

@ -0,0 +1,56 @@
#
# Copyright 2016 Red Hat, Inc.
#
# 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.
#
# Author: Jan Provaznik <jprovazn@redhat.com>
#
# Manages operations on the fs in the cluster, such as creating or deleting
# fs, setting PG/PGP numbers, number of replicas, ...
#
# == Define: ceph::fs
#
# The name of the fs.
#
# === Parameters:
#
# [*name*] Name of the filesystem.
# Optional. Default is cephfs.
#
# [*metadata_pool*] Name of a pool used for storing metadata.
# Mandatory. Get one with `ceph osd pool ls`
#
# [*data_pool*] Name of a pool used for storing data.
# Mandatory. Get one with `ceph osd pool ls`
#
# [*exec_timeout*] The default exec resource timeout, in seconds
# Optional. Defaults to $::ceph::params::exec_timeout
#
define ceph::fs (
$metadata_pool,
$data_pool,
$exec_timeout = $::ceph::params::exec_timeout,
) {
Ceph_config<||> -> Exec["create-fs-${name}"]
Ceph::Pool<||> -> Exec["create-fs-${name}"]
exec { "create-fs-${name}":
command => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
ceph fs new ${name} ${metadata_pool} ${data_pool}",
unless => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
ceph fs ls | grep 'name: ${name},'",
timeout => $exec_timeout,
}
}

29
manifests/profile/fs.pp Normal file
View File

@ -0,0 +1,29 @@
#
# Copyright (C) 2016 Red Hat, Inc.
#
# 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.
#
# Author: Jan Provaznik <jprovazn@redhat.com>
#
# == Class: ceph::profile::fs
#
# Profile for a Ceph fs
#
class ceph::profile::fs {
require ::ceph::profile::base
ceph::fs { $ceph::profile::params::fs_name:
metadata_pool => $ceph::profile::params::fs_metadata_pool,
data_pool => $ceph::profile::params::fs_data_pool,
}
}

View File

@ -175,6 +175,16 @@
#
# [*rbd_mirror_client_name*] Name of the cephx client key used for rbd mirroring
# Optional. Default is undef
#
# [*fs_name*] The FS name.
# Optional but required when using fs.
#
# [*fs_metadata_pool*] The FS metadata pool name.
# Optional but required when using fs.
#
# [*fs_data_pool*] The FS data pool name.
# Optional but required when using fs.
#
class ceph::profile::params (
@ -219,6 +229,9 @@ class ceph::profile::params (
$rgw_keystone_admin_user = undef,
$rgw_keystone_admin_password = undef,
$rbd_mirror_client_name = undef,
$fs_metadata_pool = undef,
$fs_data_pool = undef,
$fs_name = undef,
) {
validate_hash($client_keys)

View File

@ -0,0 +1,39 @@
#
# Copyright (C) 2016 Red Hat, Inc.
#
# 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.
#
require 'spec_helper'
describe 'ceph::profile::fs' do
shared_examples_for 'ceph profile fs' do
it { is_expected.to contain_ceph__fs('fs_name').with(
'metadata_pool' => 'metadata_pool',
'data_pool' => 'data_pool'
)}
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({:hostname => 'myhostname'}))
end
it_behaves_like 'ceph profile fs'
end
end
end

View File

@ -0,0 +1,52 @@
# Copyright 2016 Red Hat, Inc.
#
# 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.
#
require 'spec_helper'
describe 'ceph::fs' do
shared_examples_for 'ceph fs' do
describe "activated with custom params" do
let :title do
'fsa'
end
let :params do
{
:metadata_pool => 'metadata_pool',
:data_pool => 'data_pool'
}
end
it { is_expected.to contain_exec('create-fs-fsa').with(
:command => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs new fsa metadata_pool data_pool",
:unless => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs ls | grep 'name: fsa,'"
)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({:hostname => 'myhostname'}))
end
it_behaves_like 'ceph fs'
end
end
end

View File

@ -23,6 +23,9 @@ ceph::profile::params::osd_recovery_op_priority: '1'
ceph::profile::params::osd_recovery_max_single_start: '1'
ceph::profile::params::osd_max_scrubs: '1'
ceph::profile::params::osd_op_threads: '2'
ceph::profile::params::fs_name: 'fs_name'
ceph::profile::params::fs_metadata_pool: 'metadata_pool'
ceph::profile::params::fs_data_pool: 'data_pool'
######## Keys
ceph::profile::params::mds_key: 'AQDLOh1VgEp6FRAAFzT7Zw+Y9V6JJExQAsRnRQ=='