| Hironori Shiina | 01a84d2 | 2021-01-11 13:42:46 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
|  | 3 | # lib/cinder_backups/s3_swift | 
|  | 4 | # Configure the s3 backup driver with swift s3api | 
|  | 5 | # | 
|  | 6 | # TODO: create lib/cinder_backup/s3 for external s3 compatible storage | 
|  | 7 |  | 
|  | 8 | # Enable with: | 
|  | 9 | # | 
|  | 10 | #   CINDER_BACKUP_DRIVER=s3_swift | 
|  | 11 | #   enable_service s3api s-proxy s-object s-container s-account | 
|  | 12 |  | 
|  | 13 | # Dependencies: | 
|  | 14 | # | 
|  | 15 | # - ``functions`` file | 
|  | 16 | # - ``cinder`` configurations | 
|  | 17 |  | 
|  | 18 | # Save trace setting | 
|  | 19 | _XTRACE_CINDER_S3_SWIFT=$(set +o | grep xtrace) | 
|  | 20 | set +o xtrace | 
|  | 21 |  | 
|  | 22 | function configure_cinder_backup_s3_swift { | 
|  | 23 | # This configuration requires swift and s3api. If we're | 
|  | 24 | # on a subnode we might not know if they are enabled | 
|  | 25 | iniset $CINDER_CONF DEFAULT backup_driver "cinder.backup.drivers.s3.S3BackupDriver" | 
|  | 26 | iniset $CINDER_CONF DEFAULT backup_s3_endpoint_url "$SWIFT_SERVICE_PROTOCOL://$SERVICE_HOST:$S3_SERVICE_PORT" | 
|  | 27 | } | 
|  | 28 |  | 
|  | 29 | function init_cinder_backup_s3_swift { | 
|  | 30 | openstack ec2 credential create | 
|  | 31 | iniset $CINDER_CONF DEFAULT backup_s3_store_access_key "$(openstack ec2 credential list -c Access -f value)" | 
|  | 32 | iniset $CINDER_CONF DEFAULT backup_s3_store_secret_key "$(openstack ec2 credential list -c Secret -f value)" | 
|  | 33 | if is_service_enabled tls-proxy; then | 
|  | 34 | iniset $CINDER_CONF DEFAULT backup_s3_ca_cert_file "$SSL_BUNDLE_FILE" | 
|  | 35 | fi | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | # cleanup_cinder_backup_s3_swift: nothing to do | 
|  | 39 |  | 
|  | 40 | # Restore xtrace | 
|  | 41 | $_XTRACE_CINDER_S3_SWIFT | 
|  | 42 |  | 
|  | 43 | # Local variables: | 
|  | 44 | # mode: shell-script | 
|  | 45 | # End: |