Prepare Google Backup driver for latest libraries
With every new google library, there are small changes that need to be done to the Google Backup Cinder driver to stay compatible. This patch updatest the code and the unit tests for libraries: google-auth===1.5.0 google-auth-httplib2===0.0.3 google-api-python-client===1.7.3 While maintaining compatibility with earlier versions: google-auth===1.4.1 google-auth-httplib2===0.0.3 google-api-python-client===1.6.7 Code has also been manually tested against Google Cloud Storage to ensure backup and restore works with the new libraries. Change-Id: I4e0c36217338fd757445aa172f6e962fb9ec507c
This commit is contained in:
parent
b52d26a361
commit
7509ad4fb6
|
@ -166,7 +166,8 @@ class GoogleBackupDriver(chunkeddriver.ChunkedBackupDriver):
|
|||
creds = service_account.Credentials.from_service_account_file(
|
||||
backup_credential)
|
||||
OAUTH_EXCEPTIONS = (gexceptions.RefreshError,
|
||||
gexceptions.DefaultCredentialsError)
|
||||
gexceptions.DefaultCredentialsError,
|
||||
client.Error)
|
||||
|
||||
# Can't use google-auth, use deprecated oauth2client
|
||||
else:
|
||||
|
|
|
@ -76,6 +76,11 @@ def gcs_client(func):
|
|||
fake_google_client.FakeGoogleMediaIoBaseDownload)
|
||||
@mock.patch.object(hashlib, 'md5', FakeMD5)
|
||||
def func_wrapper(self, *args, **kwargs):
|
||||
if google_dr.service_account:
|
||||
with mock.patch.object(google_dr.service_account.Credentials,
|
||||
'from_service_account_file',
|
||||
fake_google_client.FakeGoogleCredentials):
|
||||
return func(self, *args, **kwargs)
|
||||
return func(self, *args, **kwargs)
|
||||
|
||||
return func_wrapper
|
||||
|
@ -93,6 +98,11 @@ def gcs_client2(func):
|
|||
FakeObjectName._fake_generate_object_name_prefix)
|
||||
@mock.patch.object(hashlib, 'md5', FakeMD5)
|
||||
def func_wrapper(self, *args, **kwargs):
|
||||
if google_dr.service_account:
|
||||
with mock.patch.object(google_dr.service_account.Credentials,
|
||||
'from_service_account_file',
|
||||
fake_google_client.FakeGoogleCredentials):
|
||||
return func(self, *args, **kwargs)
|
||||
return func(self, *args, **kwargs)
|
||||
|
||||
return func_wrapper
|
||||
|
|
Loading…
Reference in New Issue