Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 1 | #!/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) |
| 17 | set +o xtrace |
| 18 | |
| 19 | # Defaults |
| 20 | # -------- |
| 21 | |
| 22 | CINDER_BAK_CEPH_POOL=${CINDER_BAK_CEPH_POOL:-backups} |
| 23 | CINDER_BAK_CEPH_POOL_PG=${CINDER_BAK_CEPH_POOL_PG:-8} |
| 24 | CINDER_BAK_CEPH_POOL_PGP=${CINDER_BAK_CEPH_POOL_PGP:-8} |
| 25 | CINDER_BAK_CEPH_USER=${CINDER_BAK_CEPH_USER:-cinder-bak} |
| 26 | |
| 27 | |
| 28 | function configure_cinder_backup_ceph { |
Francesco Pantano | 96dbf55 | 2022-03-18 10:56:31 +0100 | [diff] [blame] | 29 | # 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 Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 37 | fi |
Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 38 | |
| 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: |