【问题标题】:Google Compute Engine Python API and web API do not return images or kernelsGoogle Compute Engine Python API 和 Web API 不返回图像或内核
【发布时间】:2013-08-20 02:28:45
【问题描述】:
在运行 Google Compute Engine 时,在查询图像和内核时,我得到了与 gcutil 不同的意外结果。值得注意的是,我没有得到任何结果。
gcutil 我得到了预期的结果:
$ gcutil --project MYPROJECT 列表图像
+-------------------------------------------------- -------------+------------------------------------------------ ------------------------------+------------------ ---------------+-------------+-------- +
|姓名 |描述 |内核 |弃用 |状态 |
+-------------------------------------------------- -------------+------------------------------------------------ ------------------------------+------------------ ---------------+-------------+-------- +
|项目/centos-cloud/global/images/centos-6-v20130731 |支持 SCSI 的 CentOS 6;创建于 2013 年 7 月 31 日星期三 00:00:00 +0000 |项目/谷歌/全球/内核/gce-v20130603 | |准备好了 |
|项目/debian-cloud/global/images/debian-6-squeeze-v20130723 | Debian GNU/Linux 6.0.7 (squeeze) 建于 2013-07-23 |项目/谷歌/全球/内核/gce-v20130603 | |准备好了 |
|项目/debian-cloud/global/images/debian-7-wheezy-v20130723 | Debian GNU/Linux 7.1 (wheezy) 建立于 2013-07-23 |项目/谷歌/全球/内核/gce-v20130603 | |准备好了 |
+-------------------------------------------------- -------------+------------------------------------------------ ------------------------------+------------------ ---------------+-------------+-------- +
但是当我使用 web API 或 Python API 时(缩写,但基本上直接来自 examples):
def _service():
flow = flow_from_clientsecrets(CLIENT_SECRETS, scope=GCE_SCOPE)
storage = Storage(OAUTH2_STORAGE)
credentials = storage.get()
if credentials is None or credentials.invalid:
credentials = run(flow, storage)
http = httplib2.Http()
auth_http = credentials.authorize(http)
gce_service = build('compute', API_VERSION)
return gce_service, credentials, auth_http
if __name__ == "__main__":
gce_service, credentials, auth_http = _service()
request = gce_service.images().list(project="MYPROJECT", filter=None)
response = request.execute(http=auth_http)
pprint(response)
Web 和 Python API 都返回如下内容:
{
“种类”:“计算#imageList”,
"selfLink": "https://www.googleapis.com/compute/v1beta15/projects/MYPROJECT/global/images",
“id”:“项目/MYPROJECt/global/images”
}
即缺少items 和one expects in the response。
我在这里可能做错了什么?
【问题讨论】:
标签:
python
google-compute-engine