gcutil
运行 Google Compute Engine时,在查询图像和内核时,我得到了与 不同的意外结果。值得注意的是,我没有得到任何结果。
我得到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 时(缩写,但基本上直接来自示例):
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
那个。
我在这里可能做错了什么?