Use a default all scopes to create credentials.
Seperate scopes for each api call will ask user to go oauth2 flow
multiple times.This cl try to use a default all scopes to create
credential and reuse it for all cloud api call.
Bug: 118287079
Test: rm ~/.acloud_oauth2.dat &&
run acloud create/delete cmd only see oauth2 flow once
atest acloud_test
Change-Id: Ie8a204c8825b82e300a5f5e4dba548658dc8a45f
diff --git a/public/acloud_kernel/kernel_swapper.py b/public/acloud_kernel/kernel_swapper.py
index 35fc744..6041b82 100755
--- a/public/acloud_kernel/kernel_swapper.py
+++ b/public/acloud_kernel/kernel_swapper.py
@@ -21,18 +21,10 @@
from acloud.public import errors
from acloud.public import report
-from acloud.internal.lib import android_build_client
from acloud.internal.lib import android_compute_client
from acloud.internal.lib import auth
-from acloud.internal.lib import gstorage_client
from acloud.internal.lib import utils
-ALL_SCOPES = ' '.join([
- android_build_client.AndroidBuildClient.SCOPE,
- gstorage_client.StorageClient.SCOPE,
- android_compute_client.AndroidComputeClient.SCOPE
-])
-
# ssh flags used to communicate with the Cloud Android instance.
SSH_FLAGS = [
'-q', '-o UserKnownHostsFile=/dev/null', '-o "StrictHostKeyChecking no"',
@@ -62,7 +54,7 @@
cfg: AcloudConfig object, used to create credentials.
instance_name: string, instance name.
"""
- credentials = auth.CreateCredentials(cfg, ALL_SCOPES)
+ credentials = auth.CreateCredentials(cfg)
self._compute_client = android_compute_client.AndroidComputeClient(
cfg, credentials)
# Name of the Cloud Android instance.
@@ -149,8 +141,7 @@
host_cmd.
"""
utils.Retry(
- retry_checker=
- lambda e: isinstance(e, subprocess.CalledProcessError),
+ retry_checker=lambda e: isinstance(e, subprocess.CalledProcessError),
max_retries=2,
functor=lambda cmd: subprocess.check_call(cmd, shell=True),
sleep_multiplier=0,