From a00f41a02b90ca93e21e9a98236af21b454872b3 Mon Sep 17 00:00:00 2001 From: Ronen Kat Date: Thu, 7 Aug 2014 17:00:53 +0300 Subject: [PATCH] Enable Swift backup driver for auth 2.0 This patch adds support for Swift auth 2.0 to the cinder-backup Swift driver. DocImpact Change-Id: I99585661792420e363b5259c9ed45a853a939a74 Closes-Bug: #1354801 --- cinder/backup/drivers/swift.py | 21 ++++++++++++++++----- etc/cinder/cinder.conf.sample | 8 ++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cinder/backup/drivers/swift.py b/cinder/backup/drivers/swift.py index 1c1751f31..eedc72361 100644 --- a/cinder/backup/drivers/swift.py +++ b/cinder/backup/drivers/swift.py @@ -58,6 +58,14 @@ swiftbackup_service_opts = [ cfg.StrOpt('backup_swift_auth', default='per_user', help='Swift authentication mechanism'), + cfg.StrOpt('backup_swift_auth_version', + default='1', + help='Swift authentication version. Specify "1" for auth 1.0' + ', or "2" for auth 2.0'), + cfg.StrOpt('backup_swift_tenant', + default=None, + help='Swift tenant/account name. Required when connecting' + ' to an auth 2.0 system'), cfg.StrOpt('backup_swift_user', default=None, help='Swift user name'), @@ -125,11 +133,14 @@ class SwiftBackupDriver(BackupDriver): "but %(param)s not set") % {'param': 'backup_swift_user'}) raise exception.ParameterNotFound(param='backup_swift_user') - self.conn = swift.Connection(authurl=CONF.backup_swift_url, - user=CONF.backup_swift_user, - key=CONF.backup_swift_key, - retries=self.swift_attempts, - starting_backoff=self.swift_backoff) + self.conn = swift.Connection( + authurl=CONF.backup_swift_url, + auth_version=CONF.backup_swift_auth_version, + tenant_name=CONF.backup_swift_tenant, + user=CONF.backup_swift_user, + key=CONF.backup_swift_key, + retries=self.swift_attempts, + starting_backoff=self.swift_backoff) else: self.conn = swift.Connection(retries=self.swift_attempts, preauthurl=self.swift_url, diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 25c4dcb67..31fe4584a 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -409,6 +409,14 @@ # Swift authentication mechanism (string value) #backup_swift_auth=per_user +# Swift authentication version. Specify "1" for auth 1.0, or +# "2" for auth 2.0 (string value) +#backup_swift_auth_version=1 + +# Swift tenant/account name. Required when connecting to an +# auth 2.0 system (string value) +#backup_swift_tenant= + # Swift user name (string value) #backup_swift_user= -- 2.45.2