devstack/lib/cinder_backups/s3_swift
Hironori Shiina 01a84d2d03 Configure Cinder backup driver
This patch adds a new environment variable, CINDER_BACKUP_DRIVER for
configuring cinder backup driver used when c-bak service is enabled.
This gets cinder backup driver configurable with a similar pattern to
cinder backends. Although the current configurable backup drivers don't
need cleanup functions, the interface for cleanup is prepared for the
future.

The following backup drivers can be configured:
  swift:
  This is the default backup driver.
  ceph:
  This already can be configured if ceph backend driver is enabled. For
  backward compatibility, ceph backup driver is used if ceph backend
  driver is enabled and no backup driver is specified.
  s3_swift:
  The s3 backup driver gets configurable with this patch. By specifying
  's3_swift', the driver is configured for swift s3api.

In the future, lib/cinder_backups/s3 should be created separatedly for
external S3 compatible storage. This file will just set given parameters
such as a URL and credentials.

Change-Id: I356c224d938e1aa59c8589387a03682b3ec6e23d
2021-03-31 15:12:25 -04:00

46 lines
1.3 KiB
Bash

#!/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: