Merge "Configure Cinder backup driver"
This commit is contained in:
commit
cd0147194d
45
lib/cinder
45
lib/cinder
@ -31,6 +31,7 @@ set +o xtrace
|
|||||||
CINDER_DRIVER=${CINDER_DRIVER:-default}
|
CINDER_DRIVER=${CINDER_DRIVER:-default}
|
||||||
CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins
|
CINDER_PLUGINS=$TOP_DIR/lib/cinder_plugins
|
||||||
CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends
|
CINDER_BACKENDS=$TOP_DIR/lib/cinder_backends
|
||||||
|
CINDER_BACKUPS=$TOP_DIR/lib/cinder_backups
|
||||||
|
|
||||||
# grab plugin config if specified via cinder_driver
|
# grab plugin config if specified via cinder_driver
|
||||||
if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
|
if [[ -r $CINDER_PLUGINS/$CINDER_DRIVER ]]; then
|
||||||
@ -98,6 +99,16 @@ else
|
|||||||
CINDER_ISCSI_HELPER=${CINDER_ISCSI_HELPER:-tgtadm}
|
CINDER_ISCSI_HELPER=${CINDER_ISCSI_HELPER:-tgtadm}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# For backward compatibility
|
||||||
|
# Before CINDER_BACKUP_DRIVER was introduced, ceph backup driver was configured
|
||||||
|
# along with ceph backend driver.
|
||||||
|
if [[ -z "${CINDER_BACKUP_DRIVER}" && "$CINDER_ENABLED_BACKENDS" =~ "ceph" ]]; then
|
||||||
|
CINDER_BACKUP_DRIVER=ceph
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Supported backup drivers are in lib/cinder_backups
|
||||||
|
CINDER_BACKUP_DRIVER=${CINDER_BACKUP_DRIVER:-swift}
|
||||||
|
|
||||||
# Toggle for deploying Cinder under a wsgi server. Legacy mod_wsgi
|
# Toggle for deploying Cinder under a wsgi server. Legacy mod_wsgi
|
||||||
# reference should be cleaned up to more accurately refer to uwsgi.
|
# reference should be cleaned up to more accurately refer to uwsgi.
|
||||||
CINDER_USE_MOD_WSGI=${CINDER_USE_MOD_WSGI:-True}
|
CINDER_USE_MOD_WSGI=${CINDER_USE_MOD_WSGI:-True}
|
||||||
@ -113,6 +124,15 @@ if is_service_enabled c-vol && [[ -n "$CINDER_ENABLED_BACKENDS" ]]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Source the backup driver
|
||||||
|
if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
|
||||||
|
if [[ -r $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER ]]; then
|
||||||
|
source $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER
|
||||||
|
else
|
||||||
|
die "cinder backup driver $CINDER_BACKUP_DRIVER is not supported"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Environment variables to configure the image-volume cache
|
# Environment variables to configure the image-volume cache
|
||||||
CINDER_IMG_CACHE_ENABLED=${CINDER_IMG_CACHE_ENABLED:-True}
|
CINDER_IMG_CACHE_ENABLED=${CINDER_IMG_CACHE_ENABLED:-True}
|
||||||
|
|
||||||
@ -189,6 +209,12 @@ function cleanup_cinder {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
|
||||||
|
if type cleanup_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
|
||||||
|
cleanup_cinder_backup_$CINDER_BACKUP_DRIVER
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
stop_process "c-api"
|
stop_process "c-api"
|
||||||
remove_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI"
|
remove_uwsgi_config "$CINDER_UWSGI_CONF" "$CINDER_UWSGI"
|
||||||
}
|
}
|
||||||
@ -266,13 +292,12 @@ function configure_cinder {
|
|||||||
configure_cinder_image_volume_cache
|
configure_cinder_image_volume_cache
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_service_enabled c-bak; then
|
if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
|
||||||
# NOTE(mriedem): The default backup driver uses swift and if we're
|
if type configure_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
|
||||||
# on a subnode we might not know if swift is enabled, but chances are
|
configure_cinder_backup_$CINDER_BACKUP_DRIVER
|
||||||
# good that it is on the controller so configure the backup service
|
else
|
||||||
# to use it. If we want to configure the backup service to use
|
die "configure_cinder_backup_$CINDER_BACKUP_DRIVER doesn't exist in $CINDER_BACKUPS/$CINDER_BACKUP_DRIVER"
|
||||||
# a non-swift driver, we'll likely need environment variables.
|
fi
|
||||||
iniset $CINDER_CONF DEFAULT backup_swift_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/AUTH_"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_service_enabled ceilometer; then
|
if is_service_enabled ceilometer; then
|
||||||
@ -410,6 +435,12 @@ function init_cinder {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if is_service_enabled c-bak && [[ -n "$CINDER_BACKUP_DRIVER" ]]; then
|
||||||
|
if type init_cinder_backup_$CINDER_BACKUP_DRIVER >/dev/null 2>&1; then
|
||||||
|
init_cinder_backup_$CINDER_BACKUP_DRIVER
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p $CINDER_STATE_PATH/volumes
|
mkdir -p $CINDER_STATE_PATH/volumes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,6 @@
|
|||||||
# Enable with:
|
# Enable with:
|
||||||
#
|
#
|
||||||
# CINDER_ENABLED_BACKENDS+=,ceph:ceph
|
# CINDER_ENABLED_BACKENDS+=,ceph:ceph
|
||||||
#
|
|
||||||
# Optional parameters:
|
|
||||||
# CINDER_BAK_CEPH_POOL=<pool-name>
|
|
||||||
# CINDER_BAK_CEPH_USER=<user>
|
|
||||||
# CINDER_BAK_CEPH_POOL_PG=<pg-num>
|
|
||||||
# CINDER_BAK_CEPH_POOL_PGP=<pgp-num>
|
|
||||||
|
|
||||||
# Dependencies:
|
# Dependencies:
|
||||||
#
|
#
|
||||||
@ -29,11 +23,6 @@ set +o xtrace
|
|||||||
# Defaults
|
# Defaults
|
||||||
# --------
|
# --------
|
||||||
|
|
||||||
CINDER_BAK_CEPH_POOL=${CINDER_BAK_CEPH_POOL:-backups}
|
|
||||||
CINDER_BAK_CEPH_POOL_PG=${CINDER_BAK_CEPH_POOL_PG:-8}
|
|
||||||
CINDER_BAK_CEPH_POOL_PGP=${CINDER_BAK_CEPH_POOL_PGP:-8}
|
|
||||||
CINDER_BAK_CEPH_USER=${CINDER_BAK_CEPH_USER:-cinder-bak}
|
|
||||||
|
|
||||||
|
|
||||||
# Entry Points
|
# Entry Points
|
||||||
# ------------
|
# ------------
|
||||||
@ -52,27 +41,6 @@ function configure_cinder_backend_ceph {
|
|||||||
iniset $CINDER_CONF $be_name rbd_flatten_volume_from_snapshot False
|
iniset $CINDER_CONF $be_name rbd_flatten_volume_from_snapshot False
|
||||||
iniset $CINDER_CONF $be_name rbd_max_clone_depth 5
|
iniset $CINDER_CONF $be_name rbd_max_clone_depth 5
|
||||||
iniset $CINDER_CONF DEFAULT glance_api_version 2
|
iniset $CINDER_CONF DEFAULT glance_api_version 2
|
||||||
|
|
||||||
if is_service_enabled c-bak; then
|
|
||||||
sudo ceph -c ${CEPH_CONF_FILE} osd pool create ${CINDER_BAK_CEPH_POOL} ${CINDER_BAK_CEPH_POOL_PG} ${CINDER_BAK_CEPH_POOL_PGP}
|
|
||||||
if [ "$REMOTE_CEPH" = "False" ]; then
|
|
||||||
# Configure Cinder backup service options, ceph pool, ceph user and ceph key
|
|
||||||
sudo ceph -c ${CEPH_CONF_FILE} osd pool set ${CINDER_BAK_CEPH_POOL} size ${CEPH_REPLICAS}
|
|
||||||
if [[ $CEPH_REPLICAS -ne 1 ]]; then
|
|
||||||
sudo ceph -c ${CEPH_CONF_FILE} osd pool set ${CINDER_BAK_CEPH_POOL} crush_ruleset ${RULE_ID}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
sudo chown $(whoami):$(whoami) ${CEPH_CONF_DIR}/ceph.client.${CINDER_BAK_CEPH_USER}.keyring
|
|
||||||
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.ceph.CephBackupDriver"
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_ceph_conf "$CEPH_CONF_FILE"
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_ceph_pool "$CINDER_BAK_CEPH_POOL"
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_ceph_user "$CINDER_BAK_CEPH_USER"
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_ceph_stripe_unit 0
|
|
||||||
iniset $CINDER_CONF DEFAULT backup_ceph_stripe_count 0
|
|
||||||
iniset $CINDER_CONF DEFAULT restore_discard_excess_bytes True
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore xtrace
|
# Restore xtrace
|
||||||
|
57
lib/cinder_backups/ceph
Normal file
57
lib/cinder_backups/ceph
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lib/cinder_backups/ceph
|
||||||
|
# Configure the ceph backup driver
|
||||||
|
|
||||||
|
# Enable with:
|
||||||
|
#
|
||||||
|
# CINDER_BACKUP_DRIVER=ceph
|
||||||
|
|
||||||
|
# Dependencies:
|
||||||
|
#
|
||||||
|
# - ``functions`` file
|
||||||
|
# - ``cinder`` configurations
|
||||||
|
|
||||||
|
# Save trace setting
|
||||||
|
_XTRACE_CINDER_CEPH=$(set +o | grep xtrace)
|
||||||
|
set +o xtrace
|
||||||
|
|
||||||
|
# Defaults
|
||||||
|
# --------
|
||||||
|
|
||||||
|
CINDER_BAK_CEPH_POOL=${CINDER_BAK_CEPH_POOL:-backups}
|
||||||
|
CINDER_BAK_CEPH_POOL_PG=${CINDER_BAK_CEPH_POOL_PG:-8}
|
||||||
|
CINDER_BAK_CEPH_POOL_PGP=${CINDER_BAK_CEPH_POOL_PGP:-8}
|
||||||
|
CINDER_BAK_CEPH_USER=${CINDER_BAK_CEPH_USER:-cinder-bak}
|
||||||
|
|
||||||
|
|
||||||
|
function configure_cinder_backup_ceph {
|
||||||
|
sudo ceph -c ${CEPH_CONF_FILE} osd pool create ${CINDER_BAK_CEPH_POOL} ${CINDER_BAK_CEPH_POOL_PG} ${CINDER_BAK_CEPH_POOL_PGP}
|
||||||
|
if [ "$REMOTE_CEPH" = "False" ]; then
|
||||||
|
# Configure Cinder backup service options, ceph pool, ceph user and ceph key
|
||||||
|
sudo ceph -c ${CEPH_CONF_FILE} osd pool set ${CINDER_BAK_CEPH_POOL} size ${CEPH_REPLICAS}
|
||||||
|
if [[ $CEPH_REPLICAS -ne 1 ]]; then
|
||||||
|
sudo ceph -c ${CEPH_CONF_FILE} osd pool set ${CINDER_BAK_CEPH_POOL} crush_ruleset ${RULE_ID}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
sudo chown $(whoami):$(whoami) ${CEPH_CONF_DIR}/ceph.client.${CINDER_BAK_CEPH_USER}.keyring
|
||||||
|
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.ceph.CephBackupDriver"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_ceph_conf "$CEPH_CONF_FILE"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_ceph_pool "$CINDER_BAK_CEPH_POOL"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_ceph_user "$CINDER_BAK_CEPH_USER"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_ceph_stripe_unit 0
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_ceph_stripe_count 0
|
||||||
|
iniset $CINDER_CONF DEFAULT restore_discard_excess_bytes True
|
||||||
|
}
|
||||||
|
|
||||||
|
# init_cinder_backup_ceph: nothing to do
|
||||||
|
# cleanup_cinder_backup_ceph: nothing to do
|
||||||
|
|
||||||
|
# Restore xtrace
|
||||||
|
$_XTRACE_CINDER_CEPH
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
45
lib/cinder_backups/s3_swift
Normal file
45
lib/cinder_backups/s3_swift
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lib/cinder_backups/s3_swift
|
||||||
|
# Configure the s3 backup driver with swift s3api
|
||||||
|
#
|
||||||
|
# TODO: create lib/cinder_backup/s3 for external s3 compatible storage
|
||||||
|
|
||||||
|
# Enable with:
|
||||||
|
#
|
||||||
|
# CINDER_BACKUP_DRIVER=s3_swift
|
||||||
|
# enable_service s3api s-proxy s-object s-container s-account
|
||||||
|
|
||||||
|
# Dependencies:
|
||||||
|
#
|
||||||
|
# - ``functions`` file
|
||||||
|
# - ``cinder`` configurations
|
||||||
|
|
||||||
|
# Save trace setting
|
||||||
|
_XTRACE_CINDER_S3_SWIFT=$(set +o | grep xtrace)
|
||||||
|
set +o xtrace
|
||||||
|
|
||||||
|
function configure_cinder_backup_s3_swift {
|
||||||
|
# This configuration requires swift and s3api. If we're
|
||||||
|
# on a subnode we might not know if they are enabled
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.s3.S3BackupDriver"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_s3_endpoint_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$S3_SERVICE_PORT"
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_cinder_backup_s3_swift {
|
||||||
|
openstack ec2 credential create
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_s3_store_access_key "$(openstack ec2 credential list -c Access -f value)"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_s3_store_secret_key "$(openstack ec2 credential list -c Secret -f value)"
|
||||||
|
if is_service_enabled tls-proxy; then
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_s3_ca_cert_file "$SSL_BUNDLE_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# cleanup_cinder_backup_s3_swift: nothing to do
|
||||||
|
|
||||||
|
# Restore xtrace
|
||||||
|
$_XTRACE_CINDER_S3_SWIFT
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
38
lib/cinder_backups/swift
Normal file
38
lib/cinder_backups/swift
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lib/cinder_backups/swift
|
||||||
|
# Configure the swift backup driver
|
||||||
|
|
||||||
|
# Enable with:
|
||||||
|
#
|
||||||
|
# CINDER_BACKUP_DRIVER=swift
|
||||||
|
|
||||||
|
# Dependencies:
|
||||||
|
#
|
||||||
|
# - ``functions`` file
|
||||||
|
# - ``cinder`` configurations
|
||||||
|
|
||||||
|
# Save trace setting
|
||||||
|
_XTRACE_CINDER_SWIFT=$(set +o | grep xtrace)
|
||||||
|
set +o xtrace
|
||||||
|
|
||||||
|
|
||||||
|
function configure_cinder_backup_swift {
|
||||||
|
# NOTE(mriedem): The default backup driver uses swift and if we're
|
||||||
|
# on a subnode we might not know if swift is enabled, but chances are
|
||||||
|
# good that it is on the controller so configure the backup service
|
||||||
|
# to use it.
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.swift.SwiftBackupDriver"
|
||||||
|
iniset $CINDER_CONF DEFAULT backup_swift_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$SWIFT_DEFAULT_BIND_PORT/v1/AUTH_"
|
||||||
|
}
|
||||||
|
|
||||||
|
# init_cinder_backup_swift: nothing to do
|
||||||
|
# cleanup_cinder_backup_swift: nothing to do
|
||||||
|
|
||||||
|
|
||||||
|
# Restore xtrace
|
||||||
|
$_XTRACE_CINDER_SWIFT
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# End:
|
Loading…
x
Reference in New Issue
Block a user