我正在使用:
Python代码如下所示:
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
def run():
""" Run this script
"""
ComputeEngine = get_driver(Provider.GCE)
driver = ComputeEngine(user_id='****@****.com',
credential_file='serviceaccount.json',
project='****')
run()
当我运行我的代码时,我得到了:
Traceback (most recent call last):
File "./myscript.py", line 47, in <module>
run()
File "./myscript.py", line 21, in run
project='ebs-it', secure=True)
File "/***/virtualenv/lib/python3.5/site-packages/libcloud/compute/drivers/gce.py", line 1795, in __init__
super(GCENodeDriver, self).__init__(user_id, key, **kwargs)
File "/***/virtualenv/lib/python3.5/site-packages/libcloud/common/base.py", line 975, in __init__
self.connection = self.connectionCls(*args, **conn_kwargs)
TypeError: __init__() missing 1 required positional argument: 'secure'
这对我来说perfectly textbook。知道会出现什么问题吗?
答案 0 :(得分:0)
问题有两个:不熟悉Google的服务帐户,导致编码错误。
credential_file
参数,它似乎比应该用于服务帐户文件的key
参数更合适。这就是导致我看到的实际错误的原因。