0

我需要列出在项目中成功创建的所有计算实例快照(仅适用于计算实例类型),以及计算引擎名称。我正在使用这个 api:https ://compute.googleapis.com/compute/v1/projects/my-project/global/snapshots

它列出了快照,我得到这样的响应

"items": [
    {
      "id": "36734343434334343",
      "creationTimestamp": "2020-09-16T11:38:54.780-07:00",
      "name": "backup-data1-us-central1-c-3234234324-202009161",
      "status": "READY",
      "sourceDisk": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/disks/backup-data1",
      "sourceDiskId": "323434232434970709",
      "diskSizeGb": "10",
      "storageBytes": "452416",
      "storageBytesStatus": "UP_TO_DATE",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/global/snapshots/amtest-backup-data1-us-central1-c-3234234324-202009161",
      "labelFingerprint": "23WmSpBrSM=",
      "storageLocations": [
        "us-central1"
      ],
      "autoCreated": true,
      "downloadBytes": "456717",
      "kind": "compute#snapshot"
    },
    {
      "id": "343486082509657007",
      "creationTimestamp": "2020-09-17T11:38:56.840-07:00",
      "name": "backup-data1-us-central1-c-3234234324-202009161",
      "status": "READY",
      "sourceDisk": "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/disks/backup-data1",
      "sourceDiskId": "323434232434970709",
      "diskSizeGb": "10",
      "storageBytes": "0",
      "storageBytesStatus": "UP_TO_DATE",
      "selfLink": "https://www.googleapis.com/compute/v1/projects/my-project/global/snapshots/amtest-backup-data1-us-central1-c-20200917183856-n2ipabzb",
      "labelFingerprint": "23WmSpB8rSM=",
      "storageLocations": [
        "us-central1"
      ],
      "autoCreated": true,
      "downloadBytes": "456717",
      "kind": "compute#snapshot"
    }

从这些信息中,我需要找出与此快照关联的虚拟机是什么,我不确定如何找出创建此快照的计算引擎?是否有任何用于从快照中查找计算引擎的 rest-api?谁能帮帮我吗?谢谢

4

1 回答 1

0

这里有一个小误解:您快照的是磁盘,而不是虚拟机。实际上,您可以分离磁盘并将其附加到另一个 VM。您还可以在多读取器中设置磁盘并将其附加到多个 VM。

所以,你的问题是错误的。您可以在所有 VM 中列出附加到它们的磁盘。然后检查每个磁盘是否存在快照。

于 2020-10-01T12:25:02.253 回答