blob: 4b180490d747b95a4baf18180a354feb719317ac [file] [log] [blame]
Hironori Shiina01a84d22021-01-11 13:42:46 -05001#!/bin/bash
2#
3# lib/cinder_backups/ceph
4# Configure the ceph backup driver
5
6# Enable with:
7#
8# CINDER_BACKUP_DRIVER=ceph
9
10# Dependencies:
11#
12# - ``functions`` file
13# - ``cinder`` configurations
14
15# Save trace setting
16_XTRACE_CINDER_CEPH=$(set +o | grep xtrace)
17set +o xtrace
18
19# Defaults
20# --------
21
22CINDER_BAK_CEPH_POOL=${CINDER_BAK_CEPH_POOL:-backups}
23CINDER_BAK_CEPH_POOL_PG=${CINDER_BAK_CEPH_POOL_PG:-8}
24CINDER_BAK_CEPH_POOL_PGP=${CINDER_BAK_CEPH_POOL_PGP:-8}
25CINDER_BAK_CEPH_USER=${CINDER_BAK_CEPH_USER:-cinder-bak}
26
27
28function configure_cinder_backup_ceph {
Francesco Pantano96dbf552022-03-18 10:56:31 +010029 # Execute this part only when cephadm is not used
30 if [[ "$CEPHADM_DEPLOY" = "False" ]]; then
31 sudo ceph -c ${CEPH_CONF_FILE} osd pool create ${CINDER_BAK_CEPH_POOL} ${CINDER_BAK_CEPH_POOL_PG} ${CINDER_BAK_CEPH_POOL_PGP}
32 if [[ "$REMOTE_CEPH" = "False" && "$CEPH_REPLICAS" -ne 1 ]]; then
33 sudo ceph -c ${CEPH_CONF_FILE} osd pool set ${CINDER_BAK_CEPH_POOL} crush_ruleset ${RULE_ID}
34 fi
35 sudo ceph -c ${CEPH_CONF_FILE} auth get-or-create client.${CINDER_BAK_CEPH_USER} mon "allow r" osd "allow class-read object_prefix rbd_children, allow rwx pool=${CINDER_BAK_CEPH_POOL}, allow rwx pool=${CINDER_CEPH_POOL}" | sudo tee ${CEPH_CONF_DIR}/ceph.client.${CINDER_BAK_CEPH_USER}.keyring
36 sudo chown $(whoami):$(whoami) ${CEPH_CONF_DIR}/ceph.client.${CINDER_BAK_CEPH_USER}.keyring
Hironori Shiina01a84d22021-01-11 13:42:46 -050037 fi
Hironori Shiina01a84d22021-01-11 13:42:46 -050038
39 iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.ceph.CephBackupDriver"
40 iniset $CINDER_CONF DEFAULT backup_ceph_conf "$CEPH_CONF_FILE"
41 iniset $CINDER_CONF DEFAULT backup_ceph_pool "$CINDER_BAK_CEPH_POOL"
42 iniset $CINDER_CONF DEFAULT backup_ceph_user "$CINDER_BAK_CEPH_USER"
43 iniset $CINDER_CONF DEFAULT backup_ceph_stripe_unit 0
44 iniset $CINDER_CONF DEFAULT backup_ceph_stripe_count 0
45 iniset $CINDER_CONF DEFAULT restore_discard_excess_bytes True
46}
47
48# init_cinder_backup_ceph: nothing to do
49# cleanup_cinder_backup_ceph: nothing to do
50
51# Restore xtrace
52$_XTRACE_CINDER_CEPH
53
54# Local variables:
55# mode: shell-script
56# End: