def __init__(self, credentials_dict):
"""
Build GCE service account credentials from info stored in environment variables, then build a GCE API wrapper
with those credentials. Only one of the two environment variables must be set.
:param creds_env_var_name: JSON string that contains your GCE service account credentials
:param creds_path_env_var_name: string that contains the path to the file containing your GCE service account
credentials.
"""
credentials = ServiceAccountCredentials.from_json_keyfile_dict(
credentials_dict, scopes='https://www.googleapis.com/auth/cloud-platform')
self.compute = discovery.build('compute', 'v1', credentials=credentials)
self.deployment_manager = discovery.build('deploymentmanager', 'v2', credentials=credentials)
self.project_id = credentials_dict['project_id']
评论列表
文章目录