运行Google Compute Engine运行Google Compute Engine时,在查询图像和内核时,出现意外结果,与gcutil
不同。值得注意的是我没有得到任何结果。Google Compute Engine Python API和Web API不返回图像或内核
随着gcutil
我得到预期的结果:
$ gcutil --project MYPROJECT listimages +----------------------------------------------------------------+----------------------------------------------------------------+----------------------------------------------+-------------+--------+ | name | description | kernel | deprecation | status | +----------------------------------------------------------------+----------------------------------------------------------------+----------------------------------------------+-------------+--------+ | projects/centos-cloud/global/images/centos-6-v20130731 | SCSI-enabled CentOS 6; Created Wed, 31 Jul 2013 00:00:00 +0000 | projects/google/global/kernels/gce-v20130603 | | READY | | projects/debian-cloud/global/images/debian-6-squeeze-v20130723 | Debian GNU/Linux 6.0.7 (squeeze) built on 2013-07-23 | projects/google/global/kernels/gce-v20130603 | | READY | | projects/debian-cloud/global/images/debian-7-wheezy-v20130723 | Debian GNU/Linux 7.1 (wheezy) built on 2013-07-23 | projects/google/global/kernels/gce-v20130603 | | READY | +----------------------------------------------------------------+----------------------------------------------------------------+----------------------------------------------+-------------+--------+
但是,当我使用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都返回类似这样的内容:
{ "kind": "compute#imageList", "selfLink": "https://www.googleapis.com/compute/v1beta15/projects/MYPROJECT/global/images", "id": "projects/MYPROJECt/global/images" }
即缺少items
即one expects in the response。
我在这里可能会做错什么?
非常明智,非常感谢。希望我在文档中注意到这一点。你知道在哪里可以找到这个和类似的信息,乔? –