fence-agents/0004-fence_gce-use-default-credentials-from-googleapiclie.patch
Kristoffer Gronlund 49a513e01e - run_command: fix Python 3 encoding issue (bsc#1082871)
- fence_gce: use default credentials from googleapiclient
- fence_gce: fix regression - missing import oauth2client.client
- fence_gce: fix regression - missing import googleapiclient.discovery
- Add 0002-fence_gce-fix-regression-missing-import-googleapicli.patch
- Add 0003-fence_gce-fix-regression-missing-import-oauth2client.patch
- Add 0004-fence_gce-use-default-credentials-from-googleapiclie.patch
- Add 0005-run_command-fix-Python-3-encoding-issue.patch

OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/fence-agents?expand=0&rev=87
2018-05-17 16:27:45 +00:00

44 lines
1.6 KiB
Diff

From f94bc0bb6058fe791d597ed8aa5f60f9410debdb Mon Sep 17 00:00:00 2001
From: Helen Koike <helen.koike@collabora.com>
Date: Fri, 27 Apr 2018 13:51:40 -0300
Subject: [PATCH 4/5] fence_gce: use default credentials from googleapiclient
There are two ways for performing credentials
1) google-auth
2) oauth2client (deprecated)
googleapiclient check which libraries are present in the system and use
the most apropriated one in the order above.
Also keep compatibility with previous version of googleapiclient library
---
fence/agents/gce/fence_gce.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fence/agents/gce/fence_gce.py b/fence/agents/gce/fence_gce.py
index 3a614f14..3abb5207 100644
--- a/fence/agents/gce/fence_gce.py
+++ b/fence/agents/gce/fence_gce.py
@@ -5,7 +5,6 @@ import sys
sys.path.append("@FENCEAGENTSLIBDIR@")
import googleapiclient.discovery
-import oauth2client.client
from fencing import fail_usage, run_delay, all_opt, atexit_handler, check_input, process_input, show_docs, fence_action
def translate_status(instance_status):
@@ -99,7 +98,10 @@ def main():
run_delay(options)
try:
- credentials = oauth2client.client.GoogleCredentials.get_application_default()
+ credentials = None
+ if tuple(googleapiclient.__version__) < tuple("1.6.0"):
+ import oauth2client.client
+ credentials = oauth2client.client.GoogleCredentials.get_application_default()
conn = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
except Exception as err:
fail_usage("Failed: Create GCE compute v1 connection: {}".format(str(err)))
--
2.16.3