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:
Gorka Eguileor 2018-07-17 11:14:49 +02:00
parent b52d26a361
commit 7509ad4fb6
2 changed files with 12 additions and 1 deletions

View File

@ -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:

View File

@ -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