问题标签 [google-compute-api]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
209 浏览

google-cloud-platform - 如何使用 creationtimestamp 字段过滤快照的 google rest api json 响应?

我正在使用邮递员中的 rest api 从谷歌项目中检索计算引擎快照。我想使用过滤器检索在某个时间戳值之后创建的快照,如果我将“=”作为运算符传递,它的工作方式如下所示:

我想要过滤大于特定时间戳的记录,所以我使用它

或者

https://cloud.google.com/compute/docs/reference/rest/v1/snapshots/list

但即使对于 < 或 > 运营商我得到这个:

任何人都可以提出解决方案吗?谢谢

更新

我的最终目标是在 data-studio 中创建一个快照报告,那么有什么方法可以将其余的 api 快照数据获取到 bigquery 或任何其他可以创建此报告的数据源?

0 投票
2 回答
629 浏览

google-cloud-platform - 我无法使用 gcloud 访问计算引擎 API?

我有一个实例运行访问范围“为每个 API 设置访问权限”,并明确允许具有读写访问权限的 Compute Engine API,如下图所示。

API访问列表

所以我通过 SSH 登录到实例内部,并尝试运行以下命令:-

gcloud compute instances list

我得到了一个错误:

- Required 'compute.zones.list' permission for 'projects/dotted-hxxl-xxx'

我的用户明确允许访问计算引擎 API,但我仍然收到错误消息。我不应该得到这个错误吗?我在这里想念什么?

0 投票
1 回答
358 浏览

google-cloud-platform - 获取 Google Cloud 中的公共 VM 映像列表

我正在使用 C# Google SDK 来获取 Google Cloud 中可用的公共 ubuntu 或 debian VM 映像列表。响应是一长串 VM',主要将弃用状态设为“OBSOLETE”。

为 ACTIVE 状态应用过滤器时,响应为 null ,任何人都可以帮助了解如何获取活动图像,或者如果没有过滤器返回的结果是正确的。

情景 1。未应用过滤器时

var lstRequest = new ImagesResource.ListRequest(_computeClient, ""); var images = lstRequest.Execute();

样本响应

{“id”:“projects/windows-cloud/global/images”,“items”:[{“archiveSizeBytes”:77493158912,“creationTimestamp”:“2017-11-06T11:38:00.859-08:00”,“弃用”:{“已删除”:空,“弃用”:空,“过时”:空,“替换”:空,“状态”:“过时”,“ETag”:空},“描述”:“微软, Windows Server,版本 1709 Core for Containers (Beta),Server Core,x64 构建于 2017-10-30","diskSizeGb":32,"family":"windows-1709-core-for-containers","guestOsFeatures" : [ { "type": "MULTI_IP_SUBNET", "ETag": null }, { "type": "VIRTIO_SCSI_MULTIQUEUE", "ETag": null }, { "type":“WINDOWS”,“ETag”:null}],“id”:7068044754301027575,“imageEncryptionKey”:null,“kind”:“compute#image”,“labelFingerprint”:“42WmSpB8rSM=”,“labels”:null, “许可证代码”:[5194306116883728686、1000226、2643967004807329741]、“许可证”:[“https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server-1709-dc” , "https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server-core", "https://www.googleapis.com/compute/v1/projects/ windows-cloud/global/licenses/windows-for-containers”],“名称”:“windows-server-1709-dc-core-for-containers-v20171030”,“rawDisk”:{“containerType”:“TAR” , "sha1Checksum": null, "source": "" }, "selfLink": "https://www.googleapis.com/compute/v1/projects/windows-cloud/global/images/windows-server-1709-dc- core-for-containers-v20171030”,“shieldedInstanceInitialState”:null,“sourceDisk”:null,“sourceDiskEncryptionKey”:null,“sourceDiskId”:null,“sourceImage”:null,“sourceImageEncryptionKey”:null,“sourceImageId”:null ,“sourceSnapshot”:null,“sourceSnapshotEncryptionKey”:null,“sourceSnapshotId”:null,“sourceType”:“RAW”,“status”:“READY”,“storageLocations”:[“us”,“us”,“eu ", "亚洲", "亚洲", "欧盟", "亚洲", "我们", "我们”,“我们”,“亚洲”,“亚洲”,“欧盟”],“ETag”:null },{“archiveSizeBytes”:79706428672,“creationTimestamp”:“2017-11-16T12:14:33.128-08 :00", "deprecated": { "deleted": null, "deprecated": null, "obsolete": null, "replacement": null, "state": "OBSOLETE", "ETag": null }, "description ": "Microsoft, Windows Server, version 1709 Core for Containers (Beta), Server Core, x64 build on 2017-11-14", "diskSizeGb": 32, "family": "windows-1709-core-for-containers ", "guestOsFeatures": [ { "type": "MULTI_IP_SUBNET", "ETag": null }, { "type": "VIRTIO_SCSI_MULTIQUEUE", "ETag": null },{ "type": "WINDOWS", "ETag": null } ], "id": 1572352838839848774, "imageEncryptionKey": null, "kind": "compute#image", "labelFingerprint": "42WmSpB8rSM=", "labels ": null, "licenseCodes": [5194306116883728686, 1000226, 2643967004807329741], "licenses": ["https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server- 1709-dc”、“https://www.googleapis.com/compute/v1/projects/windows-cloud/global/licenses/windows-server-core”、“https://www.googleapis.com/compute/ v1/projects/windows-cloud/global/licenses/windows-for-containers”],“名称”:“windows-server-1709-dc-core-for-containers-v20171114”,“rawDisk”:{“containerType” :“TAR”,“sha1Checksum”:null,“source”:“”},“selfLink”:“https://www.googleapis.com/compute/v1/projects/windows-cloud/global/images/windows-server- 1709-dc-core-for-containers-v20171114”,“shieldedInstanceInitialState”:null,“sourceDisk”:null,“sourceDiskEncryptionKey”:null,“sourceDiskId”:null,“sourceImage”:null,“sourceImageEncryptionKey”:null,“ sourceImageId”:null,“sourceSnapshot”:null,“sourceSnapshotEncryptionKey”:null,“sourceSnapshotId”:null,“sourceType”:“RAW”,“status”:“READY”,“storageLocations”:[“us”,“us ", "亚洲", "亚洲", "欧盟", "亚洲", "亚洲", "我们”,“亚洲”,“我们”,“我们”,“欧盟”,“欧盟”],“ETag”:空},


==================================================== ==========

场景 2:在应用过滤器时

var lstRequest = new ImagesResource.ListRequest(_computeClient, "ubuntu-os-cloud"); lstRequest.Filter = "deprecated.state=ACTIVE"; var images = lstRequest.Execute();

回复

无效的

我正在使用 Google.Apis.Compute.v1 命名空间

0 投票
1 回答
70 浏览

google-cloud-platform - 如何获得 Method: instances.aggregatedList Compute API in GCP 的部分响应

我正在尝试通过按照https://cloud.google.com/resource-manager/docs/performance#partial-responseinstances.aggregatedList设置请求参数来从 Compute API 方法获得特定响应fields

但我越来越400 BAD REQUEST

有没有我可以参考的样本来获取聚合方法的部分响应?

0 投票
1 回答
591 浏览

java - Google Cloud - Compute Engine,使用实例模板插入实例

我想通过 java google-api-client 使用 InstanceTemplate 创建一个实例。执行操作后,新实例会显示在 GCP 的 Compute Engine 前端中,并已创建。10-15 秒后,实例消失。 GCP-Compute Engine 虚拟机-实例概览

按照参考手册,我无法理解为什么我的代码不起作用。
https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert

实例对象如下所示:

Gradle 依赖项

来自 GCP 的日志:

0 投票
2 回答
1460 浏览

google-cloud-platform - 我想获取 GCP VM 实例的操作系统

我想获取 GCP VM 实例的操作系统。目前我只看到创建实例的图像。有没有办法得到它?我看到操作系统库存管理需要在 VM https://cloud.google.com/compute/docs/instances/view-os-details#api上设置一些元数据。

  • 客人属性: 键:enable-guest-attributes 值:True
  • 操作系统库存管理: 关键:enable-os-inventory 价值:True

此外,只有当 VM 处于RUNNING状态gcloud compute instances os-inventory describe VM-NAME时,才有获取操作系统配置的命令。我希望通过 REST API 获取操作系统详细信息。有没有例子可以参考?

0 投票
1 回答
159 浏览

node.js - GKE REST/Node API 调用以获取池中的节点数?

如何使用 REST(或节点)API获取 GKE 节点池的当前大小?

我正在使用运行在我的集群上的 Express 应用程序管理我自己的工作池,并且可以设置池的大小并跟踪 setSize 操作的成功,但我看不到用于获取当前节点数的 API。NodePool 资源只包含原始节点数,不包含当前数。我不想在我的一个生产虚拟机上使用 gcloud 或 kubectl。

我可以绕过 GKE 并尝试使用 Compute Engine (GCE) API 来推断大小,但我还没有研究过这种方法。请注意,即使从 Stack Driver 获取节点数似乎也很困难。有没有人找到任何解决方法来获取当前节点大小?

0 投票
1 回答
29 浏览

google-cloud-platform - 从没有外部 IP 的计算实例访问谷歌存储

我需要在没有公共 IP 的情况下从我的虚拟机读取和写入谷歌存储。它有一个带有自定义图像的磁盘,里面有我需要的一切:python 等。

我用这样的脚本创建了一个实例。在config字典中,您可以看到networkInterfaces我指定不希望我的机器使用公共 IP 的部分。

我在此处粘贴该部分和我的配置:

问题是这个设置甚至不允许我在同一个项目中写入既不从谷歌存储读取的内容。仅供参考ping www.google.com也不起作用。

0 投票
1 回答
21 浏览

python - 如何在 Google 的 Python API 客户端中仅指定正在运行的实例?

我正在使用 Python API 构建 gcloud 实例列表。

这些是从服务器上的 GCP 中提取信息的命令:

当我运行脚本时,它会为正在运行和停止的项目中的所有服务器提取信息。

如何指定我只想使用这些命令获取正在运行的服务器?我可以status=running在这些命令中指定某个地方吗?

0 投票
1 回答
137 浏览

google-cloud-platform - 使用哪个客户端库与 Google Cloud Compute 交互

我正在开发一个与 Google Cloud Compute 交互的项目。为此,我找到了两种使用 Python 与 Google Cloud 交互的方法(也可以使用其他语言);

Google API 客户端(Rest 编排) - google-api-python-client

谷歌云客户端 - 用于计算 - google-cloud-compute

现在 Google api 客户端适用于我,但由于它不是推荐的方式,我尝试评估 Google Cloud 客户端。为此,我检查了 google-cloud-compute,但它处于 aplha 阶段,没有提及 GA 时间表。

我也检查了 nodejs、golang 和 python 计算客户端,但谷歌计算客户端库都是预览版或 alpha 版。

所以,我应该继续使用 Google API 客户端库还是等待计算客户端足够成熟。